[RFC PATCH 4/9] lib: sbi: Delegate PMU counter overflow interrupt to S mode
Atish Patra
atish.patra at wdc.com
Thu Sep 9 13:40:26 PDT 2021
We don't handle PMU counters for now. Delete the overflow counter to
S-mode always.
Signed-off-by: Atish Patra <atish.patra at wdc.com>
---
include/sbi/riscv_encoding.h | 2 ++
lib/sbi/sbi_hart.c | 3 +++
2 files changed, 5 insertions(+)
diff --git a/include/sbi/riscv_encoding.h b/include/sbi/riscv_encoding.h
index f01c6cf0264d..c2cf0f4d69f4 100644
--- a/include/sbi/riscv_encoding.h
+++ b/include/sbi/riscv_encoding.h
@@ -86,6 +86,7 @@
#define IRQ_VS_EXT 10
#define IRQ_M_EXT 11
#define IRQ_S_GEXT 12
+#define IRQ_PMU_OVF 13
#define MIP_SSIP (_UL(1) << IRQ_S_SOFT)
#define MIP_VSSIP (_UL(1) << IRQ_VS_SOFT)
@@ -97,6 +98,7 @@
#define MIP_VSEIP (_UL(1) << IRQ_VS_EXT)
#define MIP_MEIP (_UL(1) << IRQ_M_EXT)
#define MIP_SGEIP (_UL(1) << IRQ_S_GEXT)
+#define MIP_LCOFIP (_UL(1) << IRQ_PMU_OVF)
#define SIP_SSIP MIP_SSIP
#define SIP_STIP MIP_STIP
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index 44b8dfd1b551..6076bea2470d 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -115,6 +115,9 @@ static int delegate_traps(struct sbi_scratch *scratch)
/* Send M-mode interrupts and most exceptions to S-mode */
interrupts = MIP_SSIP | MIP_STIP | MIP_SEIP;
+ if (sbi_hart_has_feature(scratch, SBI_HART_HAS_SSCOF))
+ interrupts |= MIP_LCOFIP;
+
exceptions = (1U << CAUSE_MISALIGNED_FETCH) | (1U << CAUSE_BREAKPOINT) |
(1U << CAUSE_USER_ECALL);
if (sbi_platform_has_mfaults_delegation(plat))
--
2.31.1
More information about the opensbi
mailing list