aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/oprofile/common.c (renamed from arch/ppc64/oprofile/common.c)101
-rw-r--r--arch/powerpc/oprofile/op_model_fsl_booke.c (renamed from arch/ppc/oprofile/op_model_fsl_booke.c)0
-rw-r--r--arch/powerpc/oprofile/op_model_power4.c (renamed from arch/ppc64/oprofile/op_model_power4.c)0
-rw-r--r--arch/powerpc/oprofile/op_model_rs64.c (renamed from arch/ppc64/oprofile/op_model_rs64.c)0
-rw-r--r--arch/ppc/Makefile2
-rw-r--r--arch/ppc/oprofile/Makefile1
-rw-r--r--arch/ppc/oprofile/common.c160
-rw-r--r--arch/ppc64/Makefile2
-rw-r--r--arch/ppc64/oprofile/Makefile1
9 files changed, 87 insertions, 180 deletions
diff --git a/arch/ppc64/oprofile/common.c b/arch/powerpc/oprofile/common.c
index ff9361a07d39..486314a0defd 100644
--- a/arch/ppc64/oprofile/common.c
+++ b/arch/powerpc/oprofile/common.c
@@ -1,5 +1,9 @@
1/* 1/*
2 * PPC 64 oprofile support:
2 * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM 3 * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM
4 * PPC 32 oprofile support: (based on PPC 64 support)
5 * Copyright (C) Freescale Semiconductor, Inc 2004
6 * Author: Andy Fleming
3 * 7 *
4 * Based on alpha version. 8 * Based on alpha version.
5 * 9 *
@@ -10,12 +14,19 @@
10 */ 14 */
11 15
12#include <linux/oprofile.h> 16#include <linux/oprofile.h>
17#ifndef __powerpc64__
18#include <linux/slab.h>
19#endif /* ! __powerpc64__ */
13#include <linux/init.h> 20#include <linux/init.h>
14#include <linux/smp.h> 21#include <linux/smp.h>
15#include <linux/errno.h> 22#include <linux/errno.h>
16#include <asm/ptrace.h> 23#include <asm/ptrace.h>
17#include <asm/system.h> 24#include <asm/system.h>
25#ifdef __powerpc64__
18#include <asm/pmc.h> 26#include <asm/pmc.h>
27#else /* __powerpc64__ */
28#include <asm/perfmon.h>
29#endif /* __powerpc64__ */
19#include <asm/cputable.h> 30#include <asm/cputable.h>
20#include <asm/oprofile_impl.h> 31#include <asm/oprofile_impl.h>
21 32
@@ -24,59 +35,84 @@ static struct op_powerpc_model *model;
24static struct op_counter_config ctr[OP_MAX_COUNTER]; 35static struct op_counter_config ctr[OP_MAX_COUNTER];
25static struct op_system_config sys; 36static struct op_system_config sys;
26 37
38#ifndef __powerpc64__
39static char *cpu_type;
40#endif /* ! __powerpc64__ */
41
27static void op_handle_interrupt(struct pt_regs *regs) 42static void op_handle_interrupt(struct pt_regs *regs)
28{ 43{
29 model->handle_interrupt(regs, ctr); 44 model->handle_interrupt(regs, ctr);
30} 45}
31 46
32static int op_ppc64_setup(void) 47static int op_powerpc_setup(void)
33{ 48{
49#ifdef __powerpc64__
34 int err; 50 int err;
35 51
36 /* Grab the hardware */ 52 /* Grab the hardware */
37 err = reserve_pmc_hardware(op_handle_interrupt); 53 err = reserve_pmc_hardware(op_handle_interrupt);
38 if (err) 54 if (err)
39 return err; 55 return err;
56#else /* __powerpc64__ */
57 /* Install our interrupt handler into the existing hook. */
58 if (request_perfmon_irq(&op_handle_interrupt))
59 return -EBUSY;
60 mb();
61#endif /* __powerpc64__ */
40 62
41 /* Pre-compute the values to stuff in the hardware registers. */ 63 /* Pre-compute the values to stuff in the hardware registers. */
42 model->reg_setup(ctr, &sys, model->num_counters); 64 model->reg_setup(ctr, &sys, model->num_counters);
43 65
44 /* Configure the registers on all cpus. */ 66 /* Configure the registers on all cpus. */
67#ifdef __powerpc64__
45 on_each_cpu(model->cpu_setup, NULL, 0, 1); 68 on_each_cpu(model->cpu_setup, NULL, 0, 1);
69#else /* __powerpc64__ */
70#if 0
71 /* FIXME: Make multi-cpu work */
72 on_each_cpu(model->reg_setup, NULL, 0, 1);
73#endif
74#endif /* __powerpc64__ */
46 75
47 return 0; 76 return 0;
48} 77}
49 78
50static void op_ppc64_shutdown(void) 79static void op_powerpc_shutdown(void)
51{ 80{
81#ifdef __powerpc64__
52 release_pmc_hardware(); 82 release_pmc_hardware();
83#else /* __powerpc64__ */
84 mb();
85 /* Remove our interrupt handler. We may be removing this module. */
86 free_perfmon_irq();
87#endif /* __powerpc64__ */
53} 88}
54 89
55static void op_ppc64_cpu_start(void *dummy) 90static void op_powerpc_cpu_start(void *dummy)
56{ 91{
57 model->start(ctr); 92 model->start(ctr);
58} 93}
59 94
60static int op_ppc64_start(void) 95static int op_powerpc_start(void)
61{ 96{
62 on_each_cpu(op_ppc64_cpu_start, NULL, 0, 1); 97 on_each_cpu(op_powerpc_cpu_start, NULL, 0, 1);
63 return 0; 98 return 0;
64} 99}
65 100
66static inline void op_ppc64_cpu_stop(void *dummy) 101static inline void op_powerpc_cpu_stop(void *dummy)
67{ 102{
68 model->stop(); 103 model->stop();
69} 104}
70 105
71static void op_ppc64_stop(void) 106static void op_powerpc_stop(void)
72{ 107{
73 on_each_cpu(op_ppc64_cpu_stop, NULL, 0, 1); 108 on_each_cpu(op_powerpc_cpu_stop, NULL, 0, 1);
74} 109}
75 110
76static int op_ppc64_create_files(struct super_block *sb, struct dentry *root) 111static int op_powerpc_create_files(struct super_block *sb, struct dentry *root)
77{ 112{
78 int i; 113 int i;
79 114
115#ifdef __powerpc64__
80 /* 116 /*
81 * There is one mmcr0, mmcr1 and mmcra for setting the events for 117 * There is one mmcr0, mmcr1 and mmcra for setting the events for
82 * all of the counters. 118 * all of the counters.
@@ -84,6 +120,7 @@ static int op_ppc64_create_files(struct super_block *sb, struct dentry *root)
84 oprofilefs_create_ulong(sb, root, "mmcr0", &sys.mmcr0); 120 oprofilefs_create_ulong(sb, root, "mmcr0", &sys.mmcr0);
85 oprofilefs_create_ulong(sb, root, "mmcr1", &sys.mmcr1); 121 oprofilefs_create_ulong(sb, root, "mmcr1", &sys.mmcr1);
86 oprofilefs_create_ulong(sb, root, "mmcra", &sys.mmcra); 122 oprofilefs_create_ulong(sb, root, "mmcra", &sys.mmcra);
123#endif /* __powerpc64__ */
87 124
88 for (i = 0; i < model->num_counters; ++i) { 125 for (i = 0; i < model->num_counters; ++i) {
89 struct dentry *dir; 126 struct dentry *dir;
@@ -95,44 +132,72 @@ static int op_ppc64_create_files(struct super_block *sb, struct dentry *root)
95 oprofilefs_create_ulong(sb, dir, "enabled", &ctr[i].enabled); 132 oprofilefs_create_ulong(sb, dir, "enabled", &ctr[i].enabled);
96 oprofilefs_create_ulong(sb, dir, "event", &ctr[i].event); 133 oprofilefs_create_ulong(sb, dir, "event", &ctr[i].event);
97 oprofilefs_create_ulong(sb, dir, "count", &ctr[i].count); 134 oprofilefs_create_ulong(sb, dir, "count", &ctr[i].count);
135#ifdef __powerpc64__
98 /* 136 /*
99 * We dont support per counter user/kernel selection, but 137 * We dont support per counter user/kernel selection, but
100 * we leave the entries because userspace expects them 138 * we leave the entries because userspace expects them
101 */ 139 */
140#endif /* __powerpc64__ */
102 oprofilefs_create_ulong(sb, dir, "kernel", &ctr[i].kernel); 141 oprofilefs_create_ulong(sb, dir, "kernel", &ctr[i].kernel);
103 oprofilefs_create_ulong(sb, dir, "user", &ctr[i].user); 142 oprofilefs_create_ulong(sb, dir, "user", &ctr[i].user);
143
144#ifndef __powerpc64__
145 /* FIXME: Not sure if this is used */
146#endif /* ! __powerpc64__ */
104 oprofilefs_create_ulong(sb, dir, "unit_mask", &ctr[i].unit_mask); 147 oprofilefs_create_ulong(sb, dir, "unit_mask", &ctr[i].unit_mask);
105 } 148 }
106 149
107 oprofilefs_create_ulong(sb, root, "enable_kernel", &sys.enable_kernel); 150 oprofilefs_create_ulong(sb, root, "enable_kernel", &sys.enable_kernel);
108 oprofilefs_create_ulong(sb, root, "enable_user", &sys.enable_user); 151 oprofilefs_create_ulong(sb, root, "enable_user", &sys.enable_user);
152#ifdef __powerpc64__
109 oprofilefs_create_ulong(sb, root, "backtrace_spinlocks", 153 oprofilefs_create_ulong(sb, root, "backtrace_spinlocks",
110 &sys.backtrace_spinlocks); 154 &sys.backtrace_spinlocks);
155#endif /* __powerpc64__ */
111 156
112 /* Default to tracing both kernel and user */ 157 /* Default to tracing both kernel and user */
113 sys.enable_kernel = 1; 158 sys.enable_kernel = 1;
114 sys.enable_user = 1; 159 sys.enable_user = 1;
115 160#ifdef __powerpc64__
116 /* Turn on backtracing through spinlocks by default */ 161 /* Turn on backtracing through spinlocks by default */
117 sys.backtrace_spinlocks = 1; 162 sys.backtrace_spinlocks = 1;
163#endif /* __powerpc64__ */
118 164
119 return 0; 165 return 0;
120} 166}
121 167
122int __init oprofile_arch_init(struct oprofile_operations *ops) 168int __init oprofile_arch_init(struct oprofile_operations *ops)
123{ 169{
170#ifndef __powerpc64__
171 int cpu_id = smp_processor_id();
172
173#ifdef CONFIG_FSL_BOOKE
174 model = &op_model_fsl_booke;
175#else
176 return -ENODEV;
177#endif
178
179 cpu_type = kmalloc(32, GFP_KERNEL);
180 if (NULL == cpu_type)
181 return -ENOMEM;
182
183 sprintf(cpu_type, "ppc/%s", cur_cpu_spec[cpu_id]->cpu_name);
184
185 model->num_counters = cur_cpu_spec[cpu_id]->num_pmcs;
186
187 ops->cpu_type = cpu_type;
188#else /* __powerpc64__ */
124 if (!cur_cpu_spec->oprofile_model || !cur_cpu_spec->oprofile_cpu_type) 189 if (!cur_cpu_spec->oprofile_model || !cur_cpu_spec->oprofile_cpu_type)
125 return -ENODEV; 190 return -ENODEV;
126
127 model = cur_cpu_spec->oprofile_model; 191 model = cur_cpu_spec->oprofile_model;
128 model->num_counters = cur_cpu_spec->num_pmcs; 192 model->num_counters = cur_cpu_spec->num_pmcs;
129 193
130 ops->cpu_type = cur_cpu_spec->oprofile_cpu_type; 194 ops->cpu_type = cur_cpu_spec->oprofile_cpu_type;
131 ops->create_files = op_ppc64_create_files; 195#endif /* __powerpc64__ */
132 ops->setup = op_ppc64_setup; 196 ops->create_files = op_powerpc_create_files;
133 ops->shutdown = op_ppc64_shutdown; 197 ops->setup = op_powerpc_setup;
134 ops->start = op_ppc64_start; 198 ops->shutdown = op_powerpc_shutdown;
135 ops->stop = op_ppc64_stop; 199 ops->start = op_powerpc_start;
200 ops->stop = op_powerpc_stop;
136 201
137 printk(KERN_INFO "oprofile: using %s performance monitoring.\n", 202 printk(KERN_INFO "oprofile: using %s performance monitoring.\n",
138 ops->cpu_type); 203 ops->cpu_type);
@@ -142,4 +207,8 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
142 207
143void oprofile_arch_exit(void) 208void oprofile_arch_exit(void)
144{ 209{
210#ifndef __powerpc64__
211 kfree(cpu_type);
212 cpu_type = NULL;
213#endif /* ! __powerpc64__ */
145} 214}
diff --git a/arch/ppc/oprofile/op_model_fsl_booke.c b/arch/powerpc/oprofile/op_model_fsl_booke.c
index 1917f8df8a8b..1917f8df8a8b 100644
--- a/arch/ppc/oprofile/op_model_fsl_booke.c
+++ b/arch/powerpc/oprofile/op_model_fsl_booke.c
diff --git a/arch/ppc64/oprofile/op_model_power4.c b/arch/powerpc/oprofile/op_model_power4.c
index 886449315847..886449315847 100644
--- a/arch/ppc64/oprofile/op_model_power4.c
+++ b/arch/powerpc/oprofile/op_model_power4.c
diff --git a/arch/ppc64/oprofile/op_model_rs64.c b/arch/powerpc/oprofile/op_model_rs64.c
index e010b85996e8..e010b85996e8 100644
--- a/arch/ppc64/oprofile/op_model_rs64.c
+++ b/arch/powerpc/oprofile/op_model_rs64.c
diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index 16e2675f3270..90c750227ed9 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -71,7 +71,7 @@ drivers-$(CONFIG_8xx) += arch/ppc/8xx_io/
71drivers-$(CONFIG_4xx) += arch/ppc/4xx_io/ 71drivers-$(CONFIG_4xx) += arch/ppc/4xx_io/
72drivers-$(CONFIG_CPM2) += arch/ppc/8260_io/ 72drivers-$(CONFIG_CPM2) += arch/ppc/8260_io/
73 73
74drivers-$(CONFIG_OPROFILE) += arch/ppc/oprofile/ 74drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/
75 75
76BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm 76BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm
77 77
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 @@
1include 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
27static struct op_powerpc_model *model;
28
29static struct op_counter_config ctr[OP_MAX_COUNTER];
30static struct op_system_config sys;
31
32static void op_handle_interrupt(struct pt_regs *regs)
33{
34 model->handle_interrupt(regs, ctr);
35}
36
37static 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
57static 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
65static void op_ppc32_cpu_start(void *dummy)
66{
67 model->start(ctr);
68}
69
70static int op_ppc32_start(void)
71{
72 on_each_cpu(op_ppc32_cpu_start, NULL, 0, 1);
73 return 0;
74}
75
76static inline void op_ppc32_cpu_stop(void *dummy)
77{
78 model->stop();
79}
80
81static void op_ppc32_stop(void)
82{
83 on_each_cpu(op_ppc32_cpu_stop, NULL, 0, 1);
84}
85
86static 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
117static 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
126int __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
156void oprofile_arch_exit(void)
157{
158 kfree(oprof_ppc32_ops.cpu_type);
159 oprof_ppc32_ops.cpu_type = NULL;
160}
diff --git a/arch/ppc64/Makefile b/arch/ppc64/Makefile
index 17d2c1eac3b8..a8877881bb48 100644
--- a/arch/ppc64/Makefile
+++ b/arch/ppc64/Makefile
@@ -85,7 +85,7 @@ libs-y += arch/ppc64/lib/
85core-y += arch/ppc64/kernel/ 85core-y += arch/ppc64/kernel/
86core-y += arch/ppc64/mm/ 86core-y += arch/ppc64/mm/
87core-$(CONFIG_XMON) += arch/ppc64/xmon/ 87core-$(CONFIG_XMON) += arch/ppc64/xmon/
88drivers-$(CONFIG_OPROFILE) += arch/ppc64/oprofile/ 88drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/
89 89
90boot := arch/ppc64/boot 90boot := arch/ppc64/boot
91 91
diff --git a/arch/ppc64/oprofile/Makefile b/arch/ppc64/oprofile/Makefile
deleted file mode 100644
index 4bf75b776c5b..000000000000
--- a/arch/ppc64/oprofile/Makefile
+++ /dev/null
@@ -1 +0,0 @@
1include arch/powerpc/oprofile/Makefile