Re: [PATCH v2] arm64: move efi_reboot to restart handler

From: Krzysztof Adamski
Date: Wed Feb 02 2022 - 12:52:23 EST


Dnia Wed, Feb 02, 2022 at 05:47:33PM +0100, Krzysztof Adamski napisał(a):
Dnia Wed, Feb 02, 2022 at 03:01:37PM +0100, Ard Biesheuvel napisał(a):
On Wed, 2 Feb 2022 at 13:41, Krzysztof Adamski
<krzysztof.adamski@xxxxxxxxx> wrote:

Dnia Tue, Feb 01, 2022 at 01:58:29PM +0000, Mark Rutland napisał(a):
If we use the restart handlers only to reset the system, this is indeed
true. But technically, restart handlers support the scenario where the
handler does some action that does not do reset of the whole system and
passes the control further down the chain, eventually reaching a handler
that will reset the whole system.
This can be done on non-uefi systems without problems but it doesn't
work on UEFI bases arm64 systems and this is a problem for us.

In other words, I would like to be able to run a restart handler on EFI
based ARM64 systems, just like I can on other systems, just for its
"side effects", not to do the actual reboot. Current code disables this
possibility on an ARM64 EFI system.

It sounds like two things are being conflated here:

1) A *notification* that a restart will subsequently occur.
2) A *request* to initiate a restart.

IIUC (1) is supposed to be handled by the existing reboot notifier mechanism
(see the reboot_notifier_list) which *is* invoked prior to the EFI reboot
today.

IMO, using restart handlers as notifiers is an abuse of the interface, and
that's the fundamental problem.

What am I missing?

You are completly right. It is possible that I would like to be able to
*abuse* the restart handlers as notifier. You are right that we have a
reboot_notifier but it is not good enough for my usecase - it is only
called, well, on reboot. It is not called in case of emergency_restart()
so in case of a panic, this won't happen. It also is called much earlier
than restart handlers which also makes a difference in some cases. So I
see no other choice than to abuse the restart_handler mechanism for that.


Why would such a platform implement ResetSystem() in the first place
if it cannot be used?

So the right solution here is for the firmware to publish a
EFI_RT_PROPERTIES_TABLE that describes ResetSystem() as unsupported,
and Linux will happily disregard it and try something else.

The firmware is generic but the problem is specific to one usecase of
such a platform. In other words, the firmware is written for the SoC and
it does not know about other parts on the board, outside of SoC. It
doesn't make much sense to provide the support for such custom device in
the firmware.

Please also note that the ResetSystem is supported. As I said, the
normal, typical reset is done via EFI, via ResetSystem. Ony if you have
a special case, where not only SoC, but also some other components in
the system have to be reset, then you want to change the reset type.

We also have one case of abusing the restart_handler as restart notifier
in the kernel in the form of drivers/mmc/core/pwrseq_emmc.c. I would
just like to be able to do this also on EFI based ARM64 systems. Is that
crazy? :)

Sorry, I forgot to mention another argument - doing that in the firmware
is SoC specific while doing that in the kernel is platform agnostic. We
use the same code on different platforms, architectures, etc.

Now, I don't understand why it is sane to have this functionality on
other archs, when we use PSCI or whatever else reset mechanism, but it
isn't if we use EFI.

For the notification purpose, we acknowledge it might be beneficial to
notify some code about the reboot (this is why we have the
reboot_notifier functionality) but having such a notifier on reset,
instead of reboot (i.e. at the end of the whole process and at all
possible cases where we reset our machine), seems strange. I don't get
it.

Krzysztof