aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc64/oprofile/common.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/ppc64/oprofile/common.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/ppc64/oprofile/common.c')
-rw-r--r--arch/ppc64/oprofile/common.c186
1 files changed, 186 insertions, 0 deletions
diff --git a/arch/ppc64/oprofile/common.c b/arch/ppc64/oprofile/common.c
new file mode 100644
index 000000000000..b28bfda23d94
--- /dev/null
+++ b/arch/ppc64/oprofile/common.c
@@ -0,0 +1,186 @@
1/*
2 * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM
3 *
4 * Based on alpha version.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/oprofile.h>
13#include <linux/init.h>
14#include <linux/smp.h>
15#include <linux/errno.h>
16#include <asm/ptrace.h>
17#include <asm/system.h>
18#include <asm/pmc.h>
19
20#include "op_impl.h"
21
22extern struct op_ppc64_model op_model_rs64;
23extern struct op_ppc64_model op_model_power4;
24static struct op_ppc64_model *model;
25
26static struct op_counter_config ctr[OP_MAX_COUNTER];
27static struct op_system_config sys;
28
29static void op_handle_interrupt(struct pt_regs *regs)
30{
31 model->handle_interrupt(regs, ctr);
32}
33
34static int op_ppc64_setup(void)
35{
36 int err;
37
38 /* Grab the hardware */
39 err = reserve_pmc_hardware(op_handle_interrupt);
40 if (err)
41 return err;
42
43 /* Pre-compute the values to stuff in the hardware registers. */
44 model->reg_setup(ctr, &sys, model->num_counters);
45
46 /* Configure the registers on all cpus. */
47 on_each_cpu(model->cpu_setup, NULL, 0, 1);
48
49 return 0;
50}
51
52static void op_ppc64_shutdown(void)
53{
54 release_pmc_hardware();
55}
56
57static void op_ppc64_cpu_start(void *dummy)
58{
59 model->start(ctr);
60}
61
62static int op_ppc64_start(void)
63{
64 on_each_cpu(op_ppc64_cpu_start, NULL, 0, 1);
65 return 0;
66}
67
68static inline void op_ppc64_cpu_stop(void *dummy)
69{
70 model->stop();
71}
72
73static void op_ppc64_stop(void)
74{
75 on_each_cpu(op_ppc64_cpu_stop, NULL, 0, 1);
76}
77
78static int op_ppc64_create_files(struct super_block *sb, struct dentry *root)
79{
80 int i;
81
82 /*
83 * There is one mmcr0, mmcr1 and mmcra for setting the events for
84 * all of the counters.
85 */
86 oprofilefs_create_ulong(sb, root, "mmcr0", &sys.mmcr0);
87 oprofilefs_create_ulong(sb, root, "mmcr1", &sys.mmcr1);
88 oprofilefs_create_ulong(sb, root, "mmcra", &sys.mmcra);
89
90 for (i = 0; i < model->num_counters; ++i) {
91 struct dentry *dir;
92 char buf[3];
93
94 snprintf(buf, sizeof buf, "%d", i);
95 dir = oprofilefs_mkdir(sb, root, buf);
96
97 oprofilefs_create_ulong(sb, dir, "enabled", &ctr[i].enabled);
98 oprofilefs_create_ulong(sb, dir, "event", &ctr[i].event);
99 oprofilefs_create_ulong(sb, dir, "count", &ctr[i].count);
100 /*
101 * We dont support per counter user/kernel selection, but
102 * we leave the entries because userspace expects them
103 */
104 oprofilefs_create_ulong(sb, dir, "kernel", &ctr[i].kernel);
105 oprofilefs_create_ulong(sb, dir, "user", &ctr[i].user);
106 oprofilefs_create_ulong(sb, dir, "unit_mask", &ctr[i].unit_mask);
107 }
108
109 oprofilefs_create_ulong(sb, root, "enable_kernel", &sys.enable_kernel);
110 oprofilefs_create_ulong(sb, root, "enable_user", &sys.enable_user);
111 oprofilefs_create_ulong(sb, root, "backtrace_spinlocks",
112 &sys.backtrace_spinlocks);
113
114 /* Default to tracing both kernel and user */
115 sys.enable_kernel = 1;
116 sys.enable_user = 1;
117
118 /* Turn on backtracing through spinlocks by default */
119 sys.backtrace_spinlocks = 1;
120
121 return 0;
122}
123
124int __init oprofile_arch_init(struct oprofile_operations *ops)
125{
126 unsigned int pvr;
127
128 pvr = mfspr(SPRN_PVR);
129
130 switch (PVR_VER(pvr)) {
131 case PV_630:
132 case PV_630p:
133 model = &op_model_rs64;
134 model->num_counters = 8;
135 ops->cpu_type = "ppc64/power3";
136 break;
137
138 case PV_NORTHSTAR:
139 case PV_PULSAR:
140 case PV_ICESTAR:
141 case PV_SSTAR:
142 model = &op_model_rs64;
143 model->num_counters = 8;
144 ops->cpu_type = "ppc64/rs64";
145 break;
146
147 case PV_POWER4:
148 case PV_POWER4p:
149 model = &op_model_power4;
150 model->num_counters = 8;
151 ops->cpu_type = "ppc64/power4";
152 break;
153
154 case PV_970:
155 case PV_970FX:
156 model = &op_model_power4;
157 model->num_counters = 8;
158 ops->cpu_type = "ppc64/970";
159 break;
160
161 case PV_POWER5:
162 case PV_POWER5p:
163 model = &op_model_power4;
164 model->num_counters = 6;
165 ops->cpu_type = "ppc64/power5";
166 break;
167
168 default:
169 return -ENODEV;
170 }
171
172 ops->create_files = op_ppc64_create_files;
173 ops->setup = op_ppc64_setup;
174 ops->shutdown = op_ppc64_shutdown;
175 ops->start = op_ppc64_start;
176 ops->stop = op_ppc64_stop;
177
178 printk(KERN_INFO "oprofile: using %s performance monitoring.\n",
179 ops->cpu_type);
180
181 return 0;
182}
183
184void oprofile_arch_exit(void)
185{
186}