From bdb3c42bca1c7fddd0c43f0be24c3a1590f02e50 Mon Sep 17 00:00:00 2001 From: Alexandre Ghiti Date: Thu, 13 Apr 2023 16:02:18 +0200 Subject: [PATCH] lib: sbi: Do not clear active_events for cycle/instret when stopping Those events are enabled by default and should not be reset afterwards since when using SBI_PMU_CFG_FLAG_SKIP_MATCH, it leads to unaccessible counters after the first use. Signed-off-by: Alexandre Ghiti Reviewed-by: Atish Patra --- lib/sbi/sbi_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sbi/sbi_pmu.c b/lib/sbi/sbi_pmu.c index 04259ae..f28c9f5 100644 --- a/lib/sbi/sbi_pmu.c +++ b/lib/sbi/sbi_pmu.c @@ -532,7 +532,7 @@ int sbi_pmu_ctr_stop(unsigned long cbase, unsigned long cmask, else ret = pmu_ctr_stop_hw(cidx); - if (flag & SBI_PMU_STOP_FLAG_RESET) { + if (cidx > (CSR_INSTRET - CSR_CYCLE) && flag & SBI_PMU_STOP_FLAG_RESET) { active_events[hartid][cidx] = SBI_PMU_EVENT_IDX_INVALID; pmu_reset_hw_mhpmevent(cidx); }