From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
Bjorn Andersson <andersson@kernel.org>,
Rob Herring <robh@kernel.org>,
Souvik Chakravarty <Souvik.Chakravarty@arm.com>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Mark Rutland <mark.rutland@arm.com>,
Conor Dooley <conor+dt@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
John Stultz <john.stultz@linaro.org>,
Moritz Fischer <moritz.fischer@ettus.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Christian Loehle <christian.loehle@arm.com>,
Lee Jones <lee@kernel.org>, Ulf Hansson <ulfh@kernel.org>,
Pavan Kondeti <pavan.kondeti@oss.qualcomm.com>,
Abel Vesa <abelvesa@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
Sudeep Holla <sudeep.holla@kernel.org>,
Andy Yan <andyshrk@163.com>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Krzysztof Kozlowski <krzk@kernel.org>,
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>,
Andre Draszik <andre.draszik@linaro.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Kathiravan Thirumoorthy
<kathiravan.thirumoorthy@oss.qualcomm.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
Srinivas Kandagatla <srini@kernel.org>
Subject: Re: [PATCH v27 01/10] power: reset: reboot-mode: Support up to 3 magic values per mode
Date: Mon, 16 Nov 2026 00:08:35 +0100 [thread overview]
Message-ID: <avo7XV2jIkT73eyb@venus> (raw)
In-Reply-To: <20261029-arm-psci-system_reset2-vendor-reboots-v27-1-fa4b3ff1359b@oss.qualcomm.com>
[-- Attachment #1: Type: text/plain, Size: 5029 bytes --]
Hi,
On Thu, Oct 29, 2026 at 02:30:55PM +0530, Shivendra Pratap wrote:
> ARM PSCI vendor-specific resets, require a 32-bit reset_type and a 64-bit
> cookie as arguments. This cannot be implemented via the reboot-mode
> framework, which supports a single 32-bit argument as magic value.
>
> Extend the reboot-mode framework to support up to three 32-bit arguments
> as magic, per reboot-mode.
>
> Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
> ---
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
-- Sebastian
> drivers/power/reset/reboot-mode.c | 46 +++++++++++++++++++++++++++------------
> include/linux/reboot-mode.h | 3 +++
> 2 files changed, 35 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
> index 3611bed341e1..328fa37598df 100644
> --- a/drivers/power/reset/reboot-mode.c
> +++ b/drivers/power/reset/reboot-mode.c
> @@ -20,7 +20,8 @@
>
> struct mode_info {
> const char *mode;
> - u32 magic;
> + u32 magic[3];
> + u32 count;
> struct list_head list;
> };
>
> @@ -72,8 +73,7 @@ static const struct class reboot_mode_class = {
> .dev_groups = reboot_mode_groups,
> };
>
> -static unsigned int get_reboot_mode_magic(struct reboot_mode_driver *reboot,
> - const char *cmd)
> +static struct mode_info *get_reboot_mode_info(struct reboot_mode_driver *reboot, const char *cmd)
> {
> const char *normal = "normal";
> struct mode_info *info;
> @@ -84,11 +84,11 @@ static unsigned int get_reboot_mode_magic(struct reboot_mode_driver *reboot,
>
> list_for_each_entry(info, &reboot->head, list)
> if (!strcmp(info->mode, cmd))
> - return info->magic;
> + return info;
>
> /* try to match again, replacing characters impossible in DT */
> if (strscpy(cmd_, cmd, sizeof(cmd_)) == -E2BIG)
> - return 0;
> + return NULL;
>
> strreplace(cmd_, ' ', '-');
> strreplace(cmd_, ',', '-');
> @@ -96,21 +96,25 @@ static unsigned int get_reboot_mode_magic(struct reboot_mode_driver *reboot,
>
> list_for_each_entry(info, &reboot->head, list)
> if (!strcmp(info->mode, cmd_))
> - return info->magic;
> + return info;
>
> - return 0;
> + return NULL;
> }
>
> static int reboot_mode_notify(struct notifier_block *this,
> unsigned long mode, void *cmd)
> {
> struct reboot_mode_driver *reboot;
> - unsigned int magic;
> + struct mode_info *info;
>
> reboot = container_of(this, struct reboot_mode_driver, reboot_notifier);
> - magic = get_reboot_mode_magic(reboot, cmd);
> - if (magic)
> - reboot->write(reboot, magic);
> + info = get_reboot_mode_info(reboot, cmd);
> + if (info && info->count) {
> + if (reboot->write_array)
> + reboot->write_array(reboot, info->magic, info->count);
> + else if (reboot->write && info->magic[0])
> + reboot->write(reboot, info->magic[0]);
> + }
>
> return NOTIFY_DONE;
> }
> @@ -173,16 +177,22 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
> struct property *prop;
> struct device_node *np = reboot->dev->of_node;
> size_t len = strlen(PREFIX);
> - u32 magic;
> + u32 magic[3];
> + int count;
> int ret;
>
> INIT_LIST_HEAD(&reboot->head);
>
> for_each_property_of_node(np, prop) {
> + memset(magic, 0, sizeof(magic));
> +
> if (strncmp(prop->name, PREFIX, len))
> continue;
>
> - if (device_property_read_u32(reboot->dev, prop->name, &magic)) {
> + count = device_property_count_u32(reboot->dev, prop->name);
> +
> + if (count <= 0 || count > ARRAY_SIZE(magic) ||
> + device_property_read_u32_array(reboot->dev, prop->name, magic, count)) {
> dev_dbg(reboot->dev, "reboot mode %s without magic number\n",
> prop->name);
> continue;
> @@ -194,7 +204,15 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
> goto error;
> }
>
> - info->magic = magic;
> + if (!memchr_inv(magic, 0, count * sizeof(u32))) {
> + dev_dbg(reboot->dev, "reboot mode %s with zero magic values\n",
> + prop->name);
> + info->count = 0;
> + } else {
> + memcpy(info->magic, magic, count * sizeof(u32));
> + info->count = count;
> + }
> +
> info->mode = kstrdup_const(prop->name + len, GFP_KERNEL);
> if (!info->mode) {
> ret = -ENOMEM;
> diff --git a/include/linux/reboot-mode.h b/include/linux/reboot-mode.h
> index 4a2abb38d1d6..29ae39935d69 100644
> --- a/include/linux/reboot-mode.h
> +++ b/include/linux/reboot-mode.h
> @@ -2,10 +2,13 @@
> #ifndef __REBOOT_MODE_H__
> #define __REBOOT_MODE_H__
>
> +#include <linux/types.h>
> +
> struct reboot_mode_driver {
> struct device *dev;
> struct list_head head;
> int (*write)(struct reboot_mode_driver *reboot, unsigned int magic);
> + int (*write_array)(struct reboot_mode_driver *reboot, const u32 *magic, int count);
> struct notifier_block reboot_notifier;
> };
>
>
> --
> 2.34.1
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-11-16 6:03 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 9:00 [PATCH v27 00/10] Implement PSCI reboot mode driver for PSCI resets Shivendra Pratap
2026-10-29 9:00 ` [PATCH v27 01/10] power: reset: reboot-mode: Support up to 3 magic values per mode Shivendra Pratap
2026-11-15 23:08 ` Sebastian Reichel [this message]
2026-10-29 9:00 ` [PATCH v27 02/10] power: reset: reboot-mode: Add support for predefined reboot modes Shivendra Pratap
2026-10-29 9:23 ` sashiko-bot
2026-11-15 23:13 ` Sebastian Reichel
2026-10-29 9:00 ` [PATCH v27 03/10] firmware: psci: Introduce command-based resets Shivendra Pratap
2026-10-29 9:00 ` [PATCH v27 04/10] firmware: psci: Add support for PSCI auxiliary devices Shivendra Pratap
2026-10-29 10:00 ` sashiko-bot
2026-10-29 9:00 ` [PATCH v27 05/10] dt-bindings: arm: Document reboot mode magic Shivendra Pratap
2026-11-02 9:40 ` Bartosz Golaszewski
2026-11-17 13:45 ` Bartosz Golaszewski
2026-10-29 9:01 ` [PATCH v27 06/10] power: reset: Add psci-reboot-mode driver Shivendra Pratap
2026-11-15 23:08 ` Sebastian Reichel
2026-10-29 9:01 ` [PATCH v27 07/10] arm64: dts: qcom: Add psci reboot-modes for kodiak boards Shivendra Pratap
2026-10-29 10:23 ` Abel Vesa
2026-10-29 9:01 ` [PATCH v27 08/10] arm64: dts: qcom: Add psci reboot-modes for lemans boards Shivendra Pratap
2026-10-29 10:23 ` Abel Vesa
2026-10-29 9:01 ` [PATCH v27 09/10] arm64: dts: qcom: Add psci reboot-modes for monaco boards Shivendra Pratap
2026-10-29 10:24 ` Abel Vesa
2026-10-29 9:01 ` [PATCH v27 10/10] arm64: dts: qcom: Add psci reboot-modes for talos boards Shivendra Pratap
2026-10-29 10:24 ` Abel Vesa
2026-11-09 15:47 ` [PATCH v27 00/10] Implement PSCI reboot mode driver for PSCI resets Ulf Hansson
2026-11-15 23:14 ` Sebastian Reichel
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=avo7XV2jIkT73eyb@venus \
--to=sebastian.reichel@collabora.com \
--cc=Souvik.Chakravarty@arm.com \
--cc=abelvesa@kernel.org \
--cc=andersson@kernel.org \
--cc=andre.draszik@linaro.org \
--cc=andyshrk@163.com \
--cc=arnd@arndb.de \
--cc=brgl@kernel.org \
--cc=christian.loehle@arm.com \
--cc=conor+dt@kernel.org \
--cc=daniel.lezcano@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=florian.fainelli@broadcom.com \
--cc=gregkh@linuxfoundation.org \
--cc=john.stultz@linaro.org \
--cc=kathiravan.thirumoorthy@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=krzk@kernel.org \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=moritz.fischer@ettus.com \
--cc=mukesh.ojha@oss.qualcomm.com \
--cc=pavan.kondeti@oss.qualcomm.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=shivendra.pratap@oss.qualcomm.com \
--cc=srini@kernel.org \
--cc=sudeep.holla@kernel.org \
--cc=ulfh@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.