diff options
Diffstat (limited to 'arch/powerpc/kernel/power7-pmu.c')
-rw-r--r-- | arch/powerpc/kernel/power7-pmu.c | 61 |
1 files changed, 39 insertions, 22 deletions
diff --git a/arch/powerpc/kernel/power7-pmu.c b/arch/powerpc/kernel/power7-pmu.c index b72e7a19d054..5d755ef7ac8f 100644 --- a/arch/powerpc/kernel/power7-pmu.c +++ b/arch/powerpc/kernel/power7-pmu.c | |||
@@ -10,7 +10,9 @@ | |||
10 | */ | 10 | */ |
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/perf_counter.h> | 12 | #include <linux/perf_counter.h> |
13 | #include <linux/string.h> | ||
13 | #include <asm/reg.h> | 14 | #include <asm/reg.h> |
15 | #include <asm/cputable.h> | ||
14 | 16 | ||
15 | /* | 17 | /* |
16 | * Bits in event code for POWER7 | 18 | * Bits in event code for POWER7 |
@@ -71,10 +73,11 @@ | |||
71 | * 0-9: Count of events needing PMC1..PMC5 | 73 | * 0-9: Count of events needing PMC1..PMC5 |
72 | */ | 74 | */ |
73 | 75 | ||
74 | static int power7_get_constraint(u64 event, u64 *maskp, u64 *valp) | 76 | static int power7_get_constraint(u64 event, unsigned long *maskp, |
77 | unsigned long *valp) | ||
75 | { | 78 | { |
76 | int pmc, sh; | 79 | int pmc, sh; |
77 | u64 mask = 0, value = 0; | 80 | unsigned long mask = 0, value = 0; |
78 | 81 | ||
79 | pmc = (event >> PM_PMC_SH) & PM_PMC_MSK; | 82 | pmc = (event >> PM_PMC_SH) & PM_PMC_MSK; |
80 | if (pmc) { | 83 | if (pmc) { |
@@ -224,10 +227,10 @@ static int power7_marked_instr_event(u64 event) | |||
224 | } | 227 | } |
225 | 228 | ||
226 | static int power7_compute_mmcr(u64 event[], int n_ev, | 229 | static int power7_compute_mmcr(u64 event[], int n_ev, |
227 | unsigned int hwc[], u64 mmcr[]) | 230 | unsigned int hwc[], unsigned long mmcr[]) |
228 | { | 231 | { |
229 | u64 mmcr1 = 0; | 232 | unsigned long mmcr1 = 0; |
230 | u64 mmcra = 0; | 233 | unsigned long mmcra = 0; |
231 | unsigned int pmc, unit, combine, l2sel, psel; | 234 | unsigned int pmc, unit, combine, l2sel, psel; |
232 | unsigned int pmc_inuse = 0; | 235 | unsigned int pmc_inuse = 0; |
233 | int i; | 236 | int i; |
@@ -265,11 +268,14 @@ static int power7_compute_mmcr(u64 event[], int n_ev, | |||
265 | --pmc; | 268 | --pmc; |
266 | } | 269 | } |
267 | if (pmc <= 3) { | 270 | if (pmc <= 3) { |
268 | mmcr1 |= (u64) unit << (MMCR1_TTM0SEL_SH - 4 * pmc); | 271 | mmcr1 |= (unsigned long) unit |
269 | mmcr1 |= (u64) combine << (MMCR1_PMC1_COMBINE_SH - pmc); | 272 | << (MMCR1_TTM0SEL_SH - 4 * pmc); |
273 | mmcr1 |= (unsigned long) combine | ||
274 | << (MMCR1_PMC1_COMBINE_SH - pmc); | ||
270 | mmcr1 |= psel << MMCR1_PMCSEL_SH(pmc); | 275 | mmcr1 |= psel << MMCR1_PMCSEL_SH(pmc); |
271 | if (unit == 6) /* L2 events */ | 276 | if (unit == 6) /* L2 events */ |
272 | mmcr1 |= (u64) l2sel << MMCR1_L2SEL_SH; | 277 | mmcr1 |= (unsigned long) l2sel |
278 | << MMCR1_L2SEL_SH; | ||
273 | } | 279 | } |
274 | if (power7_marked_instr_event(event[i])) | 280 | if (power7_marked_instr_event(event[i])) |
275 | mmcra |= MMCRA_SAMPLE_ENABLE; | 281 | mmcra |= MMCRA_SAMPLE_ENABLE; |
@@ -287,10 +293,10 @@ static int power7_compute_mmcr(u64 event[], int n_ev, | |||
287 | return 0; | 293 | return 0; |
288 | } | 294 | } |
289 | 295 | ||
290 | static void power7_disable_pmc(unsigned int pmc, u64 mmcr[]) | 296 | static void power7_disable_pmc(unsigned int pmc, unsigned long mmcr[]) |
291 | { | 297 | { |
292 | if (pmc <= 3) | 298 | if (pmc <= 3) |
293 | mmcr[1] &= ~(0xffULL << MMCR1_PMCSEL_SH(pmc)); | 299 | mmcr[1] &= ~(0xffUL << MMCR1_PMCSEL_SH(pmc)); |
294 | } | 300 | } |
295 | 301 | ||
296 | static int power7_generic_events[] = { | 302 | static int power7_generic_events[] = { |
@@ -342,16 +348,27 @@ static int power7_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = { | |||
342 | }, | 348 | }, |
343 | }; | 349 | }; |
344 | 350 | ||
345 | struct power_pmu power7_pmu = { | 351 | static struct power_pmu power7_pmu = { |
346 | .n_counter = 6, | 352 | .name = "POWER7", |
347 | .max_alternatives = MAX_ALT + 1, | 353 | .n_counter = 6, |
348 | .add_fields = 0x1555ull, | 354 | .max_alternatives = MAX_ALT + 1, |
349 | .test_adder = 0x3000ull, | 355 | .add_fields = 0x1555ul, |
350 | .compute_mmcr = power7_compute_mmcr, | 356 | .test_adder = 0x3000ul, |
351 | .get_constraint = power7_get_constraint, | 357 | .compute_mmcr = power7_compute_mmcr, |
352 | .get_alternatives = power7_get_alternatives, | 358 | .get_constraint = power7_get_constraint, |
353 | .disable_pmc = power7_disable_pmc, | 359 | .get_alternatives = power7_get_alternatives, |
354 | .n_generic = ARRAY_SIZE(power7_generic_events), | 360 | .disable_pmc = power7_disable_pmc, |
355 | .generic_events = power7_generic_events, | 361 | .n_generic = ARRAY_SIZE(power7_generic_events), |
356 | .cache_events = &power7_cache_events, | 362 | .generic_events = power7_generic_events, |
363 | .cache_events = &power7_cache_events, | ||
357 | }; | 364 | }; |
365 | |||
366 | static int init_power7_pmu(void) | ||
367 | { | ||
368 | if (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power7")) | ||
369 | return -ENODEV; | ||
370 | |||
371 | return register_power_pmu(&power7_pmu); | ||
372 | } | ||
373 | |||
374 | arch_initcall(init_power7_pmu); | ||