* [PATCH] riscv: sbi: Prefer SRST shutdown over legacy
@ 2025-11-14 6:58 Mayuresh Chitale
2025-11-14 10:58 ` Anup Patel
2025-11-17 8:10 ` patchwork-bot+linux-riscv
0 siblings, 2 replies; 3+ messages in thread
From: Mayuresh Chitale @ 2025-11-14 6:58 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Atish Patra, Andrew Jones, Clément Léger, Andrew Davis
Cc: Mayuresh Chitale, linux-riscv, linux-kernel
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>
---
arch/riscv/kernel/sbi.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
index 5e8cde055264..c443337056ab 100644
--- a/arch/riscv/kernel/sbi.c
+++ b/arch/riscv/kernel/sbi.c
@@ -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();
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] riscv: sbi: Prefer SRST shutdown over legacy
2025-11-14 6:58 [PATCH] riscv: sbi: Prefer SRST shutdown over legacy Mayuresh Chitale
@ 2025-11-14 10:58 ` Anup Patel
2025-11-17 8:10 ` patchwork-bot+linux-riscv
1 sibling, 0 replies; 3+ messages in thread
From: Anup Patel @ 2025-11-14 10:58 UTC (permalink / raw)
To: Mayuresh Chitale
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Atish Patra, Andrew Jones, Clément Léger, Andrew Davis,
linux-riscv, linux-kernel
On Fri, Nov 14, 2025 at 12:29 PM Mayuresh Chitale
<mchitale@ventanamicro.com> wrote:
>
> 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>
LGTM.
Reviewed-by: Anup Patel <anup@brainfault.org>
Regards,
Anup
> ---
> arch/riscv/kernel/sbi.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
> index 5e8cde055264..c443337056ab 100644
> --- a/arch/riscv/kernel/sbi.c
> +++ b/arch/riscv/kernel/sbi.c
> @@ -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();
> }
> --
> 2.43.0
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] riscv: sbi: Prefer SRST shutdown over legacy
2025-11-14 6:58 [PATCH] riscv: sbi: Prefer SRST shutdown over legacy Mayuresh Chitale
2025-11-14 10:58 ` Anup Patel
@ 2025-11-17 8:10 ` patchwork-bot+linux-riscv
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+linux-riscv @ 2025-11-17 8:10 UTC (permalink / raw)
To: Mayuresh Chitale
Cc: linux-riscv, pjw, palmer, aou, alex, atishp, ajones, cleger, afd,
linux-kernel
Hello:
This patch was applied to riscv/linux.git (fixes)
by Paul Walmsley <pjw@kernel.org>:
On Fri, 14 Nov 2025 06:58:06 +0000 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- riscv: sbi: Prefer SRST shutdown over legacy
https://git.kernel.org/riscv/c/7b090e7b910c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-17 8:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-14 6:58 [PATCH] riscv: sbi: Prefer SRST shutdown over legacy Mayuresh Chitale
2025-11-14 10:58 ` Anup Patel
2025-11-17 8:10 ` patchwork-bot+linux-riscv
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox