summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2021-07-11 11:58:19 +0300
committerAnup Patel <anup@brainfault.org>2021-07-11 12:01:21 +0300
commita76ac4449bf2b67b899ebdb5085834e94987b690 (patch)
treef1733139bb9d6c00c3240c213b6ffc5a332b463e
parentb88b3661d43760fbc06bc83de2c5b204a2bb03dd (diff)
downloadopensbi-a76ac4449bf2b67b899ebdb5085834e94987b690.tar.xz
lib: sbi: Fix sbi_pmu_exit() for systems not having MCOUNTINHIBIT csr
The sbi_pmu_exit() crashes on systems not having MCOUNTINHIBIT csr so to fix this we check SBI_HART_HAS_MCOUNTINHIBIT feature in sbi_pmu_exit() and do nothing if it is not available. Fixes: 13d40f21d588 ("lib: sbi: Add PMU support") Signed-off-by: Anup Patel <anup.patel@wdc.com>
-rw-r--r--lib/sbi/sbi_pmu.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/sbi/sbi_pmu.c b/lib/sbi/sbi_pmu.c
index 4092e6f..c276a46 100644
--- a/lib/sbi/sbi_pmu.c
+++ b/lib/sbi/sbi_pmu.c
@@ -583,6 +583,10 @@ void sbi_pmu_exit(struct sbi_scratch *scratch)
{
u32 hartid = current_hartid();
+ /* SBI PMU is not supported if mcountinhibit is not available */
+ if (!sbi_hart_has_feature(scratch, SBI_HART_HAS_MCOUNTINHIBIT))
+ return;
+
csr_write(CSR_MCOUNTINHIBIT, 0xFFFFFFF8);
csr_write(CSR_MCOUNTEREN, 7);
pmu_reset_event_map(hartid);