From 2f80a05eae72e360cf37b5b387c911a517134694 Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Sat, 24 Dec 2022 16:59:19 +0900 Subject: [PATCH] arch: qemu-rv: Fix qemu_rv_mtimer_interrupt() for BUILD_KERNEL Summary: - I noticed that rv-virt:ksmp64 sometimes stops during boot. - Finally, I found that it posts the Supervisor Software Interrupt before the OS finishes hardware initialization. - This commit fixes this issue. Impact: - None Testing: - Tested with QEMU-7.1 Signed-off-by: Masayuki Ishikawa --- arch/risc-v/src/qemu-rv/qemu_rv_timerisr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/risc-v/src/qemu-rv/qemu_rv_timerisr.c b/arch/risc-v/src/qemu-rv/qemu_rv_timerisr.c index 1492de5a3b4..92363ee7bad 100644 --- a/arch/risc-v/src/qemu-rv/qemu_rv_timerisr.c +++ b/arch/risc-v/src/qemu-rv/qemu_rv_timerisr.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -198,9 +199,12 @@ void qemu_rv_mtimer_interrupt(void) g_mtimer_cnt++; g_stimer_pending = true; - /* Post Supervisor Software Interrupt */ + if (OSINIT_HW_READY()) + { + /* Post Supervisor Software Interrupt */ - SET_CSR(sip, SIP_SSIP); + SET_CSR(sip, SIP_SSIP); + } } #endif /* CONFIG_BUILD_KERNEL */