diff options
author | Anshuman Khandual <khandual@linux.vnet.ibm.com> | 2013-04-22 15:42:43 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-04-26 02:13:01 -0400 |
commit | b1113557fb5f4d47d888572a7ffeac91fc692743 (patch) | |
tree | e4e5761126f61cdc113f7b01234a73af4fe973f0 | |
parent | 5afc9b52a797790bd02680207d183ba218e73d20 (diff) |
powerpc/perf: Define BHRB generic functions, data and flags for POWER8
This patch populates BHRB specific data for power_pmu structure. It
also implements POWER8 specific BHRB filter and configuration functions.
Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | arch/powerpc/perf/power8-pmu.c | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c index c6aa713ddf5f..f7d1c4fff303 100644 --- a/arch/powerpc/perf/power8-pmu.c +++ b/arch/powerpc/perf/power8-pmu.c | |||
@@ -109,6 +109,16 @@ | |||
109 | #define EVENT_IS_MARKED (EVENT_MARKED_MASK << EVENT_MARKED_SHIFT) | 109 | #define EVENT_IS_MARKED (EVENT_MARKED_MASK << EVENT_MARKED_SHIFT) |
110 | #define EVENT_PSEL_MASK 0xff /* PMCxSEL value */ | 110 | #define EVENT_PSEL_MASK 0xff /* PMCxSEL value */ |
111 | 111 | ||
112 | /* MMCRA IFM bits - POWER8 */ | ||
113 | #define POWER8_MMCRA_IFM1 0x0000000040000000UL | ||
114 | #define POWER8_MMCRA_IFM2 0x0000000080000000UL | ||
115 | #define POWER8_MMCRA_IFM3 0x00000000C0000000UL | ||
116 | |||
117 | #define ONLY_PLM \ | ||
118 | (PERF_SAMPLE_BRANCH_USER |\ | ||
119 | PERF_SAMPLE_BRANCH_KERNEL |\ | ||
120 | PERF_SAMPLE_BRANCH_HV) | ||
121 | |||
112 | /* | 122 | /* |
113 | * Layout of constraint bits: | 123 | * Layout of constraint bits: |
114 | * | 124 | * |
@@ -510,6 +520,48 @@ static int power8_generic_events[] = { | |||
510 | [PERF_COUNT_HW_BRANCH_MISSES] = PM_BR_MPRED_CMPL, | 520 | [PERF_COUNT_HW_BRANCH_MISSES] = PM_BR_MPRED_CMPL, |
511 | }; | 521 | }; |
512 | 522 | ||
523 | static u64 power8_bhrb_filter_map(u64 branch_sample_type) | ||
524 | { | ||
525 | u64 pmu_bhrb_filter = 0; | ||
526 | u64 br_privilege = branch_sample_type & ONLY_PLM; | ||
527 | |||
528 | /* BHRB and regular PMU events share the same prvillege state | ||
529 | * filter configuration. BHRB is always recorded along with a | ||
530 | * regular PMU event. So privilege state filter criteria for BHRB | ||
531 | * and the companion PMU events has to be the same. As a default | ||
532 | * "perf record" tool sets all privillege bits ON when no filter | ||
533 | * criteria is provided in the command line. So as along as all | ||
534 | * privillege bits are ON or they are OFF, we are good to go. | ||
535 | */ | ||
536 | if ((br_privilege != 7) && (br_privilege != 0)) | ||
537 | return -1; | ||
538 | |||
539 | /* No branch filter requested */ | ||
540 | if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY) | ||
541 | return pmu_bhrb_filter; | ||
542 | |||
543 | /* Invalid branch filter options - HW does not support */ | ||
544 | if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY_RETURN) | ||
545 | return -1; | ||
546 | |||
547 | if (branch_sample_type & PERF_SAMPLE_BRANCH_IND_CALL) | ||
548 | return -1; | ||
549 | |||
550 | if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY_CALL) { | ||
551 | pmu_bhrb_filter |= POWER8_MMCRA_IFM1; | ||
552 | return pmu_bhrb_filter; | ||
553 | } | ||
554 | |||
555 | /* Every thing else is unsupported */ | ||
556 | return -1; | ||
557 | } | ||
558 | |||
559 | static void power8_config_bhrb(u64 pmu_bhrb_filter) | ||
560 | { | ||
561 | /* Enable BHRB filter in PMU */ | ||
562 | mtspr(SPRN_MMCRA, (mfspr(SPRN_MMCRA) | pmu_bhrb_filter)); | ||
563 | } | ||
564 | |||
513 | static struct power_pmu power8_pmu = { | 565 | static struct power_pmu power8_pmu = { |
514 | .name = "POWER8", | 566 | .name = "POWER8", |
515 | .n_counter = 6, | 567 | .n_counter = 6, |
@@ -517,13 +569,16 @@ static struct power_pmu power8_pmu = { | |||
517 | .add_fields = POWER8_ADD_FIELDS, | 569 | .add_fields = POWER8_ADD_FIELDS, |
518 | .test_adder = POWER8_TEST_ADDER, | 570 | .test_adder = POWER8_TEST_ADDER, |
519 | .compute_mmcr = power8_compute_mmcr, | 571 | .compute_mmcr = power8_compute_mmcr, |
572 | .config_bhrb = power8_config_bhrb, | ||
573 | .bhrb_filter_map = power8_bhrb_filter_map, | ||
520 | .get_constraint = power8_get_constraint, | 574 | .get_constraint = power8_get_constraint, |
521 | .get_alternatives = power8_get_alternatives, | 575 | .get_alternatives = power8_get_alternatives, |
522 | .disable_pmc = power8_disable_pmc, | 576 | .disable_pmc = power8_disable_pmc, |
523 | .flags = PPMU_HAS_SSLOT | PPMU_HAS_SIER, | 577 | .flags = PPMU_HAS_SSLOT | PPMU_HAS_SIER | PPMU_BHRB, |
524 | .n_generic = ARRAY_SIZE(power8_generic_events), | 578 | .n_generic = ARRAY_SIZE(power8_generic_events), |
525 | .generic_events = power8_generic_events, | 579 | .generic_events = power8_generic_events, |
526 | .attr_groups = power8_pmu_attr_groups, | 580 | .attr_groups = power8_pmu_attr_groups, |
581 | .bhrb_nr = 32, | ||
527 | }; | 582 | }; |
528 | 583 | ||
529 | static int __init init_power8_pmu(void) | 584 | static int __init init_power8_pmu(void) |