From: Mark Rutland <mark.rutland@arm.com>
To: Krzysztof Adamski <krzysztof.adamski@nokia.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Peter Collingbourne <pcc@google.com>,
Guenter Roeck <linux@roeck-us.net>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
Alexander Sverdlin <alexander.sverdlin@nokia.com>,
Matija Glavinic-Pecotic <matija.glavinic-pecotic.ext@nokia.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] arm64: move efi_reboot to restart handler
Date: Fri, 28 Jan 2022 16:01:41 +0000 [thread overview]
Message-ID: <YfQTZTUNaeGi+8tG@FVFF77S0Q05N> (raw)
In-Reply-To: <YfP0osb45uJldtM9@localhost.localdomain>
On Fri, Jan 28, 2022 at 02:50:26PM +0100, Krzysztof Adamski wrote:
> On EFI enabled arm64 systems, efi_reboot was called before
> do_kernel_restart, completely omitting the reset_handlers functionality.
As I pointed out before, per the EFI spec we *need* to do this before any other
restart mechanism so that anything which EFI ties to the restart actually
occurs as expected -- e.g. UpdateCapsule(), as the comment says.
AFAICT, either:
* The other restart handlers have lower priority, in which case they'll be
called after this anyway, and in such cases this patch is not necessary.
* At least one other restart handler has higher priority, and the EFI restart
isn't actually used, and so any functionaltiy tied to the EFI restart will
not work on that machine.
> By registering efi_reboot as part of the chain with slightly elevated
> priority, we make it run before the default handler but still allow
> plugging in other handlers.
> Thanks to that, things like gpio_restart, restart handlers in
> watchdog_core, mmc or mtds are working on those platforms.
On which platforms is it necessary that these are used in preference to the EFI
restart? Can you please give a specific example?
If there's a specific platform that needs this, then we should call that out
and explain why the EFI restart isn't actually required on that (or if it is,
and functionality is broken, why that's acceptable).
Otherwise this patch is making this logic more complicated *and* making it
possible to have problems which we avoid by construction today, without any
actual benefit.
Thanks,
Mark.
> The priority 130 is one higher than PSCI, to overrule that but still
> allow to easily register higher prio handlers, if needed.
>
> Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com>
> ---
>
> Changes in v2:
> - Register the handler in EFI code, instead of arm64 setup.c
> - Remove the contdition from the handler - it should be run in all
> cases when it is registered
> - Bump the priority to 130 to make it completly obious this should be
> run before PSCI (which has priority of 129)
>
> arch/arm64/kernel/process.c | 7 -------
> drivers/firmware/efi/arm-runtime.c | 21 +++++++++++++++++++++
> 2 files changed, 21 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
> index 5369e649fa79..b86ef77bb0c8 100644
> --- a/arch/arm64/kernel/process.c
> +++ b/arch/arm64/kernel/process.c
> @@ -130,13 +130,6 @@ void machine_restart(char *cmd)
> local_irq_disable();
> smp_send_stop();
>
> - /*
> - * UpdateCapsule() depends on the system being reset via
> - * ResetSystem().
> - */
> - if (efi_enabled(EFI_RUNTIME_SERVICES))
> - efi_reboot(reboot_mode, NULL);
> -
> /* Now call the architecture specific reboot code. */
> do_kernel_restart(cmd);
>
> diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c
> index 3359ae2adf24..b9a2cdbe80b4 100644
> --- a/drivers/firmware/efi/arm-runtime.c
> +++ b/drivers/firmware/efi/arm-runtime.c
> @@ -80,6 +80,24 @@ static bool __init efi_virtmap_init(void)
> return true;
> }
>
> +static int efi_restart(struct notifier_block *nb, unsigned long action,
> + void *data)
> +{
> + /*
> + * UpdateCapsule() depends on the system being reset via
> + * ResetSystem().
> + */
> + efi_reboot(reboot_mode, NULL);
> +
> + return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block efi_restart_nb = {
> + .notifier_call = efi_restart,
> + /* We want this to take priority over PSCI which has priority of 129. */
> + .priority = 130,
> +};
> +
> /*
> * Enable the UEFI Runtime Services if all prerequisites are in place, i.e.,
> * non-early mapping of the UEFI system table and virtual mappings for all
> @@ -148,6 +166,9 @@ static int __init arm_enable_runtime_services(void)
> efi_native_runtime_setup();
> set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
>
> + if (IS_ENABLED(CONFIG_ARM64))
> + register_restart_handler(&efi_restart_nb);
> +
> return 0;
> }
> early_initcall(arm_enable_runtime_services);
> --
> 2.34.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-01-28 16:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-28 13:50 [PATCH v2] arm64: move efi_reboot to restart handler Krzysztof Adamski
2022-01-28 14:21 ` Alexander Sverdlin
2022-01-28 15:14 ` Guenter Roeck
2022-01-28 16:01 ` Mark Rutland [this message]
2022-01-28 22:05 ` Krzysztof Adamski
2022-02-01 13:58 ` Mark Rutland
2022-02-02 12:40 ` Krzysztof Adamski
2022-02-02 14:01 ` Ard Biesheuvel
2022-02-02 16:47 ` Krzysztof Adamski
2022-02-02 17:52 ` Krzysztof Adamski
2022-02-15 8:44 ` Alexander Sverdlin
2022-02-15 8:44 ` Alexander Sverdlin
2022-02-15 14:30 ` Guenter Roeck
2022-02-15 15:01 ` Krzysztof Adamski
2022-02-15 16:57 ` Guenter Roeck
2022-02-15 17:03 ` Ard Biesheuvel
2022-02-16 9:11 ` Krzysztof Adamski
2022-01-28 19:29 ` Wolfram Sang
2022-01-28 22:32 ` Krzysztof Adamski
2022-01-29 6:38 ` Wolfram Sang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YfQTZTUNaeGi+8tG@FVFF77S0Q05N \
--to=mark.rutland@arm.com \
--cc=alexander.sverdlin@nokia.com \
--cc=catalin.marinas@arm.com \
--cc=krzysztof.adamski@nokia.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=matija.glavinic-pecotic.ext@nokia.com \
--cc=pcc@google.com \
--cc=will@kernel.org \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox