[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <48b3e732-b60d-411c-a519-5e89f87eea7d@gmail.com>
Date: Tue, 18 Feb 2025 08:45:22 +0200
From: Matti Vaittinen <mazziesaccount@...il.com>
To: Ahmad Fatoum <a.fatoum@...gutronix.de>,
Andrew Morton <akpm@...ux-foundation.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>, Fabio Estevam
<festevam@...x.de>, "Rafael J. Wysocki" <rafael@...nel.org>,
Zhang Rui <rui.zhang@...el.com>, Lukasz Luba <lukasz.luba@....com>,
Jonathan Corbet <corbet@....net>, Serge Hallyn <serge@...lyn.com>,
Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
Benson Leung <bleung@...omium.org>, Tzung-Bi Shih <tzungbi@...nel.org>,
Guenter Roeck <groeck@...omium.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org,
linux-doc@...r.kernel.org, linux-security-module@...r.kernel.org,
chrome-platform@...ts.linux.dev, devicetree@...r.kernel.org,
kernel@...gutronix.de
Subject: Re: [PATCH v2 02/12] reboot: reboot, not shutdown, on
hw_protection_reboot timeout
On 17/02/2025 22:22, Ahmad Fatoum wrote:
> Hello Matti,
>
> On 22.01.25 12:28, Matti Vaittinen wrote:
>> On 13/01/2025 18:25, Ahmad Fatoum wrote:
>>> hw_protection_shutdown() will kick off an orderly shutdown and if that
>>> takes longer than a configurable amount of time, an emergency shutdown
>>> will occur.
>>>
>>> Recently, hw_protection_reboot() was added for those systems that don't
>>> implement a proper shutdown and are better served by rebooting and
>>> having the boot firmware worry about doing something about the critical
>>> condition.
>>>
>>> On timeout of the orderly reboot of hw_protection_reboot(), the system
>>> would go into shutdown, instead of reboot. This is not a good idea, as
>>> going into shutdown was explicitly not asked for.
>>>
>>> Fix this by always doing an emergency reboot if hw_protection_reboot()
>>> is called and the orderly reboot takes too long.
>>>
>>> Fixes: 79fa723ba84c ("reboot: Introduce thermal_zone_device_critical_reboot()")
>>> Signed-off-by: Ahmad Fatoum <a.fatoum@...gutronix.de>
>>> ---
>>> kernel/reboot.c | 70 ++++++++++++++++++++++++++++++++++++++++-----------------
>>> 1 file changed, 49 insertions(+), 21 deletions(-)
>>>
>>> diff --git a/kernel/reboot.c b/kernel/reboot.c
>>> index 847ac5d17a659981c6765699eac323f5e87f48c1..222b63dfd31020d0e2bc1b1402dbfa82adc71990 100644
>>> --- a/kernel/reboot.c
>>> +++ b/kernel/reboot.c
>>> @@ -932,48 +932,76 @@ void orderly_reboot(void)
>>> }
>>> EXPORT_SYMBOL_GPL(orderly_reboot);
>>> +static const char *hw_protection_action_str(enum hw_protection_action action)
>>> +{
>>> + switch (action) {
>>> + case HWPROT_ACT_SHUTDOWN:
>>> + return "shutdown";
>>> + case HWPROT_ACT_REBOOT:
>>> + return "reboot";
>>> + default:
>>> + return "undefined";
>>> + }
>>> +}
>>> +
>>> +static enum hw_protection_action hw_failure_emergency_action;
>>
>> nit: Do we have a (theoretical) possibility that two emergency restarts get scheduled with different actions? Should the action be allocated (maybe not) for each caller, or should there be a check if an operation with conflicting action is already scheduled?
>>
>> If this was already considered and thought it is not an issue:
>>
>> Reviewed-by: Matti Vaittinen <mazziesaccount@...il.com>
>
> __hw_protection_trigger (née __hw_protection_shutdown) has this at its start:
>
> static atomic_t allow_proceed = ATOMIC_INIT(1);
>
> /* Shutdown should be initiated only once. */
> if (!atomic_dec_and_test(&allow_proceed))
> return;
>
> It's thus not possible to have a later emergency restart race against the first.
>
Ah, indeed. I missed this. Thanks for the clarification! :)
Yours,
-- Matti
Powered by blists - more mailing lists