diff options
author | Paul Mackerras <paulus@samba.org> | 2009-06-17 07:51:13 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-06-18 05:11:45 -0400 |
commit | 448d64f8f4c147db466c549550767cc515a4d34c (patch) | |
tree | 9c33191273219d8e4d77e3ea78304691e4fb4b56 /arch/powerpc/kernel/power5-pmu.c | |
parent | 105988c015943e77092a6568bc5fb7e386df6ccd (diff) |
perf_counter: powerpc: Use unsigned long for register and constraint values
This changes the powerpc perf_counter back-end to use unsigned long
types for hardware register values and for the value/mask pairs used
in checking whether a given set of events fit within the hardware
constraints. This is in preparation for adding support for the PMU
on some 32-bit powerpc processors. On 32-bit processors the hardware
registers are only 32 bits wide, and the PMU structure is generally
simpler, so 32 bits should be ample for expressing the hardware
constraints. On 64-bit processors, unsigned long is 64 bits wide,
so using unsigned long vs. u64 (unsigned long long) makes no actual
difference.
This makes some other very minor changes: adjusting whitespace to line
things up in initialized structures, and simplifying some code in
hw_perf_disable().
Signed-off-by: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: linuxppc-dev@ozlabs.org
Cc: benh@kernel.crashing.org
LKML-Reference: <19000.55473.26174.331511@cargo.ozlabs.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/powerpc/kernel/power5-pmu.c')
-rw-r--r-- | arch/powerpc/kernel/power5-pmu.c | 83 |
1 files changed, 43 insertions, 40 deletions
diff --git a/arch/powerpc/kernel/power5-pmu.c b/arch/powerpc/kernel/power5-pmu.c index 05600b66221a..8694c73bfb52 100644 --- a/arch/powerpc/kernel/power5-pmu.c +++ b/arch/powerpc/kernel/power5-pmu.c | |||
@@ -130,20 +130,21 @@ static const int grsel_shift[8] = { | |||
130 | }; | 130 | }; |
131 | 131 | ||
132 | /* Masks and values for using events from the various units */ | 132 | /* Masks and values for using events from the various units */ |
133 | static u64 unit_cons[PM_LASTUNIT+1][2] = { | 133 | static unsigned long unit_cons[PM_LASTUNIT+1][2] = { |
134 | [PM_FPU] = { 0xc0002000000000ull, 0x00001000000000ull }, | 134 | [PM_FPU] = { 0xc0002000000000ul, 0x00001000000000ul }, |
135 | [PM_ISU0] = { 0x00002000000000ull, 0x00000800000000ull }, | 135 | [PM_ISU0] = { 0x00002000000000ul, 0x00000800000000ul }, |
136 | [PM_ISU1] = { 0xc0002000000000ull, 0xc0001000000000ull }, | 136 | [PM_ISU1] = { 0xc0002000000000ul, 0xc0001000000000ul }, |
137 | [PM_IFU] = { 0xc0002000000000ull, 0x80001000000000ull }, | 137 | [PM_IFU] = { 0xc0002000000000ul, 0x80001000000000ul }, |
138 | [PM_IDU] = { 0x30002000000000ull, 0x00000400000000ull }, | 138 | [PM_IDU] = { 0x30002000000000ul, 0x00000400000000ul }, |
139 | [PM_GRS] = { 0x30002000000000ull, 0x30000400000000ull }, | 139 | [PM_GRS] = { 0x30002000000000ul, 0x30000400000000ul }, |
140 | }; | 140 | }; |
141 | 141 | ||
142 | static int power5_get_constraint(u64 event, u64 *maskp, u64 *valp) | 142 | static int power5_get_constraint(u64 event, unsigned long *maskp, |
143 | unsigned long *valp) | ||
143 | { | 144 | { |
144 | int pmc, byte, unit, sh; | 145 | int pmc, byte, unit, sh; |
145 | int bit, fmask; | 146 | int bit, fmask; |
146 | u64 mask = 0, value = 0; | 147 | unsigned long mask = 0, value = 0; |
147 | int grp = -1; | 148 | int grp = -1; |
148 | 149 | ||
149 | pmc = (event >> PM_PMC_SH) & PM_PMC_MSK; | 150 | pmc = (event >> PM_PMC_SH) & PM_PMC_MSK; |
@@ -178,8 +179,9 @@ static int power5_get_constraint(u64 event, u64 *maskp, u64 *valp) | |||
178 | bit = event & 7; | 179 | bit = event & 7; |
179 | fmask = (bit == 6)? 7: 3; | 180 | fmask = (bit == 6)? 7: 3; |
180 | sh = grsel_shift[bit]; | 181 | sh = grsel_shift[bit]; |
181 | mask |= (u64)fmask << sh; | 182 | mask |= (unsigned long)fmask << sh; |
182 | value |= (u64)((event >> PM_GRS_SH) & fmask) << sh; | 183 | value |= (unsigned long)((event >> PM_GRS_SH) & fmask) |
184 | << sh; | ||
183 | } | 185 | } |
184 | /* | 186 | /* |
185 | * Bus events on bytes 0 and 2 can be counted | 187 | * Bus events on bytes 0 and 2 can be counted |
@@ -188,22 +190,22 @@ static int power5_get_constraint(u64 event, u64 *maskp, u64 *valp) | |||
188 | if (!pmc) | 190 | if (!pmc) |
189 | grp = byte & 1; | 191 | grp = byte & 1; |
190 | /* Set byte lane select field */ | 192 | /* Set byte lane select field */ |
191 | mask |= 0xfULL << (24 - 4 * byte); | 193 | mask |= 0xfUL << (24 - 4 * byte); |
192 | value |= (u64)unit << (24 - 4 * byte); | 194 | value |= (unsigned long)unit << (24 - 4 * byte); |
193 | } | 195 | } |
194 | if (grp == 0) { | 196 | if (grp == 0) { |
195 | /* increment PMC1/2 field */ | 197 | /* increment PMC1/2 field */ |
196 | mask |= 0x200000000ull; | 198 | mask |= 0x200000000ul; |
197 | value |= 0x080000000ull; | 199 | value |= 0x080000000ul; |
198 | } else if (grp == 1) { | 200 | } else if (grp == 1) { |
199 | /* increment PMC3/4 field */ | 201 | /* increment PMC3/4 field */ |
200 | mask |= 0x40000000ull; | 202 | mask |= 0x40000000ul; |
201 | value |= 0x10000000ull; | 203 | value |= 0x10000000ul; |
202 | } | 204 | } |
203 | if (pmc < 5) { | 205 | if (pmc < 5) { |
204 | /* need a counter from PMC1-4 set */ | 206 | /* need a counter from PMC1-4 set */ |
205 | mask |= 0x8000000000000ull; | 207 | mask |= 0x8000000000000ul; |
206 | value |= 0x1000000000000ull; | 208 | value |= 0x1000000000000ul; |
207 | } | 209 | } |
208 | *maskp = mask; | 210 | *maskp = mask; |
209 | *valp = value; | 211 | *valp = value; |
@@ -383,10 +385,10 @@ static int power5_marked_instr_event(u64 event) | |||
383 | } | 385 | } |
384 | 386 | ||
385 | static int power5_compute_mmcr(u64 event[], int n_ev, | 387 | static int power5_compute_mmcr(u64 event[], int n_ev, |
386 | unsigned int hwc[], u64 mmcr[]) | 388 | unsigned int hwc[], unsigned long mmcr[]) |
387 | { | 389 | { |
388 | u64 mmcr1 = 0; | 390 | unsigned long mmcr1 = 0; |
389 | u64 mmcra = 0; | 391 | unsigned long mmcra = 0; |
390 | unsigned int pmc, unit, byte, psel; | 392 | unsigned int pmc, unit, byte, psel; |
391 | unsigned int ttm, grp; | 393 | unsigned int ttm, grp; |
392 | int i, isbus, bit, grsel; | 394 | int i, isbus, bit, grsel; |
@@ -457,7 +459,7 @@ static int power5_compute_mmcr(u64 event[], int n_ev, | |||
457 | continue; | 459 | continue; |
458 | if (ttmuse++) | 460 | if (ttmuse++) |
459 | return -1; | 461 | return -1; |
460 | mmcr1 |= (u64)i << MMCR1_TTM0SEL_SH; | 462 | mmcr1 |= (unsigned long)i << MMCR1_TTM0SEL_SH; |
461 | } | 463 | } |
462 | ttmuse = 0; | 464 | ttmuse = 0; |
463 | for (; i <= PM_GRS; ++i) { | 465 | for (; i <= PM_GRS; ++i) { |
@@ -465,7 +467,7 @@ static int power5_compute_mmcr(u64 event[], int n_ev, | |||
465 | continue; | 467 | continue; |
466 | if (ttmuse++) | 468 | if (ttmuse++) |
467 | return -1; | 469 | return -1; |
468 | mmcr1 |= (u64)(i & 3) << MMCR1_TTM1SEL_SH; | 470 | mmcr1 |= (unsigned long)(i & 3) << MMCR1_TTM1SEL_SH; |
469 | } | 471 | } |
470 | if (ttmuse > 1) | 472 | if (ttmuse > 1) |
471 | return -1; | 473 | return -1; |
@@ -480,10 +482,11 @@ static int power5_compute_mmcr(u64 event[], int n_ev, | |||
480 | unit = PM_ISU0_ALT; | 482 | unit = PM_ISU0_ALT; |
481 | } else if (unit == PM_LSU1 + 1) { | 483 | } else if (unit == PM_LSU1 + 1) { |
482 | /* select lower word of LSU1 for this byte */ | 484 | /* select lower word of LSU1 for this byte */ |
483 | mmcr1 |= 1ull << (MMCR1_TTM3SEL_SH + 3 - byte); | 485 | mmcr1 |= 1ul << (MMCR1_TTM3SEL_SH + 3 - byte); |
484 | } | 486 | } |
485 | ttm = unit >> 2; | 487 | ttm = unit >> 2; |
486 | mmcr1 |= (u64)ttm << (MMCR1_TD_CP_DBG0SEL_SH - 2 * byte); | 488 | mmcr1 |= (unsigned long)ttm |
489 | << (MMCR1_TD_CP_DBG0SEL_SH - 2 * byte); | ||
487 | } | 490 | } |
488 | 491 | ||
489 | /* Second pass: assign PMCs, set PMCxSEL and PMCx_ADDER_SEL fields */ | 492 | /* Second pass: assign PMCs, set PMCxSEL and PMCx_ADDER_SEL fields */ |
@@ -513,7 +516,7 @@ static int power5_compute_mmcr(u64 event[], int n_ev, | |||
513 | --pmc; | 516 | --pmc; |
514 | if ((psel == 8 || psel == 0x10) && isbus && (byte & 2)) | 517 | if ((psel == 8 || psel == 0x10) && isbus && (byte & 2)) |
515 | /* add events on higher-numbered bus */ | 518 | /* add events on higher-numbered bus */ |
516 | mmcr1 |= 1ull << (MMCR1_PMC1_ADDER_SEL_SH - pmc); | 519 | mmcr1 |= 1ul << (MMCR1_PMC1_ADDER_SEL_SH - pmc); |
517 | } else { | 520 | } else { |
518 | /* Instructions or run cycles on PMC5/6 */ | 521 | /* Instructions or run cycles on PMC5/6 */ |
519 | --pmc; | 522 | --pmc; |
@@ -521,7 +524,7 @@ static int power5_compute_mmcr(u64 event[], int n_ev, | |||
521 | if (isbus && unit == PM_GRS) { | 524 | if (isbus && unit == PM_GRS) { |
522 | bit = psel & 7; | 525 | bit = psel & 7; |
523 | grsel = (event[i] >> PM_GRS_SH) & PM_GRS_MSK; | 526 | grsel = (event[i] >> PM_GRS_SH) & PM_GRS_MSK; |
524 | mmcr1 |= (u64)grsel << grsel_shift[bit]; | 527 | mmcr1 |= (unsigned long)grsel << grsel_shift[bit]; |
525 | } | 528 | } |
526 | if (power5_marked_instr_event(event[i])) | 529 | if (power5_marked_instr_event(event[i])) |
527 | mmcra |= MMCRA_SAMPLE_ENABLE; | 530 | mmcra |= MMCRA_SAMPLE_ENABLE; |
@@ -541,7 +544,7 @@ static int power5_compute_mmcr(u64 event[], int n_ev, | |||
541 | return 0; | 544 | return 0; |
542 | } | 545 | } |
543 | 546 | ||
544 | static void power5_disable_pmc(unsigned int pmc, u64 mmcr[]) | 547 | static void power5_disable_pmc(unsigned int pmc, unsigned long mmcr[]) |
545 | { | 548 | { |
546 | if (pmc <= 3) | 549 | if (pmc <= 3) |
547 | mmcr[1] &= ~(0x7fUL << MMCR1_PMCSEL_SH(pmc)); | 550 | mmcr[1] &= ~(0x7fUL << MMCR1_PMCSEL_SH(pmc)); |
@@ -597,15 +600,15 @@ static int power5_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = { | |||
597 | }; | 600 | }; |
598 | 601 | ||
599 | struct power_pmu power5_pmu = { | 602 | struct power_pmu power5_pmu = { |
600 | .n_counter = 6, | 603 | .n_counter = 6, |
601 | .max_alternatives = MAX_ALT, | 604 | .max_alternatives = MAX_ALT, |
602 | .add_fields = 0x7000090000555ull, | 605 | .add_fields = 0x7000090000555ul, |
603 | .test_adder = 0x3000490000000ull, | 606 | .test_adder = 0x3000490000000ul, |
604 | .compute_mmcr = power5_compute_mmcr, | 607 | .compute_mmcr = power5_compute_mmcr, |
605 | .get_constraint = power5_get_constraint, | 608 | .get_constraint = power5_get_constraint, |
606 | .get_alternatives = power5_get_alternatives, | 609 | .get_alternatives = power5_get_alternatives, |
607 | .disable_pmc = power5_disable_pmc, | 610 | .disable_pmc = power5_disable_pmc, |
608 | .n_generic = ARRAY_SIZE(power5_generic_events), | 611 | .n_generic = ARRAY_SIZE(power5_generic_events), |
609 | .generic_events = power5_generic_events, | 612 | .generic_events = power5_generic_events, |
610 | .cache_events = &power5_cache_events, | 613 | .cache_events = &power5_cache_events, |
611 | }; | 614 | }; |