diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2005-09-19 09:24:08 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-09-21 05:21:08 -0400 |
commit | 86a5cddbd9676b129cfa2ed7a1a11759d3b2b512 (patch) | |
tree | 7d5d4fdda4df9067c43870f5dcb3d5c714fdf227 /arch/ppc/oprofile | |
parent | 654810ec899ea5f2fc2138fca1793b603d481ff4 (diff) |
[PATCH] powerpc: merge the rest of arch/ppc*/oprofile
- merge common.c
- move model specific files
- remove stub Makefiles
- clean up arch/ppc*/Makefile
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/ppc/oprofile')
-rw-r--r-- | arch/ppc/oprofile/Makefile | 1 | ||||
-rw-r--r-- | arch/ppc/oprofile/common.c | 160 | ||||
-rw-r--r-- | arch/ppc/oprofile/op_model_fsl_booke.c | 183 |
3 files changed, 0 insertions, 344 deletions
diff --git a/arch/ppc/oprofile/Makefile b/arch/ppc/oprofile/Makefile deleted file mode 100644 index 4bf75b776c5b..000000000000 --- a/arch/ppc/oprofile/Makefile +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | include arch/powerpc/oprofile/Makefile | ||
diff --git a/arch/ppc/oprofile/common.c b/arch/ppc/oprofile/common.c deleted file mode 100644 index f63bee23f20c..000000000000 --- a/arch/ppc/oprofile/common.c +++ /dev/null | |||
@@ -1,160 +0,0 @@ | |||
1 | /* | ||
2 | * PPC 32 oprofile support | ||
3 | * Based on PPC64 oprofile support | ||
4 | * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM | ||
5 | * | ||
6 | * Copyright (C) Freescale Semiconductor, Inc 2004 | ||
7 | * | ||
8 | * Author: Andy Fleming | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * as published by the Free Software Foundation; either version | ||
13 | * 2 of the License, or (at your option) any later version. | ||
14 | */ | ||
15 | |||
16 | #include <linux/oprofile.h> | ||
17 | #include <linux/slab.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/smp.h> | ||
20 | #include <linux/errno.h> | ||
21 | #include <asm/ptrace.h> | ||
22 | #include <asm/system.h> | ||
23 | #include <asm/perfmon.h> | ||
24 | #include <asm/cputable.h> | ||
25 | #include <asm/oprofile_impl.h> | ||
26 | |||
27 | static struct op_powerpc_model *model; | ||
28 | |||
29 | static struct op_counter_config ctr[OP_MAX_COUNTER]; | ||
30 | static struct op_system_config sys; | ||
31 | |||
32 | static void op_handle_interrupt(struct pt_regs *regs) | ||
33 | { | ||
34 | model->handle_interrupt(regs, ctr); | ||
35 | } | ||
36 | |||
37 | static int op_ppc32_setup(void) | ||
38 | { | ||
39 | /* Install our interrupt handler into the existing hook. */ | ||
40 | if(request_perfmon_irq(&op_handle_interrupt)) | ||
41 | return -EBUSY; | ||
42 | |||
43 | mb(); | ||
44 | |||
45 | /* Pre-compute the values to stuff in the hardware registers. */ | ||
46 | model->reg_setup(ctr, &sys, model->num_counters); | ||
47 | |||
48 | #if 0 | ||
49 | /* FIXME: Make multi-cpu work */ | ||
50 | /* Configure the registers on all cpus. */ | ||
51 | on_each_cpu(model->reg_setup, NULL, 0, 1); | ||
52 | #endif | ||
53 | |||
54 | return 0; | ||
55 | } | ||
56 | |||
57 | static void op_ppc32_shutdown(void) | ||
58 | { | ||
59 | mb(); | ||
60 | |||
61 | /* Remove our interrupt handler. We may be removing this module. */ | ||
62 | free_perfmon_irq(); | ||
63 | } | ||
64 | |||
65 | static void op_ppc32_cpu_start(void *dummy) | ||
66 | { | ||
67 | model->start(ctr); | ||
68 | } | ||
69 | |||
70 | static int op_ppc32_start(void) | ||
71 | { | ||
72 | on_each_cpu(op_ppc32_cpu_start, NULL, 0, 1); | ||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | static inline void op_ppc32_cpu_stop(void *dummy) | ||
77 | { | ||
78 | model->stop(); | ||
79 | } | ||
80 | |||
81 | static void op_ppc32_stop(void) | ||
82 | { | ||
83 | on_each_cpu(op_ppc32_cpu_stop, NULL, 0, 1); | ||
84 | } | ||
85 | |||
86 | static int op_ppc32_create_files(struct super_block *sb, struct dentry *root) | ||
87 | { | ||
88 | int i; | ||
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 | oprofilefs_create_ulong(sb, dir, "kernel", &ctr[i].kernel); | ||
101 | oprofilefs_create_ulong(sb, dir, "user", &ctr[i].user); | ||
102 | |||
103 | /* FIXME: Not sure if this is used */ | ||
104 | oprofilefs_create_ulong(sb, dir, "unit_mask", &ctr[i].unit_mask); | ||
105 | } | ||
106 | |||
107 | oprofilefs_create_ulong(sb, root, "enable_kernel", &sys.enable_kernel); | ||
108 | oprofilefs_create_ulong(sb, root, "enable_user", &sys.enable_user); | ||
109 | |||
110 | /* Default to tracing both kernel and user */ | ||
111 | sys.enable_kernel = 1; | ||
112 | sys.enable_user = 1; | ||
113 | |||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | static struct oprofile_operations oprof_ppc32_ops = { | ||
118 | .create_files = op_ppc32_create_files, | ||
119 | .setup = op_ppc32_setup, | ||
120 | .shutdown = op_ppc32_shutdown, | ||
121 | .start = op_ppc32_start, | ||
122 | .stop = op_ppc32_stop, | ||
123 | .cpu_type = NULL /* To be filled in below. */ | ||
124 | }; | ||
125 | |||
126 | int __init oprofile_arch_init(struct oprofile_operations *ops) | ||
127 | { | ||
128 | char *name; | ||
129 | int cpu_id = smp_processor_id(); | ||
130 | |||
131 | #ifdef CONFIG_FSL_BOOKE | ||
132 | model = &op_model_fsl_booke; | ||
133 | #else | ||
134 | return -ENODEV; | ||
135 | #endif | ||
136 | |||
137 | name = kmalloc(32, GFP_KERNEL); | ||
138 | |||
139 | if (NULL == name) | ||
140 | return -ENOMEM; | ||
141 | |||
142 | sprintf(name, "ppc/%s", cur_cpu_spec[cpu_id]->cpu_name); | ||
143 | |||
144 | oprof_ppc32_ops.cpu_type = name; | ||
145 | |||
146 | model->num_counters = cur_cpu_spec[cpu_id]->num_pmcs; | ||
147 | |||
148 | *ops = oprof_ppc32_ops; | ||
149 | |||
150 | printk(KERN_INFO "oprofile: using %s performance monitoring.\n", | ||
151 | oprof_ppc32_ops.cpu_type); | ||
152 | |||
153 | return 0; | ||
154 | } | ||
155 | |||
156 | void oprofile_arch_exit(void) | ||
157 | { | ||
158 | kfree(oprof_ppc32_ops.cpu_type); | ||
159 | oprof_ppc32_ops.cpu_type = NULL; | ||
160 | } | ||
diff --git a/arch/ppc/oprofile/op_model_fsl_booke.c b/arch/ppc/oprofile/op_model_fsl_booke.c deleted file mode 100644 index 1917f8df8a8b..000000000000 --- a/arch/ppc/oprofile/op_model_fsl_booke.c +++ /dev/null | |||
@@ -1,183 +0,0 @@ | |||
1 | /* | ||
2 | * oprofile/op_model_e500.c | ||
3 | * | ||
4 | * Freescale Book-E oprofile support, based on ppc64 oprofile support | ||
5 | * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM | ||
6 | * | ||
7 | * Copyright (c) 2004 Freescale Semiconductor, Inc | ||
8 | * | ||
9 | * Author: Andy Fleming | ||
10 | * Maintainer: Kumar Gala <Kumar.Gala@freescale.com> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version | ||
15 | * 2 of the License, or (at your option) any later version. | ||
16 | */ | ||
17 | |||
18 | #include <linux/oprofile.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/smp.h> | ||
21 | #include <asm/ptrace.h> | ||
22 | #include <asm/system.h> | ||
23 | #include <asm/processor.h> | ||
24 | #include <asm/cputable.h> | ||
25 | #include <asm/reg_booke.h> | ||
26 | #include <asm/page.h> | ||
27 | #include <asm/perfmon.h> | ||
28 | #include <asm/oprofile_impl.h> | ||
29 | |||
30 | static unsigned long reset_value[OP_MAX_COUNTER]; | ||
31 | |||
32 | static int num_counters; | ||
33 | static int oprofile_running; | ||
34 | |||
35 | static inline unsigned int ctr_read(unsigned int i) | ||
36 | { | ||
37 | switch(i) { | ||
38 | case 0: | ||
39 | return mfpmr(PMRN_PMC0); | ||
40 | case 1: | ||
41 | return mfpmr(PMRN_PMC1); | ||
42 | case 2: | ||
43 | return mfpmr(PMRN_PMC2); | ||
44 | case 3: | ||
45 | return mfpmr(PMRN_PMC3); | ||
46 | default: | ||
47 | return 0; | ||
48 | } | ||
49 | } | ||
50 | |||
51 | static inline void ctr_write(unsigned int i, unsigned int val) | ||
52 | { | ||
53 | switch(i) { | ||
54 | case 0: | ||
55 | mtpmr(PMRN_PMC0, val); | ||
56 | break; | ||
57 | case 1: | ||
58 | mtpmr(PMRN_PMC1, val); | ||
59 | break; | ||
60 | case 2: | ||
61 | mtpmr(PMRN_PMC2, val); | ||
62 | break; | ||
63 | case 3: | ||
64 | mtpmr(PMRN_PMC3, val); | ||
65 | break; | ||
66 | default: | ||
67 | break; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | |||
72 | static void fsl_booke_reg_setup(struct op_counter_config *ctr, | ||
73 | struct op_system_config *sys, | ||
74 | int num_ctrs) | ||
75 | { | ||
76 | int i; | ||
77 | |||
78 | num_counters = num_ctrs; | ||
79 | |||
80 | /* freeze all counters */ | ||
81 | pmc_stop_ctrs(); | ||
82 | |||
83 | /* Our counters count up, and "count" refers to | ||
84 | * how much before the next interrupt, and we interrupt | ||
85 | * on overflow. So we calculate the starting value | ||
86 | * which will give us "count" until overflow. | ||
87 | * Then we set the events on the enabled counters */ | ||
88 | for (i = 0; i < num_counters; ++i) { | ||
89 | reset_value[i] = 0x80000000UL - ctr[i].count; | ||
90 | |||
91 | init_pmc_stop(i); | ||
92 | |||
93 | set_pmc_event(i, ctr[i].event); | ||
94 | |||
95 | set_pmc_user_kernel(i, ctr[i].user, ctr[i].kernel); | ||
96 | } | ||
97 | } | ||
98 | |||
99 | static void fsl_booke_start(struct op_counter_config *ctr) | ||
100 | { | ||
101 | int i; | ||
102 | |||
103 | mtmsr(mfmsr() | MSR_PMM); | ||
104 | |||
105 | for (i = 0; i < num_counters; ++i) { | ||
106 | if (ctr[i].enabled) { | ||
107 | ctr_write(i, reset_value[i]); | ||
108 | /* Set Each enabled counterd to only | ||
109 | * count when the Mark bit is not set */ | ||
110 | set_pmc_marked(i, 1, 0); | ||
111 | pmc_start_ctr(i, 1); | ||
112 | } else { | ||
113 | ctr_write(i, 0); | ||
114 | |||
115 | /* Set the ctr to be stopped */ | ||
116 | pmc_start_ctr(i, 0); | ||
117 | } | ||
118 | } | ||
119 | |||
120 | /* Clear the freeze bit, and enable the interrupt. | ||
121 | * The counters won't actually start until the rfi clears | ||
122 | * the PMM bit */ | ||
123 | pmc_start_ctrs(1); | ||
124 | |||
125 | oprofile_running = 1; | ||
126 | |||
127 | pr_debug("start on cpu %d, pmgc0 %x\n", smp_processor_id(), | ||
128 | mfpmr(PMRN_PMGC0)); | ||
129 | } | ||
130 | |||
131 | static void fsl_booke_stop(void) | ||
132 | { | ||
133 | /* freeze counters */ | ||
134 | pmc_stop_ctrs(); | ||
135 | |||
136 | oprofile_running = 0; | ||
137 | |||
138 | pr_debug("stop on cpu %d, pmgc0 %x\n", smp_processor_id(), | ||
139 | mfpmr(PMRN_PMGC0)); | ||
140 | |||
141 | mb(); | ||
142 | } | ||
143 | |||
144 | |||
145 | static void fsl_booke_handle_interrupt(struct pt_regs *regs, | ||
146 | struct op_counter_config *ctr) | ||
147 | { | ||
148 | unsigned long pc; | ||
149 | int is_kernel; | ||
150 | int val; | ||
151 | int i; | ||
152 | |||
153 | /* set the PMM bit (see comment below) */ | ||
154 | mtmsr(mfmsr() | MSR_PMM); | ||
155 | |||
156 | pc = regs->nip; | ||
157 | is_kernel = (pc >= KERNELBASE); | ||
158 | |||
159 | for (i = 0; i < num_counters; ++i) { | ||
160 | val = ctr_read(i); | ||
161 | if (val < 0) { | ||
162 | if (oprofile_running && ctr[i].enabled) { | ||
163 | oprofile_add_pc(pc, is_kernel, i); | ||
164 | ctr_write(i, reset_value[i]); | ||
165 | } else { | ||
166 | ctr_write(i, 0); | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | |||
171 | /* The freeze bit was set by the interrupt. */ | ||
172 | /* Clear the freeze bit, and reenable the interrupt. | ||
173 | * The counters won't actually start until the rfi clears | ||
174 | * the PMM bit */ | ||
175 | pmc_start_ctrs(1); | ||
176 | } | ||
177 | |||
178 | struct op_powerpc_model op_model_fsl_booke = { | ||
179 | .reg_setup = fsl_booke_reg_setup, | ||
180 | .start = fsl_booke_start, | ||
181 | .stop = fsl_booke_stop, | ||
182 | .handle_interrupt = fsl_booke_handle_interrupt, | ||
183 | }; | ||