mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-11-19 18:21:41 +00:00
Linux stops a counter before issuing another stop with RESET flag when
deleting an event [1]. Returning early on SBI_EALREADY_STOPPED skips
counter-to-event mapping reset, eventually exhausting the hardware
counters.
Continue the stop and reset process for the remaining counters when a
counter in the set is already stopped. Preserve SBI_EALREADY_STOPPED in
the final result, while still returning immediately on other errors.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/perf/riscv_pmu.c?id=72d3fcf802c45d00b300f25b848a93c3a2bd7c7e#n318
Fixes: c5077d497d ("lib: sbi_pmu: Fix counter and event info error codes as per SBI v3.0 spec")
Signed-off-by: Fengwei Tan <tfx2001@outlook.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/SY8P300MB00410B44E7D55CB5CF7B276AB5882@SY8P300MB0041.AUSP300.PROD.OUTLOOK.COM
Signed-off-by: Anup Patel <anup@brainfault.org>