Dnia Tue, Feb 15, 2022 at 06:30:26AM -0800, Guenter Roeck napisał(a):
On 2/15/22 00:44, Alexander Sverdlin wrote:
Hello Mark, Ard,
On 01/02/2022 14:58, Mark Rutland wrote:
You could argue that restart handlers were not created for that but they
suit this purpose ideally and it wouldn't make much sense (in my
opinion) to add yet another notifier chain that would run before reset
notifiers, for code that is not supposed to reset the whole system and
this is exacly what I would have to do if efi_reboot() is forced to be
called before all handlers.
As above, I think that's just using the wrong interface, and the reboot
notifier mechanism *already* exists, so I'm really confused here.
Have I misunderstood what you're trying to achieve?
Is there some problem with the reboot notifier mechanism that I am unaware of?
e.g. do we bypass them in some case where you think they're needed?
Are you simply unaware of reboot notifiers?
Could you please check the simple case of pwrseq_emmc.c?
While that's currently the only example of this kind upstream I can imagine
further use-cases, especially in storage area like above.
Would you suggest it's illegal usage of register_restart_handler()?
Do we need to fix pwrseq_emmc.c by introducing new atomic notifier chain
which will be called before restart handlers, so that it works on
emergency_restart()?
Abuse isn't just about using an API for something it isn't originally intended
for, abuse is also to intentionally _not_ use an API, as it is currently done
by the EFI restart code for arm64. Also, keep in mind that the same argument
(our restart handler _must_ be executed under all circumstances and does therefore
not use the restart API) is likely going to be used again in the future. All
it takes is for some other standard (or chip vendor, for that matter) to declare
their restart handler mandatory if present.
Wait, but it is up to us to decide if we want to follow such standard or
not. If we want to have code that is more flexible, nobody can refuse us
to do so, right? None of the standards says that we can't support
restart handlers in case of EFI on ARM64, it was decided by kernel
developers, not some vendors. We can change that.
Given that, I'd suggest to cut your losses and try to find another
solution for your problem. That may be to introduce yet another API,
one that is called before the EFI restart handling but that is always
called, unlike reboot notifiers, or simply stick with out-of-tree code.
Sure I could create yet another API like you suggest but in practice it
would be a copy of existing API as i would have to work exactly the
same - would be called at the same time in the same situations. The only
thing that would be different would be separate chain.
But if we want to prevent registering some custom code to be run before
efi_reboot(), that new API would have to be rejected as well, for the
same reason. So what is the point?
Krzysztof