* [PATCH 1/2] riscv: efi: Power off via EFI runtime services when available
2026-06-15 23:28 [PATCH 0/2] riscv: Use EFI runtime services for poweroff and restart Atish Patra
@ 2026-06-15 23:28 ` Atish Patra
2026-06-16 4:29 ` Sunil V L
2026-06-15 23:28 ` [PATCH 2/2] riscv: Restart " Atish Patra
2026-06-25 20:14 ` [PATCH 0/2] riscv: Use EFI runtime services for poweroff and restart Paul Walmsley
2 siblings, 1 reply; 6+ messages in thread
From: Atish Patra @ 2026-06-15 23:28 UTC (permalink / raw)
To: Ard Biesheuvel, Ilias Apalodimas, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Alexandre Ghiti, Atish Patra
Cc: linux-efi, linux-riscv, linux-kernel, Atish Patra
From: Atish Patra <atishp@meta.com>
When booted via UEFI with runtime services enabled, EFI Reset Shutdown is
the firmware-preferred shutdown path: it lets firmware run its own
shutdown hooks which may invoke SBI SRST extension internally. However,
RISC-V always powers off via the SBI SRST extension today and EFI runtime
path is never used even when firmware provides it.
Enable the poweroff via EFI by overriding efi_poweroff_required()
Signed-off-by: Atish Patra <atishp@meta.com>
---
arch/riscv/kernel/efi.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/riscv/kernel/efi.c b/arch/riscv/kernel/efi.c
index b64bf1624a05..2d3cc57b4535 100644
--- a/arch/riscv/kernel/efi.c
+++ b/arch/riscv/kernel/efi.c
@@ -95,3 +95,8 @@ int __init efi_set_mapping_permissions(struct mm_struct *mm,
md->num_pages << EFI_PAGE_SHIFT,
set_permissions, md);
}
+
+bool efi_poweroff_required(void)
+{
+ return efi_enabled(EFI_RUNTIME_SERVICES);
+}
--
2.53.0-Meta
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 1/2] riscv: efi: Power off via EFI runtime services when available
2026-06-15 23:28 ` [PATCH 1/2] riscv: efi: Power off via EFI runtime services when available Atish Patra
@ 2026-06-16 4:29 ` Sunil V L
0 siblings, 0 replies; 6+ messages in thread
From: Sunil V L @ 2026-06-16 4:29 UTC (permalink / raw)
To: Atish Patra
Cc: Ard Biesheuvel, Ilias Apalodimas, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Alexandre Ghiti, linux-efi, linux-riscv, linux-kernel,
Atish Patra
On Tue, Jun 16, 2026 at 4:59 AM Atish Patra <atish.patra@linux.dev> wrote:
>
> From: Atish Patra <atishp@meta.com>
>
> When booted via UEFI with runtime services enabled, EFI Reset Shutdown is
> the firmware-preferred shutdown path: it lets firmware run its own
> shutdown hooks which may invoke SBI SRST extension internally. However,
> RISC-V always powers off via the SBI SRST extension today and EFI runtime
> path is never used even when firmware provides it.
>
> Enable the poweroff via EFI by overriding efi_poweroff_required()
>
> Signed-off-by: Atish Patra <atishp@meta.com>
> ---
> arch/riscv/kernel/efi.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/arch/riscv/kernel/efi.c b/arch/riscv/kernel/efi.c
> index b64bf1624a05..2d3cc57b4535 100644
> --- a/arch/riscv/kernel/efi.c
> +++ b/arch/riscv/kernel/efi.c
> @@ -95,3 +95,8 @@ int __init efi_set_mapping_permissions(struct mm_struct *mm,
> md->num_pages << EFI_PAGE_SHIFT,
> set_permissions, md);
> }
> +
> +bool efi_poweroff_required(void)
> +{
> + return efi_enabled(EFI_RUNTIME_SERVICES);
> +}
>
Reviewed-by: Sunil V L <sunilvl@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] riscv: Restart via EFI runtime services when available
2026-06-15 23:28 [PATCH 0/2] riscv: Use EFI runtime services for poweroff and restart Atish Patra
2026-06-15 23:28 ` [PATCH 1/2] riscv: efi: Power off via EFI runtime services when available Atish Patra
@ 2026-06-15 23:28 ` Atish Patra
2026-06-16 4:29 ` Sunil V L
2026-06-25 20:14 ` [PATCH 0/2] riscv: Use EFI runtime services for poweroff and restart Paul Walmsley
2 siblings, 1 reply; 6+ messages in thread
From: Atish Patra @ 2026-06-15 23:28 UTC (permalink / raw)
To: Ard Biesheuvel, Ilias Apalodimas, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Alexandre Ghiti, Atish Patra
Cc: linux-efi, linux-riscv, linux-kernel, Atish Patra
From: Atish Patra <atishp@meta.com>
Firmware-preferred reset and EFI capsule update support requires reset
via EFI runtime services rather than direction M-mode firmware invocation
via SBI. Unlike poweroff, restart mechanism is directly controlled from
machine_restart function though.
Prefer the EFI runtime ResetSystem() service for restart when UEFI
runtime services are available.
Signed-off-by: Atish Patra <atishp@meta.com>
---
arch/riscv/kernel/reset.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/riscv/kernel/reset.c b/arch/riscv/kernel/reset.c
index 912288572226..541e2162c85a 100644
--- a/arch/riscv/kernel/reset.c
+++ b/arch/riscv/kernel/reset.c
@@ -3,6 +3,7 @@
* Copyright (C) 2012 Regents of the University of California
*/
+#include <linux/efi.h>
#include <linux/reboot.h>
#include <linux/pm.h>
@@ -17,6 +18,12 @@ EXPORT_SYMBOL(pm_power_off);
void machine_restart(char *cmd)
{
+ /*
+ * UpdateCapsule() depends on the system being reset via ResetSystem().
+ */
+ if (efi_enabled(EFI_RUNTIME_SERVICES))
+ efi_reboot(reboot_mode, NULL);
+
do_kernel_restart(cmd);
while (1);
}
--
2.53.0-Meta
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 2/2] riscv: Restart via EFI runtime services when available
2026-06-15 23:28 ` [PATCH 2/2] riscv: Restart " Atish Patra
@ 2026-06-16 4:29 ` Sunil V L
0 siblings, 0 replies; 6+ messages in thread
From: Sunil V L @ 2026-06-16 4:29 UTC (permalink / raw)
To: Atish Patra
Cc: Ard Biesheuvel, Ilias Apalodimas, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Alexandre Ghiti, linux-efi, linux-riscv, linux-kernel,
Atish Patra
On Tue, Jun 16, 2026 at 4:59 AM Atish Patra <atish.patra@linux.dev> wrote:
>
> From: Atish Patra <atishp@meta.com>
>
> Firmware-preferred reset and EFI capsule update support requires reset
> via EFI runtime services rather than direction M-mode firmware invocation
> via SBI. Unlike poweroff, restart mechanism is directly controlled from
> machine_restart function though.
>
> Prefer the EFI runtime ResetSystem() service for restart when UEFI
> runtime services are available.
>
> Signed-off-by: Atish Patra <atishp@meta.com>
> ---
> arch/riscv/kernel/reset.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/arch/riscv/kernel/reset.c b/arch/riscv/kernel/reset.c
> index 912288572226..541e2162c85a 100644
> --- a/arch/riscv/kernel/reset.c
> +++ b/arch/riscv/kernel/reset.c
> @@ -3,6 +3,7 @@
> * Copyright (C) 2012 Regents of the University of California
> */
>
> +#include <linux/efi.h>
> #include <linux/reboot.h>
> #include <linux/pm.h>
>
> @@ -17,6 +18,12 @@ EXPORT_SYMBOL(pm_power_off);
>
> void machine_restart(char *cmd)
> {
> + /*
> + * UpdateCapsule() depends on the system being reset via ResetSystem().
> + */
> + if (efi_enabled(EFI_RUNTIME_SERVICES))
> + efi_reboot(reboot_mode, NULL);
> +
> do_kernel_restart(cmd);
> while (1);
> }
>
LGTM.
Reviewed-by: Sunil V L <sunilvl@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] riscv: Use EFI runtime services for poweroff and restart
2026-06-15 23:28 [PATCH 0/2] riscv: Use EFI runtime services for poweroff and restart Atish Patra
2026-06-15 23:28 ` [PATCH 1/2] riscv: efi: Power off via EFI runtime services when available Atish Patra
2026-06-15 23:28 ` [PATCH 2/2] riscv: Restart " Atish Patra
@ 2026-06-25 20:14 ` Paul Walmsley
2 siblings, 0 replies; 6+ messages in thread
From: Paul Walmsley @ 2026-06-25 20:14 UTC (permalink / raw)
To: Atish Patra
Cc: Ard Biesheuvel, Ilias Apalodimas, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Alexandre Ghiti, linux-efi, linux-riscv, linux-kernel,
Atish Patra
On Mon, 15 Jun 2026, Atish Patra wrote:
> Today RISC-V always uses the SBI SRST extension for both poweroff and restart,
> even when UEFI runtime services are available. This series makes RISC-V prefer
> EFI runtime services for both paths when available. The reset via EFI is
> required for EFI capsule updates and also documented as a preferred method
> in BRS 1.0 spec (e.g. URT_030)[1]
>
> Behavior on SBI-only (non-EFI) systems is unchanged.
>
> Tested under QEMU 'virt' with EDK2/UEFI firmware exposing runtime
> ResetSystem().
>
> [1] https://docs.riscv.org/reference/brs/uefi.html#uefi
>
> Signed-off-by: Atish Patra <atishp@meta.com>
Thanks, queued for v7.3.
- Paul
^ permalink raw reply [flat|nested] 6+ messages in thread