mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 23:41:23 +01:00
lib: Check MSIP bit after returning from WFI
As per the RISC-V privilege specification, WFI can be implemented as a NOP. Software should ensure that relevant interrupt pending bits are set. Otherwise, loop back to WFI. Signed-off-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
@@ -385,7 +385,7 @@ static unsigned long coldboot_wait_bitmap = 0;
|
|||||||
|
|
||||||
void sbi_hart_wait_for_coldboot(struct sbi_scratch *scratch, u32 hartid)
|
void sbi_hart_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);
|
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
||||||
|
|
||||||
if ((sbi_platform_hart_count(plat) <= hartid) ||
|
if ((sbi_platform_hart_count(plat) <= hartid) ||
|
||||||
@@ -407,7 +407,10 @@ void sbi_hart_wait_for_coldboot(struct sbi_scratch *scratch, u32 hartid)
|
|||||||
/* Wait for coldboot to finish using WFI */
|
/* Wait for coldboot to finish using WFI */
|
||||||
while (!coldboot_done) {
|
while (!coldboot_done) {
|
||||||
spin_unlock(&coldboot_lock);
|
spin_unlock(&coldboot_lock);
|
||||||
wfi();
|
do {
|
||||||
|
wfi();
|
||||||
|
cmip = csr_read(CSR_MIP);
|
||||||
|
} while (!(cmip & MIP_MSIP));
|
||||||
spin_lock(&coldboot_lock);
|
spin_lock(&coldboot_lock);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user