]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
riscv: sbi: Prefer SRST shutdown over legacy
authorMayuresh Chitale <mchitale@ventanamicro.com>
Fri, 14 Nov 2025 06:58:06 +0000 (06:58 +0000)
committerPaul Walmsley <pjw@kernel.org>
Sun, 16 Nov 2025 17:37:27 +0000 (10:37 -0700)
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: 70ddf86d76c1 ("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>
arch/riscv/kernel/sbi.c

index 5e8cde055264351c0877f6bc4e647bcb6643f40d..c443337056ab7d07b6d17febf8b7589de3349e30 100644 (file)
@@ -648,9 +648,9 @@ int sbi_debug_console_read(char *bytes, unsigned int num_bytes)
 
 void __init sbi_init(void)
 {
+       bool srst_power_off = false;
        int ret;
 
-       sbi_set_power_off();
        ret = sbi_get_spec_version();
        if (ret > 0)
                sbi_spec_version = ret;
@@ -683,6 +683,7 @@ void __init sbi_init(void)
                    sbi_probe_extension(SBI_EXT_SRST)) {
                        pr_info("SBI SRST extension detected\n");
                        register_platform_power_off(sbi_srst_power_off);
+                       srst_power_off = true;
                        sbi_srst_reboot_nb.notifier_call = sbi_srst_reboot;
                        sbi_srst_reboot_nb.priority = 192;
                        register_restart_handler(&sbi_srst_reboot_nb);
@@ -702,4 +703,7 @@ void __init sbi_init(void)
                __sbi_send_ipi  = __sbi_send_ipi_v01;
                __sbi_rfence    = __sbi_rfence_v01;
        }
+
+       if (!srst_power_off)
+               sbi_set_power_off();
 }