If the ecall SBI_EXT_HSM_HART_START is called it might try to wake the
secondary hart using sbi_ipi_raw_send() to send an IPI to the hart.
This can fail if there is no IPI device but no error is returned from
sbi_ipi_raw_send() so the ecall returns as if the action completed and
the caller continues without noticing (in the case of Linux it just hangs
waiting for the secondary hart to become active)
Fix this by changing sbi_ipi_raw_send() to return and error, and if an
error is returned, then return it via SBI_EXT_HSM_HART_START call.
Signed-off-by: Ben Dooks <ben.dooks@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
void sbi_ipi_process(void);
-void sbi_ipi_raw_send(u32 target_hart);
+int sbi_ipi_raw_send(u32 target_hart);
const struct sbi_ipi_device *sbi_ipi_get_device(void);
(hsm_device_has_hart_secondary_boot() && !init_count)) {
return hsm_device_hart_start(hartid, scratch->warmboot_addr);
} else {
- sbi_ipi_raw_send(hartid);
+ int rc = sbi_ipi_raw_send(hartid);
+ if (rc)
+ return rc;
}
return 0;
};
}
-void sbi_ipi_raw_send(u32 target_hart)
+int sbi_ipi_raw_send(u32 target_hart)
{
- if (ipi_dev && ipi_dev->ipi_send)
- ipi_dev->ipi_send(target_hart);
+ if (!ipi_dev || !ipi_dev->ipi_send)
+ return SBI_EINVAL;
+
+ ipi_dev->ipi_send(target_hart);
+ return 0;
}
const struct sbi_ipi_device *sbi_ipi_get_device(void)