From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>,
Andrew Morton <akpm@linux-foundation.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Fabio Estevam <festevam@denx.de>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>,
Jonathan Corbet <corbet@lwn.net>, Serge Hallyn <serge@hallyn.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Benson Leung <bleung@chromium.org>,
Tzung-Bi Shih <tzungbi@kernel.org>,
Guenter Roeck <groeck@chromium.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
linux-doc@vger.kernel.org, linux-security-module@vger.kernel.org,
chrome-platform@lists.linux.dev, devicetree@vger.kernel.org,
kernel@pengutronix.de
Subject: Re: [PATCH v2 02/12] reboot: reboot, not shutdown, on hw_protection_reboot timeout
Date: Tue, 18 Feb 2025 08:45:22 +0200 [thread overview]
Message-ID: <48b3e732-b60d-411c-a519-5e89f87eea7d@gmail.com> (raw)
In-Reply-To: <de781a07-d209-4bbe-8945-efcb4490f604@pengutronix.de>
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@pengutronix.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@gmail.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
next prev parent reply other threads:[~2025-02-18 6:45 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 16:25 [PATCH v2 00/12] reboot: support runtime configuration of emergency hw_protection action Ahmad Fatoum
2025-01-13 16:25 ` [PATCH v2 01/12] reboot: replace __hw_protection_shutdown bool action parameter with an enum Ahmad Fatoum
2025-01-20 7:10 ` Tzung-Bi Shih
2025-01-21 9:27 ` Ahmad Fatoum
2025-01-13 16:25 ` [PATCH v2 02/12] reboot: reboot, not shutdown, on hw_protection_reboot timeout Ahmad Fatoum
2025-01-20 7:10 ` Tzung-Bi Shih
2025-01-22 11:28 ` Matti Vaittinen
2025-02-17 20:22 ` Ahmad Fatoum
2025-02-18 6:45 ` Matti Vaittinen [this message]
2025-01-13 16:25 ` [PATCH v2 03/12] docs: thermal: sync hardware protection doc with code Ahmad Fatoum
2025-01-20 7:11 ` Tzung-Bi Shih
2025-01-21 9:29 ` Ahmad Fatoum
2025-01-22 11:01 ` Matti Vaittinen
2025-01-13 16:25 ` [PATCH v2 04/12] reboot: describe do_kernel_restart's cmd argument in kernel-doc Ahmad Fatoum
2025-01-20 7:11 ` Tzung-Bi Shih
2025-01-13 16:25 ` [PATCH v2 05/12] reboot: rename now misleading __hw_protection_shutdown symbols Ahmad Fatoum
2025-01-20 7:11 ` Tzung-Bi Shih
2025-01-13 16:25 ` [PATCH v2 06/12] reboot: indicate whether it is a HARDWARE PROTECTION reboot or shutdown Ahmad Fatoum
2025-01-20 7:11 ` Tzung-Bi Shih
2025-01-13 16:25 ` [PATCH v2 07/12] reboot: add support for configuring emergency hardware protection action Ahmad Fatoum
2025-01-20 7:12 ` Tzung-Bi Shih
2025-01-21 9:35 ` Ahmad Fatoum
2025-01-13 16:25 ` [PATCH v2 08/12] regulator: allow user configuration of " Ahmad Fatoum
2025-01-20 7:12 ` Tzung-Bi Shih
2025-01-22 11:18 ` Matti Vaittinen
2025-01-13 16:25 ` [PATCH v2 09/12] platform/chrome: cros_ec_lpc: prepare for hw_protection_shutdown removal Ahmad Fatoum
2025-01-20 7:12 ` Tzung-Bi Shih
2025-01-13 16:25 ` [PATCH v2 10/12] dt-bindings: thermal: give OS some leeway in absence of critical-action Ahmad Fatoum
2025-01-13 16:25 ` [PATCH v2 11/12] thermal: core: allow user configuration of hardware protection action Ahmad Fatoum
2025-01-20 7:12 ` Tzung-Bi Shih
2025-01-13 16:25 ` [PATCH v2 12/12] reboot: retire hw_protection_reboot and hw_protection_shutdown helpers Ahmad Fatoum
2025-01-20 7:13 ` Tzung-Bi Shih
2025-01-14 0:33 ` [PATCH v2 00/12] reboot: support runtime configuration of emergency hw_protection action Andrew Morton
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=48b3e732-b60d-411c-a519-5e89f87eea7d@gmail.com \
--to=mazziesaccount@gmail.com \
--cc=a.fatoum@pengutronix.de \
--cc=akpm@linux-foundation.org \
--cc=bleung@chromium.org \
--cc=broonie@kernel.org \
--cc=chrome-platform@lists.linux.dev \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=daniel.lezcano@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@denx.de \
--cc=groeck@chromium.org \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rui.zhang@intel.com \
--cc=serge@hallyn.com \
--cc=tzungbi@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).