aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/power5+-pmu.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/kernel/power5+-pmu.c')
-rw-r--r--arch/powerpc/kernel/power5+-pmu.c79
1 files changed, 41 insertions, 38 deletions
diff --git a/arch/powerpc/kernel/power5+-pmu.c b/arch/powerpc/kernel/power5+-pmu.c
index 41e5d2d958d4..aef144d503b0 100644
--- a/arch/powerpc/kernel/power5+-pmu.c
+++ b/arch/powerpc/kernel/power5+-pmu.c
@@ -126,20 +126,21 @@ static const int grsel_shift[8] = {
126}; 126};
127 127
128/* Masks and values for using events from the various units */ 128/* Masks and values for using events from the various units */
129static u64 unit_cons[PM_LASTUNIT+1][2] = { 129static unsigned long unit_cons[PM_LASTUNIT+1][2] = {
130 [PM_FPU] = { 0x3200000000ull, 0x0100000000ull }, 130 [PM_FPU] = { 0x3200000000ul, 0x0100000000ul },
131 [PM_ISU0] = { 0x0200000000ull, 0x0080000000ull }, 131 [PM_ISU0] = { 0x0200000000ul, 0x0080000000ul },
132 [PM_ISU1] = { 0x3200000000ull, 0x3100000000ull }, 132 [PM_ISU1] = { 0x3200000000ul, 0x3100000000ul },
133 [PM_IFU] = { 0x3200000000ull, 0x2100000000ull }, 133 [PM_IFU] = { 0x3200000000ul, 0x2100000000ul },
134 [PM_IDU] = { 0x0e00000000ull, 0x0040000000ull }, 134 [PM_IDU] = { 0x0e00000000ul, 0x0040000000ul },
135 [PM_GRS] = { 0x0e00000000ull, 0x0c40000000ull }, 135 [PM_GRS] = { 0x0e00000000ul, 0x0c40000000ul },
136}; 136};
137 137
138static int power5p_get_constraint(u64 event, u64 *maskp, u64 *valp) 138static int power5p_get_constraint(u64 event, unsigned long *maskp,
139 unsigned long *valp)
139{ 140{
140 int pmc, byte, unit, sh; 141 int pmc, byte, unit, sh;
141 int bit, fmask; 142 int bit, fmask;
142 u64 mask = 0, value = 0; 143 unsigned long mask = 0, value = 0;
143 144
144 pmc = (event >> PM_PMC_SH) & PM_PMC_MSK; 145 pmc = (event >> PM_PMC_SH) & PM_PMC_MSK;
145 if (pmc) { 146 if (pmc) {
@@ -171,17 +172,18 @@ static int power5p_get_constraint(u64 event, u64 *maskp, u64 *valp)
171 bit = event & 7; 172 bit = event & 7;
172 fmask = (bit == 6)? 7: 3; 173 fmask = (bit == 6)? 7: 3;
173 sh = grsel_shift[bit]; 174 sh = grsel_shift[bit];
174 mask |= (u64)fmask << sh; 175 mask |= (unsigned long)fmask << sh;
175 value |= (u64)((event >> PM_GRS_SH) & fmask) << sh; 176 value |= (unsigned long)((event >> PM_GRS_SH) & fmask)
177 << sh;
176 } 178 }
177 /* Set byte lane select field */ 179 /* Set byte lane select field */
178 mask |= 0xfULL << (24 - 4 * byte); 180 mask |= 0xfUL << (24 - 4 * byte);
179 value |= (u64)unit << (24 - 4 * byte); 181 value |= (unsigned long)unit << (24 - 4 * byte);
180 } 182 }
181 if (pmc < 5) { 183 if (pmc < 5) {
182 /* need a counter from PMC1-4 set */ 184 /* need a counter from PMC1-4 set */
183 mask |= 0x8000000000000ull; 185 mask |= 0x8000000000000ul;
184 value |= 0x1000000000000ull; 186 value |= 0x1000000000000ul;
185 } 187 }
186 *maskp = mask; 188 *maskp = mask;
187 *valp = value; 189 *valp = value;
@@ -452,10 +454,10 @@ static int power5p_marked_instr_event(u64 event)
452} 454}
453 455
454static int power5p_compute_mmcr(u64 event[], int n_ev, 456static int power5p_compute_mmcr(u64 event[], int n_ev,
455 unsigned int hwc[], u64 mmcr[]) 457 unsigned int hwc[], unsigned long mmcr[])
456{ 458{
457 u64 mmcr1 = 0; 459 unsigned long mmcr1 = 0;
458 u64 mmcra = 0; 460 unsigned long mmcra = 0;
459 unsigned int pmc, unit, byte, psel; 461 unsigned int pmc, unit, byte, psel;
460 unsigned int ttm; 462 unsigned int ttm;
461 int i, isbus, bit, grsel; 463 int i, isbus, bit, grsel;
@@ -517,7 +519,7 @@ static int power5p_compute_mmcr(u64 event[], int n_ev,
517 continue; 519 continue;
518 if (ttmuse++) 520 if (ttmuse++)
519 return -1; 521 return -1;
520 mmcr1 |= (u64)i << MMCR1_TTM0SEL_SH; 522 mmcr1 |= (unsigned long)i << MMCR1_TTM0SEL_SH;
521 } 523 }
522 ttmuse = 0; 524 ttmuse = 0;
523 for (; i <= PM_GRS; ++i) { 525 for (; i <= PM_GRS; ++i) {
@@ -525,7 +527,7 @@ static int power5p_compute_mmcr(u64 event[], int n_ev,
525 continue; 527 continue;
526 if (ttmuse++) 528 if (ttmuse++)
527 return -1; 529 return -1;
528 mmcr1 |= (u64)(i & 3) << MMCR1_TTM1SEL_SH; 530 mmcr1 |= (unsigned long)(i & 3) << MMCR1_TTM1SEL_SH;
529 } 531 }
530 if (ttmuse > 1) 532 if (ttmuse > 1)
531 return -1; 533 return -1;
@@ -540,10 +542,11 @@ static int power5p_compute_mmcr(u64 event[], int n_ev,
540 unit = PM_ISU0_ALT; 542 unit = PM_ISU0_ALT;
541 } else if (unit == PM_LSU1 + 1) { 543 } else if (unit == PM_LSU1 + 1) {
542 /* select lower word of LSU1 for this byte */ 544 /* select lower word of LSU1 for this byte */
543 mmcr1 |= 1ull << (MMCR1_TTM3SEL_SH + 3 - byte); 545 mmcr1 |= 1ul << (MMCR1_TTM3SEL_SH + 3 - byte);
544 } 546 }
545 ttm = unit >> 2; 547 ttm = unit >> 2;
546 mmcr1 |= (u64)ttm << (MMCR1_TD_CP_DBG0SEL_SH - 2 * byte); 548 mmcr1 |= (unsigned long)ttm
549 << (MMCR1_TD_CP_DBG0SEL_SH - 2 * byte);
547 } 550 }
548 551
549 /* Second pass: assign PMCs, set PMCxSEL and PMCx_ADDER_SEL fields */ 552 /* Second pass: assign PMCs, set PMCxSEL and PMCx_ADDER_SEL fields */
@@ -568,7 +571,7 @@ static int power5p_compute_mmcr(u64 event[], int n_ev,
568 if (isbus && (byte & 2) && 571 if (isbus && (byte & 2) &&
569 (psel == 8 || psel == 0x10 || psel == 0x28)) 572 (psel == 8 || psel == 0x10 || psel == 0x28))
570 /* add events on higher-numbered bus */ 573 /* add events on higher-numbered bus */
571 mmcr1 |= 1ull << (MMCR1_PMC1_ADDER_SEL_SH - pmc); 574 mmcr1 |= 1ul << (MMCR1_PMC1_ADDER_SEL_SH - pmc);
572 } else { 575 } else {
573 /* Instructions or run cycles on PMC5/6 */ 576 /* Instructions or run cycles on PMC5/6 */
574 --pmc; 577 --pmc;
@@ -576,7 +579,7 @@ static int power5p_compute_mmcr(u64 event[], int n_ev,
576 if (isbus && unit == PM_GRS) { 579 if (isbus && unit == PM_GRS) {
577 bit = psel & 7; 580 bit = psel & 7;
578 grsel = (event[i] >> PM_GRS_SH) & PM_GRS_MSK; 581 grsel = (event[i] >> PM_GRS_SH) & PM_GRS_MSK;
579 mmcr1 |= (u64)grsel << grsel_shift[bit]; 582 mmcr1 |= (unsigned long)grsel << grsel_shift[bit];
580 } 583 }
581 if (power5p_marked_instr_event(event[i])) 584 if (power5p_marked_instr_event(event[i]))
582 mmcra |= MMCRA_SAMPLE_ENABLE; 585 mmcra |= MMCRA_SAMPLE_ENABLE;
@@ -599,7 +602,7 @@ static int power5p_compute_mmcr(u64 event[], int n_ev,
599 return 0; 602 return 0;
600} 603}
601 604
602static void power5p_disable_pmc(unsigned int pmc, u64 mmcr[]) 605static void power5p_disable_pmc(unsigned int pmc, unsigned long mmcr[])
603{ 606{
604 if (pmc <= 3) 607 if (pmc <= 3)
605 mmcr[1] &= ~(0x7fUL << MMCR1_PMCSEL_SH(pmc)); 608 mmcr[1] &= ~(0x7fUL << MMCR1_PMCSEL_SH(pmc));
@@ -655,17 +658,17 @@ static int power5p_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
655}; 658};
656 659
657struct power_pmu power5p_pmu = { 660struct power_pmu power5p_pmu = {
658 .n_counter = 6, 661 .n_counter = 6,
659 .max_alternatives = MAX_ALT, 662 .max_alternatives = MAX_ALT,
660 .add_fields = 0x7000000000055ull, 663 .add_fields = 0x7000000000055ul,
661 .test_adder = 0x3000040000000ull, 664 .test_adder = 0x3000040000000ul,
662 .compute_mmcr = power5p_compute_mmcr, 665 .compute_mmcr = power5p_compute_mmcr,
663 .get_constraint = power5p_get_constraint, 666 .get_constraint = power5p_get_constraint,
664 .get_alternatives = power5p_get_alternatives, 667 .get_alternatives = power5p_get_alternatives,
665 .disable_pmc = power5p_disable_pmc, 668 .disable_pmc = power5p_disable_pmc,
666 .limited_pmc_event = power5p_limited_pmc_event, 669 .limited_pmc_event = power5p_limited_pmc_event,
667 .flags = PPMU_LIMITED_PMC5_6, 670 .flags = PPMU_LIMITED_PMC5_6,
668 .n_generic = ARRAY_SIZE(power5p_generic_events), 671 .n_generic = ARRAY_SIZE(power5p_generic_events),
669 .generic_events = power5p_generic_events, 672 .generic_events = power5p_generic_events,
670 .cache_events = &power5p_cache_events, 673 .cache_events = &power5p_cache_events,
671}; 674};