[PATCH] lib: sbi: pmu: Improve loop in pmu_ctr_find_hw
Manuel Hernández Méndez
maherme.dev at gmail.com
Mon Jul 21 09:07:12 PDT 2025
We do not need to iterate over all values in the loop,
we can break the loop when we found a valid counter
that is not started yet.
Signed-off-by: Manuel Hernández Méndez <maherme.dev at gmail.com>
---
lib/sbi/sbi_pmu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/sbi/sbi_pmu.c b/lib/sbi/sbi_pmu.c
index 07a5c544..635cb0c7 100644
--- a/lib/sbi/sbi_pmu.c
+++ b/lib/sbi/sbi_pmu.c
@@ -780,6 +780,7 @@ static int pmu_ctr_find_hw(struct sbi_pmu_hart_state *phs,
continue;
/* We found a valid counter that is not started yet */
ctr_idx = cbase;
+ break;
}
}
--
2.34.1
More information about the opensbi
mailing list