Skip to content

Commit

Permalink
ARM: perf: Only reset PMxEVCNTCR registers on reset
Browse files Browse the repository at this point in the history
The Krait specific PMxEVCNTCR register is unpredictable upon
reset. Currently we clear the register before we setup an event,
but we don't need to do that. Instead, we can iterate through all
the events and clear them once when we reset the PMU, saving a
write in the event setup path.

Cc: Neil Leeder <nleeder@codeaurora.org>
Cc: Ashwin Chaugule <ashwinc@codeaurora.org>
Cc: Sheetal Sahasrabudhe <sheetals@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
  • Loading branch information
Stephen Boyd authored and Will Deacon committed Mar 17, 2015
1 parent 65bab45 commit 9349991
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions arch/arm/kernel/perf_event_v7.c
Original file line number Diff line number Diff line change
Expand Up @@ -1218,8 +1218,6 @@ static void krait_evt_setup(int idx, u32 config_base)
val |= config_base & (ARMV7_EXCLUDE_USER | ARMV7_EXCLUDE_PL1);
armv7_pmnc_write_evtsel(idx, val);

asm volatile("mcr p15, 0, %0, c9, c15, 0" : : "r" (0));

if (venum_event) {
venum_pre_pmresr(&vval, &fval);
val = venum_read_pmresr();
Expand Down Expand Up @@ -1339,6 +1337,8 @@ static void krait_pmu_enable_event(struct perf_event *event)
static void krait_pmu_reset(void *info)
{
u32 vval, fval;
struct arm_pmu *cpu_pmu = info;
u32 idx, nb_cnt = cpu_pmu->num_events;

armv7pmu_reset(info);

Expand All @@ -1350,6 +1350,13 @@ static void krait_pmu_reset(void *info)
venum_pre_pmresr(&vval, &fval);
venum_write_pmresr(0);
venum_post_pmresr(vval, fval);

/* Reset PMxEVNCTCR to sane default */
for (idx = ARMV7_IDX_CYCLE_COUNTER; idx < nb_cnt; ++idx) {
armv7_pmnc_select_counter(idx);
asm volatile("mcr p15, 0, %0, c9, c15, 0" : : "r" (0));
}

}

static int krait_event_to_bit(struct perf_event *event, unsigned int region,
Expand Down

0 comments on commit 9349991

Please sign in to comment.