From: Cheng Yang Date: Wed, 15 May 2024 06:15:14 +0000 (+0800) Subject: lib: utils/irqchip: Check before initializing imsic X-Git-Tag: v1.5~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e3a30a2c918aae79d4cc403d474c3d2872a9063c;p=platform%2Fkernel%2Fopensbi.git lib: utils/irqchip: Check before initializing imsic The current mlevel imsic check is only for the platform, which may cause hart without imsic in the platform to trigger an illegal instruction exception when initializing imsic. For example, the platform contains a management hart that only supports wired interrupts. This patch will check if each hart supports Smaia extension before doing imsic initialization to avoid triggering illegal instruction exceptions. Signed-off-by: Cheng Yang Reviewed-by: Anup Patel --- diff --git a/lib/utils/irqchip/imsic.c b/lib/utils/irqchip/imsic.c index f2a35c6..02e3a33 100644 --- a/lib/utils/irqchip/imsic.c +++ b/lib/utils/irqchip/imsic.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -222,6 +223,8 @@ static void imsic_local_eix_update(unsigned long base_id, void imsic_local_irqchip_init(void) { + struct sbi_trap_info trap = { 0 }; + /* * This function is expected to be called from: * 1) nascent_init() platform callback which is called @@ -231,6 +234,11 @@ void imsic_local_irqchip_init(void) * in boot-up path. */ + /* If Smaia not available then do nothing */ + csr_read_allowed(CSR_MTOPI, (ulong)&trap); + if (trap.cause) + return; + /* Setup threshold to allow all enabled interrupts */ imsic_csr_write(IMSIC_EITHRESHOLD, IMSIC_ENABLE_EITHRESHOLD);