Skip to content

Commit 9349991

Browse files
bebarinowildea01
authored andcommitted
ARM: perf: Only reset PMxEVCNTCR registers on reset
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>
1 parent 65bab45 commit 9349991

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

arch/arm/kernel/perf_event_v7.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,8 +1218,6 @@ static void krait_evt_setup(int idx, u32 config_base)
12181218
val |= config_base & (ARMV7_EXCLUDE_USER | ARMV7_EXCLUDE_PL1);
12191219
armv7_pmnc_write_evtsel(idx, val);
12201220

1221-
asm volatile("mcr p15, 0, %0, c9, c15, 0" : : "r" (0));
1222-
12231221
if (venum_event) {
12241222
venum_pre_pmresr(&vval, &fval);
12251223
val = venum_read_pmresr();
@@ -1339,6 +1337,8 @@ static void krait_pmu_enable_event(struct perf_event *event)
13391337
static void krait_pmu_reset(void *info)
13401338
{
13411339
u32 vval, fval;
1340+
struct arm_pmu *cpu_pmu = info;
1341+
u32 idx, nb_cnt = cpu_pmu->num_events;
13421342

13431343
armv7pmu_reset(info);
13441344

@@ -1350,6 +1350,13 @@ static void krait_pmu_reset(void *info)
13501350
venum_pre_pmresr(&vval, &fval);
13511351
venum_write_pmresr(0);
13521352
venum_post_pmresr(vval, fval);
1353+
1354+
/* Reset PMxEVNCTCR to sane default */
1355+
for (idx = ARMV7_IDX_CYCLE_COUNTER; idx < nb_cnt; ++idx) {
1356+
armv7_pmnc_select_counter(idx);
1357+
asm volatile("mcr p15, 0, %0, c9, c15, 0" : : "r" (0));
1358+
}
1359+
13531360
}
13541361

13551362
static int krait_event_to_bit(struct perf_event *event, unsigned int region,

0 commit comments

Comments
 (0)