aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/power4-pmu.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2009-06-17 07:51:13 -0400
committerIngo Molnar <mingo@elte.hu>2009-06-18 05:11:45 -0400
commit448d64f8f4c147db466c549550767cc515a4d34c (patch)
tree9c33191273219d8e4d77e3ea78304691e4fb4b56 /arch/powerpc/kernel/power4-pmu.c
parent105988c015943e77092a6568bc5fb7e386df6ccd (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/power4-pmu.c')
-rw-r--r--arch/powerpc/kernel/power4-pmu.c74
1 files changed, 39 insertions, 35 deletions
diff --git a/arch/powerpc/kernel/power4-pmu.c b/arch/powerpc/kernel/power4-pmu.c
index 07bd308a5fa7..81a1708f83b2 100644
--- a/arch/powerpc/kernel/power4-pmu.c
+++ b/arch/powerpc/kernel/power4-pmu.c
@@ -179,22 +179,22 @@ static short mmcr1_adder_bits[8] = {
179 */ 179 */
180 180
181static struct unitinfo { 181static struct unitinfo {
182 u64 value, mask; 182 unsigned long value, mask;
183 int unit; 183 int unit;
184 int lowerbit; 184 int lowerbit;
185} p4_unitinfo[16] = { 185} p4_unitinfo[16] = {
186 [PM_FPU] = { 0x44000000000000ull, 0x88000000000000ull, PM_FPU, 0 }, 186 [PM_FPU] = { 0x44000000000000ul, 0x88000000000000ul, PM_FPU, 0 },
187 [PM_ISU1] = { 0x20080000000000ull, 0x88000000000000ull, PM_ISU1, 0 }, 187 [PM_ISU1] = { 0x20080000000000ul, 0x88000000000000ul, PM_ISU1, 0 },
188 [PM_ISU1_ALT] = 188 [PM_ISU1_ALT] =
189 { 0x20080000000000ull, 0x88000000000000ull, PM_ISU1, 0 }, 189 { 0x20080000000000ul, 0x88000000000000ul, PM_ISU1, 0 },
190 [PM_IFU] = { 0x02200000000000ull, 0x08820000000000ull, PM_IFU, 41 }, 190 [PM_IFU] = { 0x02200000000000ul, 0x08820000000000ul, PM_IFU, 41 },
191 [PM_IFU_ALT] = 191 [PM_IFU_ALT] =
192 { 0x02200000000000ull, 0x08820000000000ull, PM_IFU, 41 }, 192 { 0x02200000000000ul, 0x08820000000000ul, PM_IFU, 41 },
193 [PM_IDU0] = { 0x10100000000000ull, 0x80840000000000ull, PM_IDU0, 1 }, 193 [PM_IDU0] = { 0x10100000000000ul, 0x80840000000000ul, PM_IDU0, 1 },
194 [PM_ISU2] = { 0x10140000000000ull, 0x80840000000000ull, PM_ISU2, 0 }, 194 [PM_ISU2] = { 0x10140000000000ul, 0x80840000000000ul, PM_ISU2, 0 },
195 [PM_LSU0] = { 0x01400000000000ull, 0x08800000000000ull, PM_LSU0, 0 }, 195 [PM_LSU0] = { 0x01400000000000ul, 0x08800000000000ul, PM_LSU0, 0 },
196 [PM_LSU1] = { 0x00000000000000ull, 0x00010000000000ull, PM_LSU1, 40 }, 196 [PM_LSU1] = { 0x00000000000000ul, 0x00010000000000ul, PM_LSU1, 40 },
197 [PM_GPS] = { 0x00000000000000ull, 0x00000000000000ull, PM_GPS, 0 } 197 [PM_GPS] = { 0x00000000000000ul, 0x00000000000000ul, PM_GPS, 0 }
198}; 198};
199 199
200static unsigned char direct_marked_event[8] = { 200static unsigned char direct_marked_event[8] = {
@@ -249,10 +249,11 @@ static int p4_marked_instr_event(u64 event)
249 return (mask >> (byte * 8 + bit)) & 1; 249 return (mask >> (byte * 8 + bit)) & 1;
250} 250}
251 251
252static int p4_get_constraint(u64 event, u64 *maskp, u64 *valp) 252static int p4_get_constraint(u64 event, unsigned long *maskp,
253 unsigned long *valp)
253{ 254{
254 int pmc, byte, unit, lower, sh; 255 int pmc, byte, unit, lower, sh;
255 u64 mask = 0, value = 0; 256 unsigned long mask = 0, value = 0;
256 int grp = -1; 257 int grp = -1;
257 258
258 pmc = (event >> PM_PMC_SH) & PM_PMC_MSK; 259 pmc = (event >> PM_PMC_SH) & PM_PMC_MSK;
@@ -282,14 +283,14 @@ static int p4_get_constraint(u64 event, u64 *maskp, u64 *valp)
282 value |= p4_unitinfo[unit].value; 283 value |= p4_unitinfo[unit].value;
283 sh = p4_unitinfo[unit].lowerbit; 284 sh = p4_unitinfo[unit].lowerbit;
284 if (sh > 1) 285 if (sh > 1)
285 value |= (u64)lower << sh; 286 value |= (unsigned long)lower << sh;
286 else if (lower != sh) 287 else if (lower != sh)
287 return -1; 288 return -1;
288 unit = p4_unitinfo[unit].unit; 289 unit = p4_unitinfo[unit].unit;
289 290
290 /* Set byte lane select field */ 291 /* Set byte lane select field */
291 mask |= 0xfULL << (28 - 4 * byte); 292 mask |= 0xfULL << (28 - 4 * byte);
292 value |= (u64)unit << (28 - 4 * byte); 293 value |= (unsigned long)unit << (28 - 4 * byte);
293 } 294 }
294 if (grp == 0) { 295 if (grp == 0) {
295 /* increment PMC1/2/5/6 field */ 296 /* increment PMC1/2/5/6 field */
@@ -353,9 +354,9 @@ static int p4_get_alternatives(u64 event, unsigned int flags, u64 alt[])
353} 354}
354 355
355static int p4_compute_mmcr(u64 event[], int n_ev, 356static int p4_compute_mmcr(u64 event[], int n_ev,
356 unsigned int hwc[], u64 mmcr[]) 357 unsigned int hwc[], unsigned long mmcr[])
357{ 358{
358 u64 mmcr0 = 0, mmcr1 = 0, mmcra = 0; 359 unsigned long mmcr0 = 0, mmcr1 = 0, mmcra = 0;
359 unsigned int pmc, unit, byte, psel, lower; 360 unsigned int pmc, unit, byte, psel, lower;
360 unsigned int ttm, grp; 361 unsigned int ttm, grp;
361 unsigned int pmc_inuse = 0; 362 unsigned int pmc_inuse = 0;
@@ -429,9 +430,11 @@ static int p4_compute_mmcr(u64 event[], int n_ev,
429 return -1; 430 return -1;
430 431
431 /* Set TTMxSEL fields. Note, units 1-3 => TTM0SEL codes 0-2 */ 432 /* Set TTMxSEL fields. Note, units 1-3 => TTM0SEL codes 0-2 */
432 mmcr1 |= (u64)(unituse[3] * 2 + unituse[2]) << MMCR1_TTM0SEL_SH; 433 mmcr1 |= (unsigned long)(unituse[3] * 2 + unituse[2])
433 mmcr1 |= (u64)(unituse[7] * 3 + unituse[6] * 2) << MMCR1_TTM1SEL_SH; 434 << MMCR1_TTM0SEL_SH;
434 mmcr1 |= (u64)unituse[9] << MMCR1_TTM2SEL_SH; 435 mmcr1 |= (unsigned long)(unituse[7] * 3 + unituse[6] * 2)
436 << MMCR1_TTM1SEL_SH;
437 mmcr1 |= (unsigned long)unituse[9] << MMCR1_TTM2SEL_SH;
435 438
436 /* Set TTCxSEL fields. */ 439 /* Set TTCxSEL fields. */
437 if (unitlower & 0xe) 440 if (unitlower & 0xe)
@@ -456,7 +459,8 @@ static int p4_compute_mmcr(u64 event[], int n_ev,
456 ttm = unit - 1; /* 2->1, 3->2 */ 459 ttm = unit - 1; /* 2->1, 3->2 */
457 else 460 else
458 ttm = unit >> 2; 461 ttm = unit >> 2;
459 mmcr1 |= (u64)ttm << (MMCR1_TD_CP_DBG0SEL_SH - 2*byte); 462 mmcr1 |= (unsigned long)ttm
463 << (MMCR1_TD_CP_DBG0SEL_SH - 2 * byte);
460 } 464 }
461 } 465 }
462 466
@@ -519,7 +523,7 @@ static int p4_compute_mmcr(u64 event[], int n_ev,
519 return 0; 523 return 0;
520} 524}
521 525
522static void p4_disable_pmc(unsigned int pmc, u64 mmcr[]) 526static void p4_disable_pmc(unsigned int pmc, unsigned long mmcr[])
523{ 527{
524 /* 528 /*
525 * Setting the PMCxSEL field to 0 disables PMC x. 529 * Setting the PMCxSEL field to 0 disables PMC x.
@@ -584,15 +588,15 @@ static int power4_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
584}; 588};
585 589
586struct power_pmu power4_pmu = { 590struct power_pmu power4_pmu = {
587 .n_counter = 8, 591 .n_counter = 8,
588 .max_alternatives = 5, 592 .max_alternatives = 5,
589 .add_fields = 0x0000001100005555ull, 593 .add_fields = 0x0000001100005555ul,
590 .test_adder = 0x0011083300000000ull, 594 .test_adder = 0x0011083300000000ul,
591 .compute_mmcr = p4_compute_mmcr, 595 .compute_mmcr = p4_compute_mmcr,
592 .get_constraint = p4_get_constraint, 596 .get_constraint = p4_get_constraint,
593 .get_alternatives = p4_get_alternatives, 597 .get_alternatives = p4_get_alternatives,
594 .disable_pmc = p4_disable_pmc, 598 .disable_pmc = p4_disable_pmc,
595 .n_generic = ARRAY_SIZE(p4_generic_events), 599 .n_generic = ARRAY_SIZE(p4_generic_events),
596 .generic_events = p4_generic_events, 600 .generic_events = p4_generic_events,
597 .cache_events = &power4_cache_events, 601 .cache_events = &power4_cache_events,
598}; 602};