Blame view
arch/mips/oprofile/common.c
2.83 KB
1da177e4c
|
1 2 3 4 5 |
/* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * |
54176736f
|
6 7 |
* Copyright (C) 2004, 2005 Ralf Baechle * Copyright (C) 2005 MIPS Technologies, Inc. |
1da177e4c
|
8 |
*/ |
e52dd9fc6
|
9 |
#include <linux/compiler.h> |
1da177e4c
|
10 11 12 13 14 15 16 |
#include <linux/errno.h> #include <linux/init.h> #include <linux/oprofile.h> #include <linux/smp.h> #include <asm/cpu-info.h> #include "op_impl.h" |
e52dd9fc6
|
17 18 19 |
extern struct op_mips_model op_model_mipsxx_ops __weak; extern struct op_mips_model op_model_rm9000_ops __weak; extern struct op_mips_model op_model_loongson2_ops __weak; |
1da177e4c
|
20 21 22 23 24 25 26 27 28 29 30 |
static struct op_mips_model *model; static struct op_counter_config ctr[20]; static int op_mips_setup(void) { /* Pre-compute the values to stuff in the hardware registers. */ model->reg_setup(ctr); /* Configure the registers on all cpus. */ |
15c8b6c1a
|
31 |
on_each_cpu(model->cpu_setup, NULL, 1); |
1da177e4c
|
32 33 34 |
return 0; } |
25ad2913c
|
35 |
static int op_mips_create_files(struct super_block *sb, struct dentry *root) |
1da177e4c
|
36 37 38 39 40 |
{ int i; for (i = 0; i < model->num_counters; ++i) { struct dentry *dir; |
0c6856f70
|
41 |
char buf[4]; |
1da177e4c
|
42 43 44 45 46 47 48 |
snprintf(buf, sizeof buf, "%d", i); dir = oprofilefs_mkdir(sb, root, buf); oprofilefs_create_ulong(sb, dir, "enabled", &ctr[i].enabled); oprofilefs_create_ulong(sb, dir, "event", &ctr[i].event); oprofilefs_create_ulong(sb, dir, "count", &ctr[i].count); |
1da177e4c
|
49 50 51 |
oprofilefs_create_ulong(sb, dir, "kernel", &ctr[i].kernel); oprofilefs_create_ulong(sb, dir, "user", &ctr[i].user); oprofilefs_create_ulong(sb, dir, "exl", &ctr[i].exl); |
54176736f
|
52 |
/* Dummy. */ |
1da177e4c
|
53 54 55 56 57 58 59 60 |
oprofilefs_create_ulong(sb, dir, "unit_mask", &ctr[i].unit_mask); } return 0; } static int op_mips_start(void) { |
15c8b6c1a
|
61 |
on_each_cpu(model->cpu_start, NULL, 1); |
1da177e4c
|
62 63 64 65 66 67 68 |
return 0; } static void op_mips_stop(void) { /* Disable performance monitoring for all counters. */ |
15c8b6c1a
|
69 |
on_each_cpu(model->cpu_stop, NULL, 1); |
1da177e4c
|
70 |
} |
54176736f
|
71 |
int __init oprofile_arch_init(struct oprofile_operations *ops) |
1da177e4c
|
72 73 |
{ struct op_mips_model *lmodel = NULL; |
54176736f
|
74 |
int res; |
1da177e4c
|
75 |
|
10cc35290
|
76 |
switch (current_cpu_type()) { |
2065988e9
|
77 78 |
case CPU_5KC: case CPU_20KC: |
1da177e4c
|
79 |
case CPU_24K: |
2065988e9
|
80 |
case CPU_25KF: |
fcfd980c8
|
81 |
case CPU_34K: |
39b8d5254
|
82 |
case CPU_1004K: |
c620953c3
|
83 |
case CPU_74K: |
c03bc1212
|
84 85 |
case CPU_SB1: case CPU_SB1A: |
714cfe786
|
86 87 88 |
case CPU_R10000: case CPU_R12000: case CPU_R14000: |
1acf1ca7e
|
89 |
lmodel = &op_model_mipsxx_ops; |
1da177e4c
|
90 91 92 |
break; case CPU_RM9000: |
1acf1ca7e
|
93 |
lmodel = &op_model_rm9000_ops; |
1da177e4c
|
94 |
break; |
67b35e5d0
|
95 96 97 |
case CPU_LOONGSON2: lmodel = &op_model_loongson2_ops; break; |
1da177e4c
|
98 99 100 |
}; if (!lmodel) |
54176736f
|
101 |
return -ENODEV; |
1da177e4c
|
102 |
|
54176736f
|
103 104 105 |
res = lmodel->init(); if (res) return res; |
1da177e4c
|
106 107 |
model = lmodel; |
54176736f
|
108 109 110 111 112 113 |
ops->create_files = op_mips_create_files; ops->setup = op_mips_setup; //ops->shutdown = op_mips_shutdown; ops->start = op_mips_start; ops->stop = op_mips_stop; ops->cpu_type = lmodel->cpu_type; |
5f307491f
|
114 |
ops->backtrace = op_mips_backtrace; |
1da177e4c
|
115 116 117 118 |
printk(KERN_INFO "oprofile: using %s performance monitoring. ", lmodel->cpu_type); |
54176736f
|
119 120 |
return 0; |
1da177e4c
|
121 122 123 124 |
} void oprofile_arch_exit(void) { |
49e31ca83
|
125 126 |
if (model) model->exit(); |
1da177e4c
|
127 |
} |