summaryrefslogtreecommitdiff
path: root/lib/sbi/sbi_init.c
diff options
context:
space:
mode:
authorAtish Patra <atish.patra@wdc.com>2020-03-21 01:10:36 +0300
committerAnup Patel <anup@brainfault.org>2020-03-21 06:51:47 +0300
commit9a74a64ae08bfeda8dc366e931f5a60838d7bac0 (patch)
treef8e28575f13a23c40165bd371bc2439e851eca8e /lib/sbi/sbi_init.c
parenta0c88ddb31ec5ce43f1dd8759a918ea590429176 (diff)
downloadopensbi-9a74a64ae08bfeda8dc366e931f5a60838d7bac0.tar.xz
lib: Check MSIP bit after returning from WFI
Commit 71d2b837c46e (lib: Move all coldboot wait APIs to sbi_init.c) caused a regression while moving the code from sbi_hart.c to sbi_init.c. As per original commit text, WFI can be implemented as a NOP according to the RISC-V privilege specification. Software should ensure that relevant interrupt pending bits are set. Otherwise, loop back to WFI. Fix the regression by applying the original patch to sbi_init.c. Fixes: 71d2b837c46e ("lib: Move all coldboot wait APIs to sbi_init.c") Signed-off-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'lib/sbi/sbi_init.c')
-rw-r--r--lib/sbi/sbi_init.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c
index 2b9afb7..90ec64c 100644
--- a/lib/sbi/sbi_init.c
+++ b/lib/sbi/sbi_init.c
@@ -79,7 +79,7 @@ static struct sbi_hartmask coldboot_wait_hmask = { 0 };
static void wait_for_coldboot(struct sbi_scratch *scratch, u32 hartid)
{
- unsigned long saved_mie;
+ unsigned long saved_mie, cmip;
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
/* Save MIE CSR */
@@ -97,7 +97,10 @@ static void wait_for_coldboot(struct sbi_scratch *scratch, u32 hartid)
/* Wait for coldboot to finish using WFI */
while (!coldboot_done) {
spin_unlock(&coldboot_lock);
- wfi();
+ do {
+ wfi();
+ cmip = csr_read(CSR_MIP);
+ } while (!(cmip & MIP_MSIP));
spin_lock(&coldboot_lock);
};