lib: sbi_hart: clear mip csr during hart init
PATCH 1/1 lib: sbi_hart: clear mip csr during hart init
If mip.SEIP bit is not cleared then on HiFive Unmatched board it causes spurious external interrupts. This breaks the boot up of HiFive Unmatched board. Hence it is required to bring the mip CSR to a known state during hart init and avoid spurious interrupts.
--- firmware/fw_base.S | 7 ------- lib/sbi/sbi_hart.c | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-)
firmware/fw_base.S +0 -7
@@ -430,13 +430,6 @@ _start_warm: /* Disable all interrupts */ csrw CSR_MIE, zero - /* - * Only clear the MIP_SSIP and MIP_STIP. For the platform like QEMU, - * If we clear other interrupts like MIP_SEIP and the pendings of - * PLIC still exist, the QEMU may not set it back immediately. - */ - li t0, (MIP_SSIP | MIP_STIP) - csrc CSR_MIP, t0 /* Find HART count and HART stack size */ lla a4, platform
lib/sbi/sbi_hart.c +6 -0
@@ -733,6 +733,12 @@ int sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot) {int rc; +/* +* Clear mip CSR before proceeding with init to avoid any spurious +* external interrupts in S-mode. +*/ +csr_write (CSR_MIP ,0 ); +if (cold_boot) {if (misa_extension ('H' )) sbi_hart_expected_trap = &__sbi_expected_trap_hext;
Signature · 1 line
2.34.1
Anup Patel
AppliedPATCH 1/1 lib: sbi_hart: clear mip csr during hart init
Quoted 8 lines · On Sat, Mar 25, 2023 at 10:21?PM Mayuresh Chitale <[email protected]>…
If mip.SEIP bit is not cleared then on HiFive Unmatched board it causes spurious external interrupts. This breaks the boot up of HiFive Unmatched board. Hence it is required to bring the mip CSR to a known state during hart init and avoid spurious interrupts.
Fixes d9e7368 ("firmware: Not to clear all the MIP")Signed-off-by Mayuresh Chitale <[email protected]>
Looks good to me.
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
Quoted 48 lines
--- firmware/fw_base.S | 7 ------- lib/sbi/sbi_hart.c | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-)firmware/fw_base.S +0
-7@@ -430,13 +430,6 @@ _start_warm: /* Disable all interrupts */ csrw CSR_MIE, zero - /* - * Only clear the MIP_SSIP and MIP_STIP. For the platform like QEMU, - * If we clear other interrupts like MIP_SEIP and the pendings of - * PLIC still exist, the QEMU may not set it back immediately. - */ - li t0, (MIP_SSIP | MIP_STIP) - csrc CSR_MIP, t0 /* Find HART count and HART stack size */ lla a4, platformlib/sbi/sbi_hart.c +6
-1@@ -733,6 +733,12 @@ int sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot) {int rc; +/* +* Clear mip CSR before proceeding with init to avoid any spurious +* external interrupts in S-mode. +*/ +csr_write (CSR_MIP ,0 ); +if (cold_boot) {if (misa_extension ('H' )) sbi_hart_expected_trap = &__sbi_expected_trap_hext; --2.34.1
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi