lib: sbi_pmu: do not ignore pmu_ctr_start_hw() error in cfg_match

sbi_pmu_ctr_cfg_match() calls pmu_ctr_start_hw() for the AUTO_START
flag and drops the result. pmu_ctr_start_hw() carries its own index
guard

	if (cidx >= num_hw_ctrs || cidx == 1)
		return SBI_EINVAL;

and can also return SBI_EALREADY_STARTED when the counter is already
running. Both are reported to the caller as a successful configure.

Neither is benign. A rejected index means nothing was configured, and
an already running counter may have been configured for a different
event previously, so the supervisor must not be told its configure
succeeded.

This is also the only one of the three start paths in the file that
discards the error. sbi_pmu_ctr_start() propagates it:

	ret = pmu_ctr_start_hw(cidx, ival, bUpdate);
	if (ret)
		return ret;

and the firmware branch directly below this call site propagates the
error from pmu_dev->fw_counter_start() as well.

Fixes: 13d40f21d5 ("lib: sbi: Add PMU support")
Signed-off-by: Sebastian Alba Vives <sebasjosue84@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20261025145338.2569358-2-sebasjosue84@gmail.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Sebastian Alba Vives authored and Anup Patel committed 2026-10-29 13:49:28 +05:30
1 parent 90ec61b228
commit 1e418fc818
1 file changed
+5 -2
+5 -2
View File
@@ -982,8 +982,11 @@ skip_match:
event_type == SBI_PMU_EVENT_TYPE_HW_RAW_V2) {
if (flags & SBI_PMU_CFG_FLAG_CLEAR_VALUE)
pmu_ctr_write_hw(ctr_idx, 0);
if (flags & SBI_PMU_CFG_FLAG_AUTO_START)
pmu_ctr_start_hw(ctr_idx, 0, false);
if (flags & SBI_PMU_CFG_FLAG_AUTO_START) {
ret = pmu_ctr_start_hw(ctr_idx, 0, false);
if (ret)
return ret;
}
} else if (event_type == SBI_PMU_EVENT_TYPE_FW) {
if (flags & SBI_PMU_CFG_FLAG_CLEAR_VALUE)
phs->fw_counters_data[ctr_idx - num_hw_ctrs] = 0;