From: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
To: sashiko-reviews@lists.linux.dev
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, lee@kernel.org,
robh@kernel.org, mfd@lists.linux.dev
Subject: Re: [PATCH v25 03/10] firmware: psci: Introduce command-based resets
Date: Tue, 15 Sep 2026 19:32:30 +0530 [thread overview]
Message-ID: <0f5a8bf1-9ac4-4b0e-98cc-5bd833896413@oss.qualcomm.com> (raw)
In-Reply-To: <20260914151400.D99051F0089A@smtp.kernel.org>
On 9/14/2026 8:44 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] The restart handler `psci_sys_reset()` unintentionally skips configured reset commands for standard reboots due to checking if `data` is non-NULL.
> --
>
> commit 15791809d0deec27e24e64483b3317dacb5842a5
> Author: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
>
> firmware: psci: Introduce command-based resets
>
> This commit introduces a command-based reset mechanism allowing reboot-mode
> drivers to specify custom PSCI reset commands like vendor-specific
> SYSTEM_RESET2. It defaults to the existing reboot_mode flow unless a valid
> reset command is configured.
>
>> diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
>> index e73bae6cb23a3..d489ba5d147ce 100644
>> --- a/drivers/firmware/psci/psci.c
>> +++ b/drivers/firmware/psci/psci.c
>
> [ ... ]
>
>> @@ -320,6 +409,30 @@ static int psci_sys_reset(struct notifier_block *nb, unsigned long action,
>
> [ ... ]
>
>> +static int psci_sys_reset(struct notifier_block *nb, unsigned long action,
>> + void *data)
>> +{
>> + const struct psci_system_reset_cmd *cmd;
>> +
>> + /* The function psci_handle_reboot_mode follows reboot_mode based
>> + * reset flow and psci_handle_reset_cmd uses reset_cmd based reset flow.
>> + *
>> + * The reset_cmd is configured at the reboot_notifier phase.
>> + * If panic() or emergency_restart() occurs between the reboot_notifier
>> + * and this final reset, skip command-based reset and let reboot_mode drive
>> + * the reset flow.
>> + *
>> + * The function psci_handle_reset_cmd invokes non-returning PSCI SYSTEM_RESET
>> + * calls to reset the device. If it returns, either the reset failed, or the
>> + * command was unsupported. Fallback to reboot_mode based reset flow.
>> + */
>> + cmd = smp_load_acquire(&reset_cmd);
>> + if (data && cmd && !panic_in_progress())
>> + psci_handle_reset_cmd(cmd);
>
> [Severity: High]
> Will this check unintentionally skip custom reset commands during a standard
> reboot?
By design - Normal reboot with NULL command should go through regular
reboot flow of psci_sys_reset.
>
> When a standard userspace reboot is triggered via the reboot syscall with
> LINUX_REBOOT_CMD_RESTART, the reboot sequence ultimately calls
> kernel_restart(NULL).
>
> This propagates down to the atomic restart notifier chain in
> do_kernel_restart(NULL), which passes a NULL command pointer to the notifier
> handlers.
>
> In psci_sys_reset(), the data parameter receives this NULL pointer. Because
> of the check for a non-NULL data variable, the condition evaluates to false,
> causing the handler to skip psci_handle_reset_cmd().
Yes, do_kernel_restart(NULL) should take regular reboot flow and ignore
any pre-set commands.
> It then incorrectly
> falls back to psci_handle_reboot_mode(), even if a valid command was
> successfully configured by a reboot-mode driver.
>
> Is the data check acting contrary to the commit message's goal of ignoring
> reset commands during panic and emergency_restart?
>
If the commit message is not clear, i can add a line to it, stating the
same.
thanks,
Shivendra
next prev parent reply other threads:[~2026-09-15 14:02 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 14:59 [PATCH v25 00/10] Implement PSCI reboot mode driver for PSCI resets Shivendra Pratap
2026-09-14 14:59 ` [PATCH v25 01/10] power: reset: reboot-mode: Support up to 3 magic values per mode Shivendra Pratap
2026-09-14 15:09 ` sashiko-bot
2026-09-14 14:59 ` [PATCH v25 02/10] power: reset: reboot-mode: Add support for predefined reboot modes Shivendra Pratap
2026-09-14 15:12 ` sashiko-bot
2026-09-15 13:54 ` Shivendra Pratap
2026-09-14 14:59 ` [PATCH v25 03/10] firmware: psci: Introduce command-based resets Shivendra Pratap
2026-09-14 15:14 ` sashiko-bot
2026-09-15 14:02 ` Shivendra Pratap [this message]
2026-09-15 14:05 ` Shivendra Pratap
2026-09-14 14:59 ` [PATCH v25 04/10] firmware: psci: Add support for PSCI auxiliary devices Shivendra Pratap
2026-09-14 15:21 ` sashiko-bot
2026-09-16 9:29 ` Bartosz Golaszewski
2026-09-17 12:18 ` Shivendra Pratap
2026-09-21 15:06 ` Ulf Hansson
2026-09-23 11:25 ` Shivendra Pratap
2026-09-14 14:59 ` [PATCH v25 05/10] dt-bindings: arm: Document reboot mode magic Shivendra Pratap
2026-09-14 15:19 ` sashiko-bot
2026-09-18 22:06 ` Rob Herring
2026-09-21 10:29 ` Shivendra Pratap
2026-09-21 18:41 ` Rob Herring
2026-09-14 14:59 ` [PATCH v25 06/10] power: reset: Add psci-reboot-mode driver Shivendra Pratap
2026-09-14 15:21 ` sashiko-bot
2026-09-16 9:23 ` Bartosz Golaszewski
2026-09-17 12:30 ` Shivendra Pratap
2026-09-14 14:59 ` [PATCH v25 07/10] arm64: dts: qcom: Add psci reboot-modes for kodiak boards Shivendra Pratap
2026-09-14 15:24 ` sashiko-bot
2026-09-14 14:59 ` [PATCH v25 08/10] arm64: dts: qcom: Add psci reboot-modes for lemans boards Shivendra Pratap
2026-09-14 15:28 ` sashiko-bot
2026-09-14 14:59 ` [PATCH v25 09/10] arm64: dts: qcom: Add psci reboot-modes for monaco boards Shivendra Pratap
2026-09-14 15:25 ` sashiko-bot
2026-09-14 14:59 ` [PATCH v25 10/10] arm64: dts: qcom: Add psci reboot-modes for talos boards Shivendra Pratap
2026-09-14 15:27 ` sashiko-bot
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=0f5a8bf1-9ac4-4b0e-98cc-5bd833896413@oss.qualcomm.com \
--to=shivendra.pratap@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lee@kernel.org \
--cc=mfd@lists.linux.dev \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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