From 2bbee7d82acec9c4a46b0a75855d33472b65cec4 Mon Sep 17 00:00:00 2001 From: Fengwei Tan Date: Sun, 27 Sep 2026 13:53:27 +0800 Subject: [PATCH] lib: sbi_pmu: Fix fixed-counter events reported as unsupported OpenSBI assigns SBI_PMU_HW_CPU_CYCLES and SBI_PMU_HW_INSTRUCTIONS to fixed counters during PMU initialization. sbi_pmu_ctr_cfg_match() recognizes these events without searching hw_event_map[]. However, sbi_pmu_event_get_info() only checks hw_event_map[] when determining whether a hardware event is supported. As a result, these fixed-counter events are reported as unsupported when no riscv,pmu device tree node is provided. Check fixed-counter events separately using pmu_ctr_find_fixed_hw() and report them as supported. Fixes: e4345842168b ("lib: sbi_pmu: Implement SBI PMU event info function") Signed-off-by: Fengwei Tan Reviewed-by: Anup Patel Link: https://lore.kernel.org/r/SY8P300MB0041D04649621E79FE950B43B58E2@SY8P300MB0041.AUSP300.PROD.OUTLOOK.COM Signed-off-by: Anup Patel --- lib/sbi/sbi_pmu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/sbi/sbi_pmu.c b/lib/sbi/sbi_pmu.c index 54877ee6..109362e1 100644 --- a/lib/sbi/sbi_pmu.c +++ b/lib/sbi/sbi_pmu.c @@ -1132,6 +1132,9 @@ int sbi_pmu_event_get_info(unsigned long shmem_phys_lo, unsigned long shmem_phys einfo[i].output = 0; } else if (event_type == SBI_PMU_EVENT_TYPE_FW) { einfo[i].output = 1; + } else if (event_type == SBI_PMU_EVENT_TYPE_HW && + pmu_ctr_find_fixed_hw(event_idx) >= 0) { + einfo[i].output = 1; } else { for (j = 0; j < num_hw_events; j++) { temp = &hw_event_map[j];