aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/ppc970-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/ppc970-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/ppc970-pmu.c')
-rw-r--r--arch/powerpc/kernel/ppc970-pmu.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/arch/powerpc/kernel/ppc970-pmu.c b/arch/powerpc/kernel/ppc970-pmu.c
index ba0a357a89f4..3ed88333412f 100644
--- a/arch/powerpc/kernel/ppc970-pmu.c
+++ b/arch/powerpc/kernel/ppc970-pmu.c
@@ -183,7 +183,7 @@ static int p970_marked_instr_event(u64 event)
183} 183}
184 184
185/* Masks and values for using events from the various units */ 185/* Masks and values for using events from the various units */
186static u64 unit_cons[PM_LASTUNIT+1][2] = { 186static unsigned long unit_cons[PM_LASTUNIT+1][2] = {
187 [PM_FPU] = { 0xc80000000000ull, 0x040000000000ull }, 187 [PM_FPU] = { 0xc80000000000ull, 0x040000000000ull },
188 [PM_VPU] = { 0xc80000000000ull, 0xc40000000000ull }, 188 [PM_VPU] = { 0xc80000000000ull, 0xc40000000000ull },
189 [PM_ISU] = { 0x080000000000ull, 0x020000000000ull }, 189 [PM_ISU] = { 0x080000000000ull, 0x020000000000ull },
@@ -192,10 +192,11 @@ static u64 unit_cons[PM_LASTUNIT+1][2] = {
192 [PM_STS] = { 0x380000000000ull, 0x310000000000ull }, 192 [PM_STS] = { 0x380000000000ull, 0x310000000000ull },
193}; 193};
194 194
195static int p970_get_constraint(u64 event, u64 *maskp, u64 *valp) 195static int p970_get_constraint(u64 event, unsigned long *maskp,
196 unsigned long *valp)
196{ 197{
197 int pmc, byte, unit, sh, spcsel; 198 int pmc, byte, unit, sh, spcsel;
198 u64 mask = 0, value = 0; 199 unsigned long mask = 0, value = 0;
199 int grp = -1; 200 int grp = -1;
200 201
201 pmc = (event >> PM_PMC_SH) & PM_PMC_MSK; 202 pmc = (event >> PM_PMC_SH) & PM_PMC_MSK;
@@ -222,7 +223,7 @@ static int p970_get_constraint(u64 event, u64 *maskp, u64 *valp)
222 grp = byte & 1; 223 grp = byte & 1;
223 /* Set byte lane select field */ 224 /* Set byte lane select field */
224 mask |= 0xfULL << (28 - 4 * byte); 225 mask |= 0xfULL << (28 - 4 * byte);
225 value |= (u64)unit << (28 - 4 * byte); 226 value |= (unsigned long)unit << (28 - 4 * byte);
226 } 227 }
227 if (grp == 0) { 228 if (grp == 0) {
228 /* increment PMC1/2/5/6 field */ 229 /* increment PMC1/2/5/6 field */
@@ -236,7 +237,7 @@ static int p970_get_constraint(u64 event, u64 *maskp, u64 *valp)
236 spcsel = (event >> PM_SPCSEL_SH) & PM_SPCSEL_MSK; 237 spcsel = (event >> PM_SPCSEL_SH) & PM_SPCSEL_MSK;
237 if (spcsel) { 238 if (spcsel) {
238 mask |= 3ull << 48; 239 mask |= 3ull << 48;
239 value |= (u64)spcsel << 48; 240 value |= (unsigned long)spcsel << 48;
240 } 241 }
241 *maskp = mask; 242 *maskp = mask;
242 *valp = value; 243 *valp = value;
@@ -257,9 +258,9 @@ static int p970_get_alternatives(u64 event, unsigned int flags, u64 alt[])
257} 258}
258 259
259static int p970_compute_mmcr(u64 event[], int n_ev, 260static int p970_compute_mmcr(u64 event[], int n_ev,
260 unsigned int hwc[], u64 mmcr[]) 261 unsigned int hwc[], unsigned long mmcr[])
261{ 262{
262 u64 mmcr0 = 0, mmcr1 = 0, mmcra = 0; 263 unsigned long mmcr0 = 0, mmcr1 = 0, mmcra = 0;
263 unsigned int pmc, unit, byte, psel; 264 unsigned int pmc, unit, byte, psel;
264 unsigned int ttm, grp; 265 unsigned int ttm, grp;
265 unsigned int pmc_inuse = 0; 266 unsigned int pmc_inuse = 0;
@@ -320,7 +321,7 @@ static int p970_compute_mmcr(u64 event[], int n_ev,
320 continue; 321 continue;
321 ttm = unitmap[i]; 322 ttm = unitmap[i];
322 ++ttmuse[(ttm >> 2) & 1]; 323 ++ttmuse[(ttm >> 2) & 1];
323 mmcr1 |= (u64)(ttm & ~4) << MMCR1_TTM1SEL_SH; 324 mmcr1 |= (unsigned long)(ttm & ~4) << MMCR1_TTM1SEL_SH;
324 } 325 }
325 /* Check only one unit per TTMx */ 326 /* Check only one unit per TTMx */
326 if (ttmuse[0] > 1 || ttmuse[1] > 1) 327 if (ttmuse[0] > 1 || ttmuse[1] > 1)
@@ -340,7 +341,8 @@ static int p970_compute_mmcr(u64 event[], int n_ev,
340 if (unit == PM_LSU1L && byte >= 2) 341 if (unit == PM_LSU1L && byte >= 2)
341 mmcr1 |= 1ull << (MMCR1_TTM3SEL_SH + 3 - byte); 342 mmcr1 |= 1ull << (MMCR1_TTM3SEL_SH + 3 - byte);
342 } 343 }
343 mmcr1 |= (u64)ttm << (MMCR1_TD_CP_DBG0SEL_SH - 2 * byte); 344 mmcr1 |= (unsigned long)ttm
345 << (MMCR1_TD_CP_DBG0SEL_SH - 2 * byte);
344 } 346 }
345 347
346 /* Second pass: assign PMCs, set PMCxSEL and PMCx_ADDER_SEL fields */ 348 /* Second pass: assign PMCs, set PMCxSEL and PMCx_ADDER_SEL fields */
@@ -386,7 +388,8 @@ static int p970_compute_mmcr(u64 event[], int n_ev,
386 for (pmc = 0; pmc < 2; ++pmc) 388 for (pmc = 0; pmc < 2; ++pmc)
387 mmcr0 |= pmcsel[pmc] << (MMCR0_PMC1SEL_SH - 7 * pmc); 389 mmcr0 |= pmcsel[pmc] << (MMCR0_PMC1SEL_SH - 7 * pmc);
388 for (; pmc < 8; ++pmc) 390 for (; pmc < 8; ++pmc)
389 mmcr1 |= (u64)pmcsel[pmc] << (MMCR1_PMC3SEL_SH - 5 * (pmc - 2)); 391 mmcr1 |= (unsigned long)pmcsel[pmc]
392 << (MMCR1_PMC3SEL_SH - 5 * (pmc - 2));
390 if (pmc_inuse & 1) 393 if (pmc_inuse & 1)
391 mmcr0 |= MMCR0_PMC1CE; 394 mmcr0 |= MMCR0_PMC1CE;
392 if (pmc_inuse & 0xfe) 395 if (pmc_inuse & 0xfe)
@@ -401,7 +404,7 @@ static int p970_compute_mmcr(u64 event[], int n_ev,
401 return 0; 404 return 0;
402} 405}
403 406
404static void p970_disable_pmc(unsigned int pmc, u64 mmcr[]) 407static void p970_disable_pmc(unsigned int pmc, unsigned long mmcr[])
405{ 408{
406 int shift, i; 409 int shift, i;
407 410
@@ -468,15 +471,15 @@ static int ppc970_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
468}; 471};
469 472
470struct power_pmu ppc970_pmu = { 473struct power_pmu ppc970_pmu = {
471 .n_counter = 8, 474 .n_counter = 8,
472 .max_alternatives = 2, 475 .max_alternatives = 2,
473 .add_fields = 0x001100005555ull, 476 .add_fields = 0x001100005555ull,
474 .test_adder = 0x013300000000ull, 477 .test_adder = 0x013300000000ull,
475 .compute_mmcr = p970_compute_mmcr, 478 .compute_mmcr = p970_compute_mmcr,
476 .get_constraint = p970_get_constraint, 479 .get_constraint = p970_get_constraint,
477 .get_alternatives = p970_get_alternatives, 480 .get_alternatives = p970_get_alternatives,
478 .disable_pmc = p970_disable_pmc, 481 .disable_pmc = p970_disable_pmc,
479 .n_generic = ARRAY_SIZE(ppc970_generic_events), 482 .n_generic = ARRAY_SIZE(ppc970_generic_events),
480 .generic_events = ppc970_generic_events, 483 .generic_events = ppc970_generic_events,
481 .cache_events = &ppc970_cache_events, 484 .cache_events = &ppc970_cache_events,
482}; 485};