From: sashiko-bot@kernel.org
To: "Shivendra Pratap" <shivendra.pratap@oss.qualcomm.com>
Cc: mfd@lists.linux.dev, devicetree@vger.kernel.org, robh@kernel.org,
conor+dt@kernel.org, lee@kernel.org
Subject: Re: [PATCH v23 07/13] power: reset: Add psci-reboot-mode driver
Date: Tue, 14 Jul 2026 17:30:37 +0000 [thread overview]
Message-ID: <20260714173038.50B121F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260714-arm-psci-system_reset2-vendor-reboots-v23-7-e7453c548c21@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The `psci-reboot-mode` platform driver is completely unreachable dead code because it lacks an `of_match_table` and is never instantiated as a child device by the parent PSCI or MFD driver.
- [High] Lockless read of `reset_cmd` in `psci_sys_reset()` can race with concurrent updates via `psci_set_reset_cmd()`.
- [Medium] The `PSCI_REBOOT_MODE` config is set to `bool`, which forces the `REBOOT_MODE` framework to be built-in.
--
--- Patch [7]: [PATCH v23 07/13] power: reset: Add psci-reboot-mode driver ---
commit 05cd2956034a357b1e7d5eab96bdce4575604285
Author: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
power: reset: Add psci-reboot-mode driver
Add a psci-reboot-mode driver to handle different types of PSCI resets,
including predefined and vendor-specific resets, at one place. It registers
with the reboot-mode framework to interface these resets to userspace and
passes arguments to the PSCI driver for command-based reset.
> diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
> index 124afb99febe9..93e4029d95060 100644
> --- a/drivers/power/reset/Kconfig
> +++ b/drivers/power/reset/Kconfig
> @@ -348,6 +348,16 @@ config NVMEM_REBOOT_MODE
> then the bootloader can read it and take different
> action according to the mode.
>
> +config PSCI_REBOOT_MODE
> + bool "PSCI reboot mode driver"
> + depends on OF && (ARM_PSCI_FW || COMPILE_TEST)
> + select REBOOT_MODE
[Severity: Medium]
Will this force the REBOOT_MODE framework to always be built-in?
Since PSCI_REBOOT_MODE is defined as a bool, selecting the REBOOT_MODE
tristate will forcefully upgrade the entire reboot-mode framework to built-in
(=y), which overrides user configurations that might prefer it as a module.
Also, since the driver source uses module_platform_driver and MODULE_LICENSE,
it appears designed to be built as a module. Should this be a tristate instead?
> + help
> + Say y here will enable PSCI reboot mode driver. This gets
> + the PSCI reboot mode arguments and passes them to psci
> + driver. psci driver uses these arguments for issuing
> + device reset into different boot states.
> +
> config POWER_MLXBF
> tristate "Mellanox BlueField power handling driver"
> depends on (GPIO_MLXBF2 || GPIO_MLXBF3) && ACPI
[ ... ]
> diff --git a/drivers/power/reset/psci-reboot-mode.c b/drivers/power/reset/psci-reboot-mode.c
> new file mode 100644
> index 0000000000000..955ed68f14026
> --- /dev/null
> +++ b/drivers/power/reset/psci-reboot-mode.c
[ ... ]
> +static int psci_reboot_mode_write(struct reboot_mode_driver *reboot,
> + u32 *magic, int count)
> +{
> + if (count < 1 || count > 3)
> + return -EINVAL;
> +
> + return psci_set_reset_cmd(magic[0], psci_reboot_mode_get_cookie(magic, count));
[Severity: High]
Can this call to psci_set_reset_cmd() race with the atomic restart handler?
Looking at drivers/firmware/psci/psci.c, psci_sys_reset() evaluates reset_cmd
locklessly:
if ((reset_cmd.reset_type || reset_cmd.cookie) && !panic_in_progress())
psci_handle_reset_cmd();
And psci_set_reset_cmd() protects writes using a mutex:
reset_cmd.reset_type = reset_type;
reset_cmd.cookie = cookie;
If an atomic restart handler like psci_sys_reset() executes during a SysRq-B
emergency restart and interrupts a CPU executing psci_set_reset_cmd(), it could
observe a partially updated state.
Since the 64-bit cookie may be written via multiple instructions on 32-bit ARM,
could this lead to torn reads and mismatched reset types, causing the system to
hang during emergency restarts?
> +}
[ ... ]
> +static struct platform_driver psci_reboot_mode_driver = {
> + .probe = psci_reboot_mode_probe,
> + .driver = {
> + .name = "psci-reboot-mode",
> + },
> +};
[Severity: High]
Is this platform driver able to probe?
The driver lacks an of_match_table and is not instantiated as a child device
by any parent PSCI or MFD driver.
A platform driver without an of_match_table must be manually instantiated
(e.g., via mfd_add_devices in an MFD parent like psci-mfd.c). However,
psci_reboot_mode is not listed in psci_cells in drivers/mfd/psci-mfd.c, nor
does any code call of_platform_populate() on the PSCI node.
Does this make the newly introduced psci-reboot-mode functionality unreachable
dead code?
> +module_platform_driver(psci_reboot_mode_driver);
> +
> +MODULE_DESCRIPTION("PSCI reboot mode driver");
> +MODULE_LICENSE("GPL");
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260714-arm-psci-system_reset2-vendor-reboots-v23-0-e7453c548c21@oss.qualcomm.com?part=7
next prev parent reply other threads:[~2026-07-14 17:30 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 17:16 [PATCH v23 00/13] Implement PSCI reboot mode driver for PSCI resets Shivendra Pratap
2026-07-14 17:16 ` [PATCH v23 01/13] power: reset: reboot-mode: Remove devres based allocations Shivendra Pratap
2026-07-14 17:29 ` sashiko-bot
2026-07-14 17:16 ` [PATCH v23 02/13] power: reset: reboot-mode: Support up to 3 magic values per mode Shivendra Pratap
2026-07-14 17:30 ` sashiko-bot
2026-07-14 17:16 ` [PATCH v23 03/13] power: reset: reboot-mode: Add support for predefined reboot modes Shivendra Pratap
2026-07-14 17:27 ` sashiko-bot
2026-07-14 17:16 ` [PATCH v23 04/13] firmware: psci: Introduce command-based resets Shivendra Pratap
2026-07-14 17:28 ` sashiko-bot
2026-07-14 17:16 ` [PATCH v23 05/13] mfd: psci-mfd: Add PSCI MFD driver for cpuidle-psci-domain cell Shivendra Pratap
2026-07-14 17:27 ` sashiko-bot
2026-07-14 17:16 ` [PATCH v23 06/13] dt-bindings: arm: Document reboot mode magic Shivendra Pratap
2026-07-14 17:33 ` sashiko-bot
2026-07-14 17:16 ` [PATCH v23 07/13] power: reset: Add psci-reboot-mode driver Shivendra Pratap
2026-07-14 17:30 ` sashiko-bot [this message]
2026-07-14 17:16 ` [PATCH v23 08/13] mfd: core: Add firmware-node support to MFD cells Shivendra Pratap
2026-07-14 17:30 ` sashiko-bot
2026-07-14 17:16 ` [PATCH v23 09/13] mfd: psci-mfd: Add psci-reboot-mode child cell Shivendra Pratap
2026-07-14 17:24 ` sashiko-bot
2026-07-14 17:16 ` [PATCH v23 10/13] arm64: dts: qcom: Add psci reboot-modes for kodiak boards Shivendra Pratap
2026-07-14 17:32 ` sashiko-bot
2026-07-14 17:16 ` [PATCH v23 11/13] arm64: dts: qcom: Add psci reboot-modes for lemans boards Shivendra Pratap
2026-07-14 17:32 ` sashiko-bot
2026-07-14 17:16 ` [PATCH v23 12/13] arm64: dts: qcom: Add psci reboot-modes for monaco boards Shivendra Pratap
2026-07-14 17:31 ` sashiko-bot
2026-07-14 17:16 ` [PATCH v23 13/13] arm64: dts: qcom: Add psci reboot-modes for talos boards Shivendra Pratap
2026-07-14 17:32 ` 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=20260714173038.50B121F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--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 \
--cc=shivendra.pratap@oss.qualcomm.com \
/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