aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2007-04-18 02:38:21 -0400
committerPaul Mackerras <paulus@samba.org>2007-04-24 07:31:51 -0400
commit25fc530eed1ca9ccde2a1e96d0b2060867f76bb2 (patch)
treee8f8705562939146413b79f50963acca5f64fab5
parent7e8bddf56661a16b7d5945390a37cd2e9c5e45fe (diff)
[POWERPC] pasemi: PA6T oprofile support
Oprofile support for PA6T, kernel side. Also rename the PA6T_SPRN.* defines to SPRN_PA6T.*. Signed-off-by: Olof Johansson <olof@lixom.net> Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r--arch/powerpc/kernel/cputable.c2
-rw-r--r--arch/powerpc/kernel/sysfs.c12
-rw-r--r--arch/powerpc/oprofile/Makefile2
-rw-r--r--arch/powerpc/oprofile/common.c3
-rw-r--r--arch/powerpc/oprofile/op_model_pa6t.c234
-rw-r--r--include/asm-powerpc/cputable.h1
-rw-r--r--include/asm-powerpc/oprofile_impl.h2
-rw-r--r--include/asm-powerpc/pmc.h1
-rw-r--r--include/asm-powerpc/reg.h68
9 files changed, 312 insertions, 13 deletions
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index ad74fecae507..9cb24d20f0f9 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -389,6 +389,8 @@ static struct cpu_spec cpu_specs[] = {
389 .pmc_type = PPC_PMC_PA6T, 389 .pmc_type = PPC_PMC_PA6T,
390 .cpu_setup = __setup_cpu_pa6t, 390 .cpu_setup = __setup_cpu_pa6t,
391 .cpu_restore = __restore_cpu_pa6t, 391 .cpu_restore = __restore_cpu_pa6t,
392 .oprofile_cpu_type = "ppc64/pa6t",
393 .oprofile_type = PPC_OPROFILE_PA6T,
392 .platform = "pa6t", 394 .platform = "pa6t",
393 }, 395 },
394 { /* default match */ 396 { /* default match */
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 476f1d546056..6fc27e771b5a 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -189,12 +189,12 @@ SYSFS_PMCSETUP(purr, SPRN_PURR);
189SYSFS_PMCSETUP(spurr, SPRN_SPURR); 189SYSFS_PMCSETUP(spurr, SPRN_SPURR);
190SYSFS_PMCSETUP(dscr, SPRN_DSCR); 190SYSFS_PMCSETUP(dscr, SPRN_DSCR);
191 191
192SYSFS_PMCSETUP(pa6t_pmc0, PA6T_SPRN_PMC0); 192SYSFS_PMCSETUP(pa6t_pmc0, SPRN_PA6T_PMC0);
193SYSFS_PMCSETUP(pa6t_pmc1, PA6T_SPRN_PMC1); 193SYSFS_PMCSETUP(pa6t_pmc1, SPRN_PA6T_PMC1);
194SYSFS_PMCSETUP(pa6t_pmc2, PA6T_SPRN_PMC2); 194SYSFS_PMCSETUP(pa6t_pmc2, SPRN_PA6T_PMC2);
195SYSFS_PMCSETUP(pa6t_pmc3, PA6T_SPRN_PMC3); 195SYSFS_PMCSETUP(pa6t_pmc3, SPRN_PA6T_PMC3);
196SYSFS_PMCSETUP(pa6t_pmc4, PA6T_SPRN_PMC4); 196SYSFS_PMCSETUP(pa6t_pmc4, SPRN_PA6T_PMC4);
197SYSFS_PMCSETUP(pa6t_pmc5, PA6T_SPRN_PMC5); 197SYSFS_PMCSETUP(pa6t_pmc5, SPRN_PA6T_PMC5);
198 198
199 199
200static SYSDEV_ATTR(mmcra, 0600, show_mmcra, store_mmcra); 200static SYSDEV_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
diff --git a/arch/powerpc/oprofile/Makefile b/arch/powerpc/oprofile/Makefile
index 4ccef2d5530c..4b5f9528218c 100644
--- a/arch/powerpc/oprofile/Makefile
+++ b/arch/powerpc/oprofile/Makefile
@@ -12,6 +12,6 @@ DRIVER_OBJS := $(addprefix ../../../drivers/oprofile/, \
12 12
13oprofile-y := $(DRIVER_OBJS) common.o backtrace.o 13oprofile-y := $(DRIVER_OBJS) common.o backtrace.o
14oprofile-$(CONFIG_PPC_CELL_NATIVE) += op_model_cell.o 14oprofile-$(CONFIG_PPC_CELL_NATIVE) += op_model_cell.o
15oprofile-$(CONFIG_PPC64) += op_model_rs64.o op_model_power4.o 15oprofile-$(CONFIG_PPC64) += op_model_rs64.o op_model_power4.o op_model_pa6t.o
16oprofile-$(CONFIG_FSL_BOOKE) += op_model_fsl_booke.o 16oprofile-$(CONFIG_FSL_BOOKE) += op_model_fsl_booke.o
17oprofile-$(CONFIG_6xx) += op_model_7450.o 17oprofile-$(CONFIG_6xx) += op_model_7450.o
diff --git a/arch/powerpc/oprofile/common.c b/arch/powerpc/oprofile/common.c
index fbd62eacfdf4..1a7ef7e246d2 100644
--- a/arch/powerpc/oprofile/common.c
+++ b/arch/powerpc/oprofile/common.c
@@ -160,6 +160,9 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
160 case PPC_OPROFILE_POWER4: 160 case PPC_OPROFILE_POWER4:
161 model = &op_model_power4; 161 model = &op_model_power4;
162 break; 162 break;
163 case PPC_OPROFILE_PA6T:
164 model = &op_model_pa6t;
165 break;
163#endif 166#endif
164#ifdef CONFIG_6xx 167#ifdef CONFIG_6xx
165 case PPC_OPROFILE_G4: 168 case PPC_OPROFILE_G4:
diff --git a/arch/powerpc/oprofile/op_model_pa6t.c b/arch/powerpc/oprofile/op_model_pa6t.c
new file mode 100644
index 000000000000..e8a56b0adadc
--- /dev/null
+++ b/arch/powerpc/oprofile/op_model_pa6t.c
@@ -0,0 +1,234 @@
1/*
2 * Copyright (C) 2006-2007 PA Semi, Inc
3 *
4 * Author: Shashi Rao, PA Semi
5 *
6 * Maintained by: Olof Johansson <olof@lixom.net>
7 *
8 * Based on arch/powerpc/oprofile/op_model_power4.c
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#include <linux/oprofile.h>
25#include <linux/init.h>
26#include <linux/smp.h>
27#include <linux/percpu.h>
28#include <asm/processor.h>
29#include <asm/cputable.h>
30#include <asm/oprofile_impl.h>
31#include <asm/reg.h>
32
33static unsigned char oprofile_running;
34
35/* mmcr values are set in pa6t_reg_setup, used in pa6t_cpu_setup */
36static u64 mmcr0_val;
37static u64 mmcr1_val;
38
39/* inited in pa6t_reg_setup */
40static u64 reset_value[OP_MAX_COUNTER];
41
42static inline u64 ctr_read(unsigned int i)
43{
44 switch (i) {
45 case 0:
46 return mfspr(SPRN_PA6T_PMC0);
47 case 1:
48 return mfspr(SPRN_PA6T_PMC1);
49 case 2:
50 return mfspr(SPRN_PA6T_PMC2);
51 case 3:
52 return mfspr(SPRN_PA6T_PMC3);
53 case 4:
54 return mfspr(SPRN_PA6T_PMC4);
55 case 5:
56 return mfspr(SPRN_PA6T_PMC5);
57 default:
58 printk(KERN_ERR "ctr_read called with bad arg %u\n", i);
59 return 0;
60 }
61}
62
63static inline void ctr_write(unsigned int i, u64 val)
64{
65 switch (i) {
66 case 0:
67 mtspr(SPRN_PA6T_PMC0, val);
68 break;
69 case 1:
70 mtspr(SPRN_PA6T_PMC1, val);
71 break;
72 case 2:
73 mtspr(SPRN_PA6T_PMC2, val);
74 break;
75 case 3:
76 mtspr(SPRN_PA6T_PMC3, val);
77 break;
78 case 4:
79 mtspr(SPRN_PA6T_PMC4, val);
80 break;
81 case 5:
82 mtspr(SPRN_PA6T_PMC5, val);
83 break;
84 default:
85 printk(KERN_ERR "ctr_write called with bad arg %u\n", i);
86 break;
87 }
88}
89
90
91/* precompute the values to stuff in the hardware registers */
92static void pa6t_reg_setup(struct op_counter_config *ctr,
93 struct op_system_config *sys,
94 int num_ctrs)
95{
96 int pmc;
97
98 /*
99 * adjust the mmcr0.en[0-5] and mmcr0.inten[0-5] values obtained from the
100 * event_mappings file by turning off the counters that the user doesn't
101 * care about
102 *
103 * setup user and kernel profiling
104 */
105 for (pmc = 0; pmc < cur_cpu_spec->num_pmcs; pmc++)
106 if (!ctr[pmc].enabled) {
107 sys->mmcr0 &= ~(0x1UL << pmc);
108 sys->mmcr0 &= ~(0x1UL << (pmc+12));
109 pr_debug("turned off counter %u\n", pmc);
110 }
111
112 if (sys->enable_kernel)
113 sys->mmcr0 |= PA6T_MMCR0_SUPEN | PA6T_MMCR0_HYPEN;
114 else
115 sys->mmcr0 &= ~(PA6T_MMCR0_SUPEN | PA6T_MMCR0_HYPEN);
116
117 if (sys->enable_user)
118 sys->mmcr0 |= PA6T_MMCR0_PREN;
119 else
120 sys->mmcr0 &= ~PA6T_MMCR0_PREN;
121
122 /*
123 * The performance counter event settings are given in the mmcr0 and
124 * mmcr1 values passed from the user in the op_system_config
125 * structure (sys variable).
126 */
127 mmcr0_val = sys->mmcr0;
128 mmcr1_val = sys->mmcr1;
129 pr_debug("mmcr0_val inited to %016lx\n", sys->mmcr0);
130 pr_debug("mmcr1_val inited to %016lx\n", sys->mmcr1);
131
132 for (pmc = 0; pmc < cur_cpu_spec->num_pmcs; pmc++) {
133 /* counters are 40 bit. Move to cputable at some point? */
134 reset_value[pmc] = (0x1UL << 39) - ctr[pmc].count;
135 pr_debug("reset_value for pmc%u inited to 0x%lx\n",
136 pmc, reset_value[pmc]);
137 }
138}
139
140/* configure registers on this cpu */
141static void pa6t_cpu_setup(struct op_counter_config *ctr)
142{
143 u64 mmcr0 = mmcr0_val;
144 u64 mmcr1 = mmcr1_val;
145
146 /* Default is all PMCs off */
147 mmcr0 &= ~(0x3FUL);
148 mtspr(SPRN_PA6T_MMCR0, mmcr0);
149
150 /* program selected programmable events in */
151 mtspr(SPRN_PA6T_MMCR1, mmcr1);
152
153 pr_debug("setup on cpu %d, mmcr0 %016lx\n", smp_processor_id(),
154 mfspr(SPRN_PA6T_MMCR0));
155 pr_debug("setup on cpu %d, mmcr1 %016lx\n", smp_processor_id(),
156 mfspr(SPRN_PA6T_MMCR1));
157}
158
159static void pa6t_start(struct op_counter_config *ctr)
160{
161 int i;
162
163 /* Hold off event counting until rfid */
164 u64 mmcr0 = mmcr0_val | PA6T_MMCR0_HANDDIS;
165
166 for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
167 if (ctr[i].enabled)
168 ctr_write(i, reset_value[i]);
169 else
170 ctr_write(i, 0UL);
171
172 mtspr(SPRN_PA6T_MMCR0, mmcr0);
173
174 oprofile_running = 1;
175
176 pr_debug("start on cpu %d, mmcr0 %lx\n", smp_processor_id(), mmcr0);
177}
178
179static void pa6t_stop(void)
180{
181 u64 mmcr0;
182
183 /* freeze counters */
184 mmcr0 = mfspr(SPRN_PA6T_MMCR0);
185 mmcr0 |= PA6T_MMCR0_FCM0;
186 mtspr(SPRN_PA6T_MMCR0, mmcr0);
187
188 oprofile_running = 0;
189
190 pr_debug("stop on cpu %d, mmcr0 %lx\n", smp_processor_id(), mmcr0);
191}
192
193/* handle the perfmon overflow vector */
194static void pa6t_handle_interrupt(struct pt_regs *regs,
195 struct op_counter_config *ctr)
196{
197 unsigned long pc = mfspr(SPRN_PA6T_SIAR);
198 int is_kernel = is_kernel_addr(pc);
199 u64 val;
200 int i;
201 u64 mmcr0;
202
203 /* disable perfmon counting until rfid */
204 mmcr0 = mfspr(SPRN_PA6T_MMCR0);
205 mtspr(SPRN_PA6T_MMCR0, mmcr0 | PA6T_MMCR0_HANDDIS);
206
207 /* Record samples. We've got one global bit for whether a sample
208 * was taken, so add it for any counter that triggered overflow.
209 */
210 for (i = 0; i < cur_cpu_spec->num_pmcs; i++) {
211 val = ctr_read(i);
212 if (val & (0x1UL << 39)) { /* Overflow bit set */
213 if (oprofile_running && ctr[i].enabled) {
214 if (mmcr0 & PA6T_MMCR0_SIARLOG)
215 oprofile_add_ext_sample(pc, regs, i, is_kernel);
216 ctr_write(i, reset_value[i]);
217 } else {
218 ctr_write(i, 0UL);
219 }
220 }
221 }
222
223 /* Restore mmcr0 to a good known value since the PMI changes it */
224 mmcr0 = mmcr0_val | PA6T_MMCR0_HANDDIS;
225 mtspr(SPRN_PA6T_MMCR0, mmcr0);
226}
227
228struct op_powerpc_model op_model_pa6t = {
229 .reg_setup = pa6t_reg_setup,
230 .cpu_setup = pa6t_cpu_setup,
231 .start = pa6t_start,
232 .stop = pa6t_stop,
233 .handle_interrupt = pa6t_handle_interrupt,
234};
diff --git a/include/asm-powerpc/cputable.h b/include/asm-powerpc/cputable.h
index 4f7c25518641..434524931ef3 100644
--- a/include/asm-powerpc/cputable.h
+++ b/include/asm-powerpc/cputable.h
@@ -48,6 +48,7 @@ enum powerpc_oprofile_type {
48 PPC_OPROFILE_G4 = 3, 48 PPC_OPROFILE_G4 = 3,
49 PPC_OPROFILE_BOOKE = 4, 49 PPC_OPROFILE_BOOKE = 4,
50 PPC_OPROFILE_CELL = 5, 50 PPC_OPROFILE_CELL = 5,
51 PPC_OPROFILE_PA6T = 6,
51}; 52};
52 53
53enum powerpc_pmc_type { 54enum powerpc_pmc_type {
diff --git a/include/asm-powerpc/oprofile_impl.h b/include/asm-powerpc/oprofile_impl.h
index 94c0ad2bff96..8d6b47f7b300 100644
--- a/include/asm-powerpc/oprofile_impl.h
+++ b/include/asm-powerpc/oprofile_impl.h
@@ -57,6 +57,8 @@ extern struct op_powerpc_model op_model_rs64;
57extern struct op_powerpc_model op_model_power4; 57extern struct op_powerpc_model op_model_power4;
58extern struct op_powerpc_model op_model_7450; 58extern struct op_powerpc_model op_model_7450;
59extern struct op_powerpc_model op_model_cell; 59extern struct op_powerpc_model op_model_cell;
60extern struct op_powerpc_model op_model_pa6t;
61
60 62
61/* All the classic PPC parts use these */ 63/* All the classic PPC parts use these */
62static inline unsigned int classic_ctr_read(unsigned int i) 64static inline unsigned int classic_ctr_read(unsigned int i)
diff --git a/include/asm-powerpc/pmc.h b/include/asm-powerpc/pmc.h
index 8588be68e0ad..d6a616a1b3ea 100644
--- a/include/asm-powerpc/pmc.h
+++ b/include/asm-powerpc/pmc.h
@@ -30,6 +30,7 @@ void release_pmc_hardware(void);
30 30
31#ifdef CONFIG_PPC64 31#ifdef CONFIG_PPC64
32void power4_enable_pmcs(void); 32void power4_enable_pmcs(void);
33void pasemi_enable_pmcs(void);
33#endif 34#endif
34 35
35#endif /* __KERNEL__ */ 36#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/reg.h b/include/asm-powerpc/reg.h
index 0d7f0164ed81..749c7f953b58 100644
--- a/include/asm-powerpc/reg.h
+++ b/include/asm-powerpc/reg.h
@@ -469,12 +469,68 @@
469#define SPRN_SIAR 780 469#define SPRN_SIAR 780
470#define SPRN_SDAR 781 470#define SPRN_SDAR 781
471 471
472#define PA6T_SPRN_PMC0 787 472#define SPRN_PA6T_MMCR0 795
473#define PA6T_SPRN_PMC1 788 473#define PA6T_MMCR0_EN0 0x0000000000000001UL
474#define PA6T_SPRN_PMC2 789 474#define PA6T_MMCR0_EN1 0x0000000000000002UL
475#define PA6T_SPRN_PMC3 790 475#define PA6T_MMCR0_EN2 0x0000000000000004UL
476#define PA6T_SPRN_PMC4 791 476#define PA6T_MMCR0_EN3 0x0000000000000008UL
477#define PA6T_SPRN_PMC5 792 477#define PA6T_MMCR0_EN4 0x0000000000000010UL
478#define PA6T_MMCR0_EN5 0x0000000000000020UL
479#define PA6T_MMCR0_SUPEN 0x0000000000000040UL
480#define PA6T_MMCR0_PREN 0x0000000000000080UL
481#define PA6T_MMCR0_HYPEN 0x0000000000000100UL
482#define PA6T_MMCR0_FCM0 0x0000000000000200UL
483#define PA6T_MMCR0_FCM1 0x0000000000000400UL
484#define PA6T_MMCR0_INTGEN 0x0000000000000800UL
485#define PA6T_MMCR0_INTEN0 0x0000000000001000UL
486#define PA6T_MMCR0_INTEN1 0x0000000000002000UL
487#define PA6T_MMCR0_INTEN2 0x0000000000004000UL
488#define PA6T_MMCR0_INTEN3 0x0000000000008000UL
489#define PA6T_MMCR0_INTEN4 0x0000000000010000UL
490#define PA6T_MMCR0_INTEN5 0x0000000000020000UL
491#define PA6T_MMCR0_DISCNT 0x0000000000040000UL
492#define PA6T_MMCR0_UOP 0x0000000000080000UL
493#define PA6T_MMCR0_TRG 0x0000000000100000UL
494#define PA6T_MMCR0_TRGEN 0x0000000000200000UL
495#define PA6T_MMCR0_TRGREG 0x0000000001600000UL
496#define PA6T_MMCR0_SIARLOG 0x0000000002000000UL
497#define PA6T_MMCR0_SDARLOG 0x0000000004000000UL
498#define PA6T_MMCR0_PROEN 0x0000000008000000UL
499#define PA6T_MMCR0_PROLOG 0x0000000010000000UL
500#define PA6T_MMCR0_DAMEN2 0x0000000020000000UL
501#define PA6T_MMCR0_DAMEN3 0x0000000040000000UL
502#define PA6T_MMCR0_DAMEN4 0x0000000080000000UL
503#define PA6T_MMCR0_DAMEN5 0x0000000100000000UL
504#define PA6T_MMCR0_DAMSEL2 0x0000000200000000UL
505#define PA6T_MMCR0_DAMSEL3 0x0000000400000000UL
506#define PA6T_MMCR0_DAMSEL4 0x0000000800000000UL
507#define PA6T_MMCR0_DAMSEL5 0x0000001000000000UL
508#define PA6T_MMCR0_HANDDIS 0x0000002000000000UL
509#define PA6T_MMCR0_PCTEN 0x0000004000000000UL
510#define PA6T_MMCR0_SOCEN 0x0000008000000000UL
511#define PA6T_MMCR0_SOCMOD 0x0000010000000000UL
512
513#define SPRN_PA6T_MMCR1 798
514#define PA6T_MMCR1_ES2 0x00000000000000ffUL
515#define PA6T_MMCR1_ES3 0x000000000000ff00UL
516#define PA6T_MMCR1_ES4 0x0000000000ff0000UL
517#define PA6T_MMCR1_ES5 0x00000000ff000000UL
518
519#define SPRN_PA6T_SIAR 780
520#define SPRN_PA6T_UPMC0 771
521#define SPRN_PA6T_UPMC1 772
522#define SPRN_PA6T_UPMC2 773
523#define SPRN_PA6T_UPMC3 774
524#define SPRN_PA6T_UPMC4 775
525#define SPRN_PA6T_UPMC5 776
526#define SPRN_PA6T_UMMCR0 779
527#define SPRN_PA6T_UMMCR1 782
528#define SPRN_PA6T_PMC0 787
529#define SPRN_PA6T_PMC1 788
530#define SPRN_PA6T_PMC2 789
531#define SPRN_PA6T_PMC3 790
532#define SPRN_PA6T_PMC4 791
533#define SPRN_PA6T_PMC5 792
478 534
479#else /* 32-bit */ 535#else /* 32-bit */
480#define SPRN_MMCR0 952 /* Monitor Mode Control Register 0 */ 536#define SPRN_MMCR0 952 /* Monitor Mode Control Register 0 */