[PATCH] lib: sbi_pmu: Fix fixed-counter events reported as unsupported

Fengwei Tan tfx2001 at outlook.com
Sat Sep 26 22:53:27 PDT 2026


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 <tfx2001 at outlook.com>
---
 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 e79f6b60..b4abfa1e 100644
--- a/lib/sbi/sbi_pmu.c
+++ b/lib/sbi/sbi_pmu.c
@@ -1119,6 +1119,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];

---
base-commit: 5a175017261af97e9122fcb9d9012481cdb5aa41
change-id: 20260927-fix-pmu-event-get-info-c4a6e2c5717b

Best regards,
--  
Fengwei Tan <tfx2001 at outlook.com>



More information about the opensbi mailing list