aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/power6-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/power6-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/power6-pmu.c')
-rw-r--r--arch/powerpc/kernel/power6-pmu.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/arch/powerpc/kernel/power6-pmu.c b/arch/powerpc/kernel/power6-pmu.c
index 46f74bebcfd9..8898622ac28c 100644
--- a/arch/powerpc/kernel/power6-pmu.c
+++ b/arch/powerpc/kernel/power6-pmu.c
@@ -41,9 +41,9 @@
41#define MMCR1_NESTSEL_SH 45 41#define MMCR1_NESTSEL_SH 45
42#define MMCR1_NESTSEL_MSK 0x7 42#define MMCR1_NESTSEL_MSK 0x7
43#define MMCR1_NESTSEL(m) (((m) >> MMCR1_NESTSEL_SH) & MMCR1_NESTSEL_MSK) 43#define MMCR1_NESTSEL(m) (((m) >> MMCR1_NESTSEL_SH) & MMCR1_NESTSEL_MSK)
44#define MMCR1_PMC1_LLA ((u64)1 << 44) 44#define MMCR1_PMC1_LLA (1ul << 44)
45#define MMCR1_PMC1_LLA_VALUE ((u64)1 << 39) 45#define MMCR1_PMC1_LLA_VALUE (1ul << 39)
46#define MMCR1_PMC1_ADDR_SEL ((u64)1 << 35) 46#define MMCR1_PMC1_ADDR_SEL (1ul << 35)
47#define MMCR1_PMC1SEL_SH 24 47#define MMCR1_PMC1SEL_SH 24
48#define MMCR1_PMCSEL_SH(n) (MMCR1_PMC1SEL_SH - (n) * 8) 48#define MMCR1_PMCSEL_SH(n) (MMCR1_PMC1SEL_SH - (n) * 8)
49#define MMCR1_PMCSEL_MSK 0xff 49#define MMCR1_PMCSEL_MSK 0xff
@@ -173,10 +173,10 @@ static int power6_marked_instr_event(u64 event)
173 * Assign PMC numbers and compute MMCR1 value for a set of events 173 * Assign PMC numbers and compute MMCR1 value for a set of events
174 */ 174 */
175static int p6_compute_mmcr(u64 event[], int n_ev, 175static int p6_compute_mmcr(u64 event[], int n_ev,
176 unsigned int hwc[], u64 mmcr[]) 176 unsigned int hwc[], unsigned long mmcr[])
177{ 177{
178 u64 mmcr1 = 0; 178 unsigned long mmcr1 = 0;
179 u64 mmcra = 0; 179 unsigned long mmcra = 0;
180 int i; 180 int i;
181 unsigned int pmc, ev, b, u, s, psel; 181 unsigned int pmc, ev, b, u, s, psel;
182 unsigned int ttmset = 0; 182 unsigned int ttmset = 0;
@@ -215,7 +215,7 @@ static int p6_compute_mmcr(u64 event[], int n_ev,
215 /* check for conflict on this byte of event bus */ 215 /* check for conflict on this byte of event bus */
216 if ((ttmset & (1 << b)) && MMCR1_TTMSEL(mmcr1, b) != u) 216 if ((ttmset & (1 << b)) && MMCR1_TTMSEL(mmcr1, b) != u)
217 return -1; 217 return -1;
218 mmcr1 |= (u64)u << MMCR1_TTMSEL_SH(b); 218 mmcr1 |= (unsigned long)u << MMCR1_TTMSEL_SH(b);
219 ttmset |= 1 << b; 219 ttmset |= 1 << b;
220 if (u == 5) { 220 if (u == 5) {
221 /* Nest events have a further mux */ 221 /* Nest events have a further mux */
@@ -224,7 +224,7 @@ static int p6_compute_mmcr(u64 event[], int n_ev,
224 MMCR1_NESTSEL(mmcr1) != s) 224 MMCR1_NESTSEL(mmcr1) != s)
225 return -1; 225 return -1;
226 ttmset |= 0x10; 226 ttmset |= 0x10;
227 mmcr1 |= (u64)s << MMCR1_NESTSEL_SH; 227 mmcr1 |= (unsigned long)s << MMCR1_NESTSEL_SH;
228 } 228 }
229 if (0x30 <= psel && psel <= 0x3d) { 229 if (0x30 <= psel && psel <= 0x3d) {
230 /* these need the PMCx_ADDR_SEL bits */ 230 /* these need the PMCx_ADDR_SEL bits */
@@ -243,7 +243,7 @@ static int p6_compute_mmcr(u64 event[], int n_ev,
243 if (power6_marked_instr_event(event[i])) 243 if (power6_marked_instr_event(event[i]))
244 mmcra |= MMCRA_SAMPLE_ENABLE; 244 mmcra |= MMCRA_SAMPLE_ENABLE;
245 if (pmc < 4) 245 if (pmc < 4)
246 mmcr1 |= (u64)psel << MMCR1_PMCSEL_SH(pmc); 246 mmcr1 |= (unsigned long)psel << MMCR1_PMCSEL_SH(pmc);
247 } 247 }
248 mmcr[0] = 0; 248 mmcr[0] = 0;
249 if (pmc_inuse & 1) 249 if (pmc_inuse & 1)
@@ -265,10 +265,11 @@ static int p6_compute_mmcr(u64 event[], int n_ev,
265 * 20-23, 24-27, 28-31 ditto for bytes 1, 2, 3 265 * 20-23, 24-27, 28-31 ditto for bytes 1, 2, 3
266 * 32-34 select field: nest (subunit) event selector 266 * 32-34 select field: nest (subunit) event selector
267 */ 267 */
268static int p6_get_constraint(u64 event, u64 *maskp, u64 *valp) 268static int p6_get_constraint(u64 event, unsigned long *maskp,
269 unsigned long *valp)
269{ 270{
270 int pmc, byte, sh, subunit; 271 int pmc, byte, sh, subunit;
271 u64 mask = 0, value = 0; 272 unsigned long mask = 0, value = 0;
272 273
273 pmc = (event >> PM_PMC_SH) & PM_PMC_MSK; 274 pmc = (event >> PM_PMC_SH) & PM_PMC_MSK;
274 if (pmc) { 275 if (pmc) {
@@ -282,11 +283,11 @@ static int p6_get_constraint(u64 event, u64 *maskp, u64 *valp)
282 byte = (event >> PM_BYTE_SH) & PM_BYTE_MSK; 283 byte = (event >> PM_BYTE_SH) & PM_BYTE_MSK;
283 sh = byte * 4 + (16 - PM_UNIT_SH); 284 sh = byte * 4 + (16 - PM_UNIT_SH);
284 mask |= PM_UNIT_MSKS << sh; 285 mask |= PM_UNIT_MSKS << sh;
285 value |= (u64)(event & PM_UNIT_MSKS) << sh; 286 value |= (unsigned long)(event & PM_UNIT_MSKS) << sh;
286 if ((event & PM_UNIT_MSKS) == (5 << PM_UNIT_SH)) { 287 if ((event & PM_UNIT_MSKS) == (5 << PM_UNIT_SH)) {
287 subunit = (event >> PM_SUBUNIT_SH) & PM_SUBUNIT_MSK; 288 subunit = (event >> PM_SUBUNIT_SH) & PM_SUBUNIT_MSK;
288 mask |= (u64)PM_SUBUNIT_MSK << 32; 289 mask |= (unsigned long)PM_SUBUNIT_MSK << 32;
289 value |= (u64)subunit << 32; 290 value |= (unsigned long)subunit << 32;
290 } 291 }
291 } 292 }
292 if (pmc <= 4) { 293 if (pmc <= 4) {
@@ -458,7 +459,7 @@ static int p6_get_alternatives(u64 event, unsigned int flags, u64 alt[])
458 return nalt; 459 return nalt;
459} 460}
460 461
461static void p6_disable_pmc(unsigned int pmc, u64 mmcr[]) 462static void p6_disable_pmc(unsigned int pmc, unsigned long mmcr[])
462{ 463{
463 /* Set PMCxSEL to 0 to disable PMCx */ 464 /* Set PMCxSEL to 0 to disable PMCx */
464 if (pmc <= 3) 465 if (pmc <= 3)
@@ -516,17 +517,17 @@ static int power6_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
516}; 517};
517 518
518struct power_pmu power6_pmu = { 519struct power_pmu power6_pmu = {
519 .n_counter = 6, 520 .n_counter = 6,
520 .max_alternatives = MAX_ALT, 521 .max_alternatives = MAX_ALT,
521 .add_fields = 0x1555, 522 .add_fields = 0x1555,
522 .test_adder = 0x3000, 523 .test_adder = 0x3000,
523 .compute_mmcr = p6_compute_mmcr, 524 .compute_mmcr = p6_compute_mmcr,
524 .get_constraint = p6_get_constraint, 525 .get_constraint = p6_get_constraint,
525 .get_alternatives = p6_get_alternatives, 526 .get_alternatives = p6_get_alternatives,
526 .disable_pmc = p6_disable_pmc, 527 .disable_pmc = p6_disable_pmc,
527 .limited_pmc_event = p6_limited_pmc_event, 528 .limited_pmc_event = p6_limited_pmc_event,
528 .flags = PPMU_LIMITED_PMC5_6 | PPMU_ALT_SIPR, 529 .flags = PPMU_LIMITED_PMC5_6 | PPMU_ALT_SIPR,
529 .n_generic = ARRAY_SIZE(power6_generic_events), 530 .n_generic = ARRAY_SIZE(power6_generic_events),
530 .generic_events = power6_generic_events, 531 .generic_events = power6_generic_events,
531 .cache_events = &power6_cache_events, 532 .cache_events = &power6_cache_events,
532}; 533};