Skip to content

Commit 7b090e7

Browse files
mdchitalePaul Walmsley
authored andcommitted
riscv: sbi: Prefer SRST shutdown over legacy
Currently, the sbi_init() always attempts to register the legacy shutdown function as the sys-off handler which is fine when RISCV_SBI_V01 is not enabled. However, if RISCV_SBI_V01 is enabled in the kernel and the SBI v0.1 is not supported by the underlying SBI implementation then the legacy shutdown fails. Fix this by not registering the legacy shutdown when SRST shutdown is available. Fixes: 70ddf86 ("riscv: sbi: Switch to new sys-off handler API") Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://patch.msgid.link/20251114065808.304430-1-mchitale@ventanamicro.com Signed-off-by: Paul Walmsley <pjw@kernel.org>
1 parent 91f815b commit 7b090e7

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

arch/riscv/kernel/sbi.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,9 +648,9 @@ int sbi_debug_console_read(char *bytes, unsigned int num_bytes)
648648

649649
void __init sbi_init(void)
650650
{
651+
bool srst_power_off = false;
651652
int ret;
652653

653-
sbi_set_power_off();
654654
ret = sbi_get_spec_version();
655655
if (ret > 0)
656656
sbi_spec_version = ret;
@@ -683,6 +683,7 @@ void __init sbi_init(void)
683683
sbi_probe_extension(SBI_EXT_SRST)) {
684684
pr_info("SBI SRST extension detected\n");
685685
register_platform_power_off(sbi_srst_power_off);
686+
srst_power_off = true;
686687
sbi_srst_reboot_nb.notifier_call = sbi_srst_reboot;
687688
sbi_srst_reboot_nb.priority = 192;
688689
register_restart_handler(&sbi_srst_reboot_nb);
@@ -702,4 +703,7 @@ void __init sbi_init(void)
702703
__sbi_send_ipi = __sbi_send_ipi_v01;
703704
__sbi_rfence = __sbi_rfence_v01;
704705
}
706+
707+
if (!srst_power_off)
708+
sbi_set_power_off();
705709
}

0 commit comments

Comments
 (0)