* [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2
@ 2025-07-27 16:24 Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 01/10] power: reset: reboot-mode: Synchronize list traversal Shivendra Pratap
` (10 more replies)
0 siblings, 11 replies; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-27 16:24 UTC (permalink / raw)
To: Bartosz Golaszewski, Bjorn Andersson, Sebastian Reichel,
Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Shivendra Pratap,
Srinivas Kandagatla, Elliot Berman, Konrad Dybcio, Konrad Dybcio
The PSCI SYSTEM_RESET2 call allows vendor firmware to define
additional reset types which could be mapped to the reboot
argument.
User-space should be able to reboot a device into different
operational boot-states supported by underlying bootloader and
firmware. Generally, some HW registers need to be written, based
on which the bootloader and firmware decide the next boot state
of device, after the reset. For example, a requirement on
Qualcomm platforms may state that reboot with "bootloader"
command, should reboot the device into bootloader flashing mode
and reboot with “edl” command, should reboot the device into an
Emergency flashing mode. Setting up such reboots on Qualcomm
devices can be inconsistent across SoC platforms and may require
setting different HW registers, where some of these registers may
not be accessible to HLOS. These knobs evolve over product
generations and require more drivers. PSCI defines a
vendor-specific reset in SYSTEM_RESET2 spec, which enables the
firmware to take care of underlying setting for any such
supported vendor-specific reboot. Qualcomm firmwares are
beginning to support and expose PSCI SYSTEM_RESET2
vendor-specific reset types to simplify driver requirements from
Linux. With such support added in the firmware, we now need a
Linux interface which can make use of the firmware calls for PSCI
vendor-specific resets. This will align such reboot requirement
across platforms and vendors.
The current psci driver supports two types of resets –
SYSTEM_RESET2 Arch warm-reset and SYSTEM_RESET cold-reset. The
patchset introduces the PSCI SYSTEM_RESET2 vendor-specific reset
into the reset path of the psci driver and aligns it to work with
reboot system call - LINUX_REBOOT_CMD_RESTART2, when used along
with a supported string-based command in “*arg”.
The patchset uses reboot-mode based commands, to define the
supported vendor reset-types commands in psci device tree node
and registers these commands with the reboot-mode framework.
The PSCI vendor-specific reset takes two arguments, being,
reset_type and cookie as defined by the spec. To accommodate this
requirement, enhance the reboot-mode framework to support two
32-bit arguments by switching to 64-bit magic values.
Along this line, the patchset also extends the reboot-mode
framework to add a non-device-based registration function, which
will allow drivers to register using device tree node, while
keeping backward compatibility for existing users of reboot-mode.
This will enable psci driver to register for reboot-mode and
implement a write function, which will save the magic and then
use it in psci reset path to make a vendor-specific reset call
into the firmware. In addition, the patchset will expose a sysfs
entry interface within reboot-mode which can be used by userspace
to view the supported reboot-mode commands.
The list of vendor-specific reset commands remains open due to
divergent requirements across vendors, but this can be
streamlined and standardized through dedicated device tree
bindings.
Currently three drivers register with reboot-mode framework -
syscon-reboot-mode, nvmem-reboot-mode and qcom-pon. Consolidated
list of commands currently added across various vendor DTs:
mode-loader
mode-normal
mode-bootloader
mode-charge
mode-fastboot
mode-reboot-ab-update
mode-recovery
mode-rescue
mode-shutdown-thermal
mode-shutdown-thermal-battery
Detailed list of commands being used by syscon-reboot-mode:
arm64/boot/dts/exynos/exynosautov9.dtsi:
mode-bootloader = <EXYNOSAUTOV9_BOOT_BOOTLOADER>;
mode-fastboot = <EXYNOSAUTOV9_BOOT_FASTBOOT>;
mode-recovery = <EXYNOSAUTOV9_BOOT_RECOVERY>;
arm64/boot/dts/exynos/google/gs101.dtsi:
mode-bootloader = <0xfc>;
mode-charge = <0x0a>;
mode-fastboot = <0xfa>;
mode-reboot-ab-update = <0x52>;
mode-recovery = <0xff>;
mode-rescue = <0xf9>;
mode-shutdown-thermal = <0x51>;
mode-shutdown-thermal-battery = <0x51>;
arm64/boot/dts/hisilicon/hi3660-hikey960.dts:
mode-normal = <0x77665501>;
mode-bootloader = <0x77665500>;
mode-recovery = <0x77665502>;
arm64/boot/dts/hisilicon/hi6220-hikey.dts:
mode-normal = <0x77665501>;
mode-bootloader = <0x77665500>;
mode-recovery = <0x77665502>;
arm64/boot/dts/rockchip/px30.dtsi:
mode-bootloader = <BOOT_BL_DOWNLOAD>;
mode-fastboot = <BOOT_FASTBOOT>;
mode-loader = <BOOT_BL_DOWNLOAD>;
mode-normal = <BOOT_NORMAL>;
mode-recovery = <BOOT_RECOVERY>;
arm64/boot/dts/rockchip/rk3308.dtsi:
mode-bootloader = <BOOT_BL_DOWNLOAD>;
mode-loader = <BOOT_BL_DOWNLOAD>;
mode-normal = <BOOT_NORMAL>;
mode-recovery = <BOOT_RECOVERY>;
mode-fastboot = <BOOT_FASTBOOT>;
arm64/boot/dts/rockchip/rk3566-lckfb-tspi.dts:
mode-normal = <BOOT_NORMAL>;
mode-loader = <BOOT_BL_DOWNLOAD>;
mode-recovery = <BOOT_RECOVERY>;
mode-bootloader = <BOOT_FASTBOOT>;
Detailed list of commands being used by nvmem-reboot-mode:
arm64/boot/dts/qcom/pmXXXX.dtsi:(multiple qcom DTs)
mode-recovery = <0x01>;
mode-bootloader = <0x02>;
Previous discussions around SYSTEM_RESET2:
- https://lore.kernel.org/lkml/20230724223057.1208122-2-quic_eberman@quicinc.com/T/
- https://lore.kernel.org/all/4a679542-b48d-7e11-f33a-63535a5c68cb@quicinc.com/
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
Changes in v13:
- Split patch1 into two (Synchronize list traversal and DT node-based
registration) - by Dmitry.
- Move mutex lock inside get_reboot_mode_magic - by Dmitry.
- Reorder the patches – pull patch8 for exposing reboot-mode sysfs before
psci patch - to align the change in reboot-mode sysfs patch.
- Update patch- reboot-mode: Expose sysfs for registered reboot_modes
- Introduce a driver_name in reboot_mode_register. This will be used
in sysfs creation - by Arnd.
- Update documentation and commit text for above.
- Fix release function to properly call delete attr file.
- Fix sparse warning for devres_find.
- Add error handling for devres_find.
- Split ABI documentation as a separate patch and update ABI documentation
for usage of driver-name in sysfs - by Arnd
- Update patch - psci: Implement vendor-specific resets as reboot-mode
- Fix Kconfig for CONFIG related warning.
- Add driver_name as "psci" in register call to reboot-mode - by Arnd
- Link to v12: https://lore.kernel.org/r/20250721-arm-psci-system_reset2-vendor-reboots-v12-0-87bac3ec422e@oss.qualcomm.com
Changes in v12:
- Added lock for list traversals in reboot-mode - by Dmitry.
- Added proper handling for BE and LE cases in reboot-mode - by Dmitry.
- Removed type casting for u64 to u32 conversions. Added limit checks
and used bitwise operations for same - by Andrew.
- Link to v11: https://lore.kernel.org/r/20250717-arm-psci-system_reset2-vendor-reboots-v11-0-df3e2b2183c3@oss.qualcomm.com
Changes in v11:
- Remove reference of cookie in reboot-mode – Arnd/Rob
- Introduce 64-bit magic in reboot-mode to accommodate two 32-bit
arguments – Arnd
- Change reset-type to reboot-mode in psci device tree binding – Arnd
- binding no more mandates two arguments as in v10.
- dt changes done to support this binding.
- Remove obvious comments in psci reset path – Konrad
- Merge sysfs and ABI doc into single patch.
- Fix compilation issue on X86 configs.
- Fix warnings for pr_fmt.
- Link to v10: https://lore.kernel.org/all/569f154d-c714-1714-b898-83a42a38771c@oss.qualcomm.com/
Changes in V10:
- Change in reset-type binding to make cookie as a mandatory
argument.
- Change reboot-mode binding to support additional argument
"cookie".
From Lorenzo:
- Use reboot-mode framework for implementing vendor-resets.
- Modify reboot-mode framework to support two arguments
(magic and cookie).
- Expose sysfs for supported reboot-modes commands.
- List out all existing reboot-mode commands and their users.
- Added this to cover letter.
From Dmitry:
- Modify reboot-mode to support non-device based registration.
- Modify reboot-mode to create a class and device to expose
sysfs interface.
- Link to v9: https://lore.kernel.org/all/20250303-arm-psci-system_reset2-vendor-reboots-v9-0-b2cf4a20feda@oss.qualcomm.com/
Changes in v9:
- Don't fallback to architecturally defined resets from Lorenzo.
- Link to v8: https://lore.kernel.org/r/20241107-arm-psci-system_reset2-vendor-reboots-v8-0-e8715fa65cb5@quicinc.com
Changes in v8:
- Code style nits from Stephen
- Add rb3gen2
- Link to v7: https://lore.kernel.org/r/20241028-arm-psci-system_reset2-vendor-reboots-v7-0-a4c40b0ebc54@quicinc.com
Changes in v7:
- Code style nits from Stephen
- Dropped unnecessary hunk from the sa8775p-ride patch
- Link to v6: https://lore.kernel.org/r/20241018-arm-psci-system_reset2-vendor-reboots-v6-0-50cbe88b0a24@quicinc.com
Changes in v6:
- Rebase to v6.11 and fix trivial conflicts in qcm6490-idp
- Add sa8775p-ride support (same as qcm6490-idp)
- Link to v5: https://lore.kernel.org/r/20240617-arm-psci-system_reset2-vendor-reboots-v5-0-086950f650c8@quicinc.com
Changes in v5:
- Drop the nested "items" in prep for future dtschema tools
- Link to v4: https://lore.kernel.org/r/20240611-arm-psci-system_reset2-vendor-reboots-v4-0-98f55aa74ae8@quicinc.com
Changes in v4:
- Change mode- properties from uint32-matrix to uint32-array
- Restructure the reset-types node so only the restriction is in the
if/then schemas and not the entire definition
- Link to v3: https://lore.kernel.org/r/20240515-arm-psci-system_reset2-vendor-reboots-v3-0-16dd4f9c0ab4@quicinc.com
Changes in v3:
- Limit outer number of items to 1 for mode-* properties
- Move the reboot-mode for psci under a subnode "reset-types"
- Fix the DT node in qcm6490-idp so it doesn't overwrite the one from
sc7820.dtsi
- Link to v2: https://lore.kernel.org/r/20240414-arm-psci-system_reset2-vendor-reboots-v2-0-da9a055a648f@quicinc.com
Changes in v2:
- Fixes to schema as suggested by Rob and Krzysztof
- Add qcm6490 idp as first Qualcomm device to support
- Link to v1: https://lore.kernel.org/r/20231117-arm-psci-system_reset2-vendor-reboots-v1-0-03c4612153e2@quicinc.com
Changes in v1:
- Reference reboot-mode bindings as suggeted by Rob.
- Link to RFC: https://lore.kernel.org/r/20231030-arm-psci-system_reset2-vendor-reboots-v1-0-dcdd63352ad1@quicinc.com
---
Elliot Berman (4):
dt-bindings: arm: Document reboot mode magic
arm64: dts: qcom: qcm6490-idp: Add PSCI SYSTEM_RESET2 types
arm64: dts: qcom: qcs6490-rb3gen2: Add PSCI SYSTEM_RESET2 types
arm64: dts: qcom: sa8775p-ride: Add PSCI SYSTEM_RESET2 types
Shivendra Pratap (6):
power: reset: reboot-mode: Synchronize list traversal
power: reset: reboot-mode: Add device tree node-based registration
power: reset: reboot-mode: Add support for 64 bit magic
Documentation: ABI: Add sysfs-class-reboot-mode-reboot_modes
power: reset: reboot-mode: Expose sysfs for registered reboot_modes
firmware: psci: Implement vendor-specific resets as reboot-mode
.../testing/sysfs-class-reboot-mode-reboot_modes | 39 +++++
Documentation/devicetree/bindings/arm/psci.yaml | 43 +++++
arch/arm64/boot/dts/qcom/qcm6490-idp.dts | 7 +
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts | 7 +
arch/arm64/boot/dts/qcom/sa8775p-ride.dtsi | 7 +
arch/arm64/boot/dts/qcom/sa8775p.dtsi | 2 +-
arch/arm64/boot/dts/qcom/sc7280.dtsi | 2 +-
drivers/firmware/psci/Kconfig | 2 +
drivers/firmware/psci/psci.c | 57 ++++++-
drivers/power/reset/nvmem-reboot-mode.c | 13 +-
drivers/power/reset/qcom-pon.c | 11 +-
drivers/power/reset/reboot-mode.c | 174 +++++++++++++++++----
drivers/power/reset/syscon-reboot-mode.c | 11 +-
include/linux/reboot-mode.h | 11 +-
14 files changed, 342 insertions(+), 44 deletions(-)
---
base-commit: d7af19298454ed155f5cf67201a70f5cf836c842
change-id: 20250709-arm-psci-system_reset2-vendor-reboots-46c80044afcf
Best regards,
--
Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v13 01/10] power: reset: reboot-mode: Synchronize list traversal
2025-07-27 16:24 [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 Shivendra Pratap
@ 2025-07-27 16:24 ` Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 02/10] power: reset: reboot-mode: Add device tree node-based registration Shivendra Pratap
` (9 subsequent siblings)
10 siblings, 0 replies; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-27 16:24 UTC (permalink / raw)
To: Bartosz Golaszewski, Bjorn Andersson, Sebastian Reichel,
Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Shivendra Pratap,
Srinivas Kandagatla
List traversals must be synchronized to prevent race conditions
and data corruption. The reboot-mode list is not protected by a
lock currently, which can lead to concurrent access and race.
Introduce a mutex lock to guard all operations on the reboot-mode
list and ensure thread-safe access. The change prevents unsafe
concurrent access on reboot-mode list.
Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
---
drivers/power/reset/reboot-mode.c | 24 ++++++++++++++++++++----
include/linux/reboot-mode.h | 4 ++++
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
index fba53f638da04655e756b5f8b7d2d666d1379535..42bb99128ed3846d4bff62416dc31135ddeaeb90 100644
--- a/drivers/power/reset/reboot-mode.c
+++ b/drivers/power/reset/reboot-mode.c
@@ -29,9 +29,14 @@ static unsigned int get_reboot_mode_magic(struct reboot_mode_driver *reboot,
if (!cmd)
cmd = normal;
- list_for_each_entry(info, &reboot->head, list)
- if (!strcmp(info->mode, cmd))
+ mutex_lock(&reboot->rb_lock);
+ list_for_each_entry(info, &reboot->head, list) {
+ if (!strcmp(info->mode, cmd)) {
+ mutex_unlock(&reboot->rb_lock);
return info->magic;
+ }
+ }
+ mutex_unlock(&reboot->rb_lock);
/* try to match again, replacing characters impossible in DT */
if (strscpy(cmd_, cmd, sizeof(cmd_)) == -E2BIG)
@@ -41,9 +46,14 @@ static unsigned int get_reboot_mode_magic(struct reboot_mode_driver *reboot,
strreplace(cmd_, ',', '-');
strreplace(cmd_, '/', '-');
- list_for_each_entry(info, &reboot->head, list)
- if (!strcmp(info->mode, cmd_))
+ mutex_lock(&reboot->rb_lock);
+ list_for_each_entry(info, &reboot->head, list) {
+ if (!strcmp(info->mode, cmd_)) {
+ mutex_unlock(&reboot->rb_lock);
return info->magic;
+ }
+ }
+ mutex_unlock(&reboot->rb_lock);
return 0;
}
@@ -77,7 +87,9 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
int ret;
INIT_LIST_HEAD(&reboot->head);
+ mutex_init(&reboot->rb_lock);
+ mutex_lock(&reboot->rb_lock);
for_each_property_of_node(np, prop) {
if (strncmp(prop->name, PREFIX, len))
continue;
@@ -113,12 +125,14 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
reboot->reboot_notifier.notifier_call = reboot_mode_notify;
register_reboot_notifier(&reboot->reboot_notifier);
+ mutex_unlock(&reboot->rb_lock);
return 0;
error:
list_for_each_entry(info, &reboot->head, list)
kfree_const(info->mode);
+ mutex_unlock(&reboot->rb_lock);
return ret;
}
EXPORT_SYMBOL_GPL(reboot_mode_register);
@@ -133,8 +147,10 @@ int reboot_mode_unregister(struct reboot_mode_driver *reboot)
unregister_reboot_notifier(&reboot->reboot_notifier);
+ mutex_lock(&reboot->rb_lock);
list_for_each_entry(info, &reboot->head, list)
kfree_const(info->mode);
+ mutex_unlock(&reboot->rb_lock);
return 0;
}
diff --git a/include/linux/reboot-mode.h b/include/linux/reboot-mode.h
index 4a2abb38d1d612ec0fdf05eb18c98b210f631b7f..b73f80708197677db8dc2e43affc519782b7146e 100644
--- a/include/linux/reboot-mode.h
+++ b/include/linux/reboot-mode.h
@@ -2,11 +2,15 @@
#ifndef __REBOOT_MODE_H__
#define __REBOOT_MODE_H__
+#include <linux/mutex.h>
+
struct reboot_mode_driver {
struct device *dev;
struct list_head head;
int (*write)(struct reboot_mode_driver *reboot, unsigned int magic);
struct notifier_block reboot_notifier;
+ /*Protects access to reboot mode list*/
+ struct mutex rb_lock;
};
int reboot_mode_register(struct reboot_mode_driver *reboot);
--
2.34.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v13 02/10] power: reset: reboot-mode: Add device tree node-based registration
2025-07-27 16:24 [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 01/10] power: reset: reboot-mode: Synchronize list traversal Shivendra Pratap
@ 2025-07-27 16:24 ` Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 03/10] power: reset: reboot-mode: Add support for 64 bit magic Shivendra Pratap
` (8 subsequent siblings)
10 siblings, 0 replies; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-27 16:24 UTC (permalink / raw)
To: Bartosz Golaszewski, Bjorn Andersson, Sebastian Reichel,
Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Shivendra Pratap,
Srinivas Kandagatla
The reboot-mode driver does not have a strict requirement for
device-based registration. It primarily uses the device's of_node
to read mode-<cmd> properties and the device pointer for logging.
Remove the dependency on struct device and introduce support for
Device Tree (DT) node-based registration. This enables drivers
that are not associated with a struct device to leverage the
reboot-mode framework.
Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
---
drivers/power/reset/reboot-mode.c | 37 ++++++++++++++++++++++++++-----------
include/linux/reboot-mode.h | 2 +-
2 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
index 42bb99128ed3846d4bff62416dc31135ddeaeb90..9bb97bcd33cd3d58c75c791e9b568024e810e5b0 100644
--- a/drivers/power/reset/reboot-mode.c
+++ b/drivers/power/reset/reboot-mode.c
@@ -3,13 +3,17 @@
* Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd
*/
+#define pr_fmt(fmt) "reboot-mode: " fmt
+
#include <linux/device.h>
#include <linux/init.h>
#include <linux/kernel.h>
+#include <linux/list.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/reboot.h>
#include <linux/reboot-mode.h>
+#include <linux/slab.h>
#define PREFIX "mode-"
@@ -75,17 +79,21 @@ static int reboot_mode_notify(struct notifier_block *this,
/**
* reboot_mode_register - register a reboot mode driver
* @reboot: reboot mode driver
+ * @np: Pointer to device tree node
*
* Returns: 0 on success or a negative error code on failure.
*/
-int reboot_mode_register(struct reboot_mode_driver *reboot)
+int reboot_mode_register(struct reboot_mode_driver *reboot, struct device_node *np)
{
struct mode_info *info;
+ struct mode_info *next;
struct property *prop;
- struct device_node *np = reboot->dev->of_node;
size_t len = strlen(PREFIX);
int ret;
+ if (!np)
+ return -EINVAL;
+
INIT_LIST_HEAD(&reboot->head);
mutex_init(&reboot->rb_lock);
@@ -94,28 +102,28 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
if (strncmp(prop->name, PREFIX, len))
continue;
- info = devm_kzalloc(reboot->dev, sizeof(*info), GFP_KERNEL);
+ info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) {
ret = -ENOMEM;
goto error;
}
if (of_property_read_u32(np, prop->name, &info->magic)) {
- dev_err(reboot->dev, "reboot mode %s without magic number\n",
- info->mode);
- devm_kfree(reboot->dev, info);
+ pr_err("reboot mode %s without magic number\n", info->mode);
+ kfree(info);
continue;
}
info->mode = kstrdup_const(prop->name + len, GFP_KERNEL);
if (!info->mode) {
ret = -ENOMEM;
+ kfree(info);
goto error;
} else if (info->mode[0] == '\0') {
kfree_const(info->mode);
+ kfree(info);
ret = -EINVAL;
- dev_err(reboot->dev, "invalid mode name(%s): too short!\n",
- prop->name);
+ pr_err("invalid mode name(%s): too short!\n", prop->name);
goto error;
}
@@ -129,8 +137,11 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
return 0;
error:
- list_for_each_entry(info, &reboot->head, list)
+ list_for_each_entry_safe(info, next, &reboot->head, list) {
+ list_del(&info->list);
kfree_const(info->mode);
+ kfree(info);
+ }
mutex_unlock(&reboot->rb_lock);
return ret;
@@ -144,12 +155,16 @@ EXPORT_SYMBOL_GPL(reboot_mode_register);
int reboot_mode_unregister(struct reboot_mode_driver *reboot)
{
struct mode_info *info;
+ struct mode_info *next;
unregister_reboot_notifier(&reboot->reboot_notifier);
mutex_lock(&reboot->rb_lock);
- list_for_each_entry(info, &reboot->head, list)
+ list_for_each_entry_safe(info, next, &reboot->head, list) {
+ list_del(&info->list);
kfree_const(info->mode);
+ kfree(info);
+ }
mutex_unlock(&reboot->rb_lock);
return 0;
@@ -178,7 +193,7 @@ int devm_reboot_mode_register(struct device *dev,
if (!dr)
return -ENOMEM;
- rc = reboot_mode_register(reboot);
+ rc = reboot_mode_register(reboot, reboot->dev->of_node);
if (rc) {
devres_free(dr);
return rc;
diff --git a/include/linux/reboot-mode.h b/include/linux/reboot-mode.h
index b73f80708197677db8dc2e43affc519782b7146e..98f68f95c9e8460be23282c51ef7fcbed73887bd 100644
--- a/include/linux/reboot-mode.h
+++ b/include/linux/reboot-mode.h
@@ -13,7 +13,7 @@ struct reboot_mode_driver {
struct mutex rb_lock;
};
-int reboot_mode_register(struct reboot_mode_driver *reboot);
+int reboot_mode_register(struct reboot_mode_driver *reboot, struct device_node *np);
int reboot_mode_unregister(struct reboot_mode_driver *reboot);
int devm_reboot_mode_register(struct device *dev,
struct reboot_mode_driver *reboot);
--
2.34.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v13 03/10] power: reset: reboot-mode: Add support for 64 bit magic
2025-07-27 16:24 [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 01/10] power: reset: reboot-mode: Synchronize list traversal Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 02/10] power: reset: reboot-mode: Add device tree node-based registration Shivendra Pratap
@ 2025-07-27 16:24 ` Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 04/10] Documentation: ABI: Add sysfs-class-reboot-mode-reboot_modes Shivendra Pratap
` (7 subsequent siblings)
10 siblings, 0 replies; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-27 16:24 UTC (permalink / raw)
To: Bartosz Golaszewski, Bjorn Andersson, Sebastian Reichel,
Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Shivendra Pratap,
Srinivas Kandagatla
Current reboot-mode supports a single 32-bit argument for any
supported mode. Some reboot-mode based drivers may require
passing two independent 32-bit arguments during a reboot
sequence, for uses-cases, where a mode requires an additional
argument. Such drivers may not be able to use the reboot-mode
driver. For example, ARM PSCI vendor-specific resets, need two
arguments for its operation – reset_type and cookie, to complete
the reset operation. If a driver wants to implement this
firmware-based reset, it cannot use reboot-mode framework.
Introduce 64-bit magic values in reboot-mode driver to
accommodate dual 32-bit arguments when specified via device tree.
In cases, where no second argument is passed from device tree,
keep the upper 32-bit of magic un-changed(0) to maintain backward
compatibility.
Update the current drivers using reboot-mode for a 64-bit magic
value.
Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
---
drivers/power/reset/nvmem-reboot-mode.c | 13 +++++++++----
drivers/power/reset/qcom-pon.c | 11 ++++++++---
drivers/power/reset/reboot-mode.c | 19 +++++++++++++------
drivers/power/reset/syscon-reboot-mode.c | 11 ++++++++---
include/linux/reboot-mode.h | 3 ++-
5 files changed, 40 insertions(+), 17 deletions(-)
diff --git a/drivers/power/reset/nvmem-reboot-mode.c b/drivers/power/reset/nvmem-reboot-mode.c
index 41530b70cfc48c2a83fbbd96f523d5816960a0d1..5d73dde585b1fd438b1847f884feb37cd9e4dd5c 100644
--- a/drivers/power/reset/nvmem-reboot-mode.c
+++ b/drivers/power/reset/nvmem-reboot-mode.c
@@ -16,15 +16,20 @@ struct nvmem_reboot_mode {
struct nvmem_cell *cell;
};
-static int nvmem_reboot_mode_write(struct reboot_mode_driver *reboot,
- unsigned int magic)
+static int nvmem_reboot_mode_write(struct reboot_mode_driver *reboot, u64 magic)
{
- int ret;
struct nvmem_reboot_mode *nvmem_rbm;
+ u32 magic_32;
+ int ret;
+
+ if (magic > U32_MAX)
+ return -EINVAL;
+
+ magic_32 = magic;
nvmem_rbm = container_of(reboot, struct nvmem_reboot_mode, reboot);
- ret = nvmem_cell_write(nvmem_rbm->cell, &magic, sizeof(magic));
+ ret = nvmem_cell_write(nvmem_rbm->cell, &magic_32, sizeof(magic_32));
if (ret < 0)
dev_err(reboot->dev, "update reboot mode bits failed\n");
diff --git a/drivers/power/reset/qcom-pon.c b/drivers/power/reset/qcom-pon.c
index 7e108982a582e8243c5c806bd4a793646b87189f..d0ed9431a02313a7bbaa93743c16fa1ae713ddfe 100644
--- a/drivers/power/reset/qcom-pon.c
+++ b/drivers/power/reset/qcom-pon.c
@@ -27,17 +27,22 @@ struct qcom_pon {
long reason_shift;
};
-static int qcom_pon_reboot_mode_write(struct reboot_mode_driver *reboot,
- unsigned int magic)
+static int qcom_pon_reboot_mode_write(struct reboot_mode_driver *reboot, u64 magic)
{
struct qcom_pon *pon = container_of
(reboot, struct qcom_pon, reboot_mode);
+ u32 magic_32;
int ret;
+ if (magic > U32_MAX || (magic << pon->reason_shift) > U32_MAX)
+ return -EINVAL;
+
+ magic_32 = magic << pon->reason_shift;
+
ret = regmap_update_bits(pon->regmap,
pon->baseaddr + PON_SOFT_RB_SPARE,
GENMASK(7, pon->reason_shift),
- magic << pon->reason_shift);
+ magic_32);
if (ret < 0)
dev_err(pon->dev, "update reboot mode bits failed\n");
diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
index 9bb97bcd33cd3d58c75c791e9b568024e810e5b0..ac81b8b0a9b7fc31f8ef21024333a050087ce90f 100644
--- a/drivers/power/reset/reboot-mode.c
+++ b/drivers/power/reset/reboot-mode.c
@@ -19,12 +19,11 @@
struct mode_info {
const char *mode;
- u32 magic;
+ u64 magic;
struct list_head list;
};
-static unsigned int get_reboot_mode_magic(struct reboot_mode_driver *reboot,
- const char *cmd)
+static u64 get_reboot_mode_magic(struct reboot_mode_driver *reboot, const char *cmd)
{
const char *normal = "normal";
struct mode_info *info;
@@ -66,7 +65,7 @@ static int reboot_mode_notify(struct notifier_block *this,
unsigned long mode, void *cmd)
{
struct reboot_mode_driver *reboot;
- unsigned int magic;
+ u64 magic;
reboot = container_of(this, struct reboot_mode_driver, reboot_notifier);
magic = get_reboot_mode_magic(reboot, cmd);
@@ -89,6 +88,8 @@ int reboot_mode_register(struct reboot_mode_driver *reboot, struct device_node *
struct mode_info *next;
struct property *prop;
size_t len = strlen(PREFIX);
+ u32 magic_arg1;
+ u32 magic_arg2;
int ret;
if (!np)
@@ -108,12 +109,18 @@ int reboot_mode_register(struct reboot_mode_driver *reboot, struct device_node *
goto error;
}
- if (of_property_read_u32(np, prop->name, &info->magic)) {
- pr_err("reboot mode %s without magic number\n", info->mode);
+ if (of_property_read_u32(np, prop->name, &magic_arg1)) {
+ pr_err("reboot mode without magic number\n");
kfree(info);
continue;
}
+ if (of_property_read_u32_index(np, prop->name, 1, &magic_arg2))
+ magic_arg2 = 0;
+
+ info->magic = magic_arg2;
+ info->magic = (info->magic << 32) | magic_arg1;
+
info->mode = kstrdup_const(prop->name + len, GFP_KERNEL);
if (!info->mode) {
ret = -ENOMEM;
diff --git a/drivers/power/reset/syscon-reboot-mode.c b/drivers/power/reset/syscon-reboot-mode.c
index e0772c9f70f7a19cd8ec8a0b7fdbbaa7ba44afd0..3cbd000c512239b12ec51987e900d260540a9dea 100644
--- a/drivers/power/reset/syscon-reboot-mode.c
+++ b/drivers/power/reset/syscon-reboot-mode.c
@@ -20,16 +20,21 @@ struct syscon_reboot_mode {
u32 mask;
};
-static int syscon_reboot_mode_write(struct reboot_mode_driver *reboot,
- unsigned int magic)
+static int syscon_reboot_mode_write(struct reboot_mode_driver *reboot, u64 magic)
{
struct syscon_reboot_mode *syscon_rbm;
+ u32 magic_32;
int ret;
+ if (magic > U32_MAX)
+ return -EINVAL;
+
+ magic_32 = magic;
+
syscon_rbm = container_of(reboot, struct syscon_reboot_mode, reboot);
ret = regmap_update_bits(syscon_rbm->map, syscon_rbm->offset,
- syscon_rbm->mask, magic);
+ syscon_rbm->mask, magic_32);
if (ret < 0)
dev_err(reboot->dev, "update reboot mode bits failed\n");
diff --git a/include/linux/reboot-mode.h b/include/linux/reboot-mode.h
index 98f68f95c9e8460be23282c51ef7fcbed73887bd..370228b5161963aac1d75af752ada0e8282b1078 100644
--- a/include/linux/reboot-mode.h
+++ b/include/linux/reboot-mode.h
@@ -3,11 +3,12 @@
#define __REBOOT_MODE_H__
#include <linux/mutex.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)(struct reboot_mode_driver *reboot, u64 magic);
struct notifier_block reboot_notifier;
/*Protects access to reboot mode list*/
struct mutex rb_lock;
--
2.34.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v13 04/10] Documentation: ABI: Add sysfs-class-reboot-mode-reboot_modes
2025-07-27 16:24 [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 Shivendra Pratap
` (2 preceding siblings ...)
2025-07-27 16:24 ` [PATCH v13 03/10] power: reset: reboot-mode: Add support for 64 bit magic Shivendra Pratap
@ 2025-07-27 16:24 ` Shivendra Pratap
2025-07-30 9:06 ` André Draszik
2025-07-27 16:24 ` [PATCH v13 05/10] power: reset: reboot-mode: Expose sysfs for registered reboot_modes Shivendra Pratap
` (6 subsequent siblings)
10 siblings, 1 reply; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-27 16:24 UTC (permalink / raw)
To: Bartosz Golaszewski, Bjorn Andersson, Sebastian Reichel,
Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Shivendra Pratap,
Srinivas Kandagatla
Add ABI documentation for /sys/class/reboot-mode/*/reboot_modes,
a read-only sysfs attribute exposing the list of supported
reboot-mode arguments. This file is created by reboot-mode
framework and provides a user-readable interface to query
available reboot-mode arguments.
Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
---
.../testing/sysfs-class-reboot-mode-reboot_modes | 39 ++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-class-reboot-mode-reboot_modes b/Documentation/ABI/testing/sysfs-class-reboot-mode-reboot_modes
new file mode 100644
index 0000000000000000000000000000000000000000..7147a781e5d4d11977c3a156bf4308aa13310e39
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-reboot-mode-reboot_modes
@@ -0,0 +1,39 @@
+What: /sys/class/reboot-mode/<driver>/reboot_modes
+Date: July 2025
+KernelVersion: 6.16
+Contact: linux-pm@vger.kernel.org
+ Description:
+ This interface exposes the reboot-mode arguments
+ registered with the reboot-mode framework. It is
+ a read-only interface and provides a comma
+ separated list of reboot-mode arguments supported
+ on the current platform.
+ Example:
+ recovery,fastboot,bootloader
+
+ The exact sysfs path may vary depending on the
+ name of the driver that registers the arguments.
+ Example:
+ /sys/class/reboot-mode/nvmem-reboot-mode/reboot_modes
+ /sys/class/reboot-mode/syscon-reboot-mode/reboot_modes
+ /sys/class/reboot-mode/qcom-pon/reboot_modes
+
+ The supported arguments can be used by userspace
+ to invoke device reset using the reboot() system
+ call, with the "argument" as string to "*arg"
+ parameter along with LINUX_REBOOT_CMD_RESTART2.
+ Example:
+ reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
+ LINUX_REBOOT_CMD_RESTART2, "bootloader");
+
+ A driver can expose the supported arguments by
+ registering them with the reboot-mode framework
+ using the property names that follow the
+ mode-<argument> format.
+ Example:
+ mode-bootloader, mode-recovery.
+
+ This attribute is useful for scripts or initramfs
+ logic that need to programmatically determine
+ which reboot-mode arguments are valid before
+ triggering a reboot.
--
2.34.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v13 05/10] power: reset: reboot-mode: Expose sysfs for registered reboot_modes
2025-07-27 16:24 [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 Shivendra Pratap
` (3 preceding siblings ...)
2025-07-27 16:24 ` [PATCH v13 04/10] Documentation: ABI: Add sysfs-class-reboot-mode-reboot_modes Shivendra Pratap
@ 2025-07-27 16:24 ` Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 06/10] dt-bindings: arm: Document reboot mode magic Shivendra Pratap
` (5 subsequent siblings)
10 siblings, 0 replies; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-27 16:24 UTC (permalink / raw)
To: Bartosz Golaszewski, Bjorn Andersson, Sebastian Reichel,
Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Shivendra Pratap,
Srinivas Kandagatla
Currently, there is no standardized mechanism for userspace to
discover which reboot-modes are supported on a given platform.
This limitation forces tools and scripts to rely on hardcoded
assumptions about the supported reboot-modes.
Create a class 'reboot-mode' and a device under it to expose a
sysfs interface to show the available reboot mode arguments to
userspace.
Provision the register function with an additional parameter to
get an explicit driver_name. Create the device using this
driver_name. For platform drivers, use the driver_name configured
in dev node.
This results in the creation of:
/sys/class/reboot-mode/<driver>/reboot_modes
This read-only sysfs file will exposes the list of supported
reboot modes arguments provided by the driver, enabling userspace
to query the list of arguments.
Align the clean up path to maintain backward compatibility for
existing reboot-mode based drivers.
Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
---
drivers/power/reset/reboot-mode.c | 126 ++++++++++++++++++++++++++++++--------
include/linux/reboot-mode.h | 4 +-
2 files changed, 105 insertions(+), 25 deletions(-)
diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
index ac81b8b0a9b7fc31f8ef21024333a050087ce90f..4c23ff912fc6afbc6949bfdd6607781eccb4e85e 100644
--- a/drivers/power/reset/reboot-mode.c
+++ b/drivers/power/reset/reboot-mode.c
@@ -6,6 +6,7 @@
#define pr_fmt(fmt) "reboot-mode: " fmt
#include <linux/device.h>
+#include <linux/err.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/list.h>
@@ -23,6 +24,8 @@ struct mode_info {
struct list_head list;
};
+static struct class *rb_class;
+
static u64 get_reboot_mode_magic(struct reboot_mode_driver *reboot, const char *cmd)
{
const char *normal = "normal";
@@ -75,26 +78,116 @@ static int reboot_mode_notify(struct notifier_block *this,
return NOTIFY_DONE;
}
+static void release_reboot_mode_device(struct device *dev, void *res);
+
+static ssize_t reboot_modes_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct reboot_mode_driver **devres_reboot;
+ struct reboot_mode_driver *reboot;
+ struct mode_info *info;
+ ssize_t size = 0;
+
+ devres_reboot = devres_find(dev, release_reboot_mode_device, NULL, NULL);
+ if (!devres_reboot || !(*devres_reboot))
+ return -ENODATA;
+
+ reboot = *devres_reboot;
+ mutex_lock(&reboot->rb_lock);
+ list_for_each_entry(info, &reboot->head, list) {
+ size += sprintf(buf + size, "%s,", info->mode);
+ }
+ mutex_unlock(&reboot->rb_lock);
+
+ if (size) {
+ size += sprintf(buf + size - 1, "\n");
+ return size;
+ }
+
+ return -ENODATA;
+}
+static DEVICE_ATTR_RO(reboot_modes);
+
+static void release_reboot_mode_device(struct device *dev, void *res)
+{
+ struct reboot_mode_driver *reboot = *(struct reboot_mode_driver **)res;
+ struct mode_info *info;
+ struct mode_info *next;
+
+ unregister_reboot_notifier(&reboot->reboot_notifier);
+
+ mutex_lock(&reboot->rb_lock);
+ list_for_each_entry_safe(info, next, &reboot->head, list) {
+ list_del(&info->list);
+ kfree_const(info->mode);
+ kfree(info);
+ }
+ mutex_unlock(&reboot->rb_lock);
+
+ device_remove_file(reboot->reboot_dev, &dev_attr_reboot_modes);
+}
+
+static int create_reboot_mode_device(struct reboot_mode_driver *reboot,
+ const char *dev_name)
+{
+ struct reboot_mode_driver **dr;
+ int ret = 0;
+
+ if (!rb_class) {
+ rb_class = class_create("reboot-mode");
+ if (IS_ERR(rb_class))
+ return PTR_ERR(rb_class);
+ }
+
+ reboot->reboot_dev = device_create(rb_class, NULL, 0, NULL, dev_name);
+ if (IS_ERR(reboot->reboot_dev))
+ return PTR_ERR(reboot->reboot_dev);
+
+ ret = device_create_file(reboot->reboot_dev, &dev_attr_reboot_modes);
+ if (ret)
+ return ret;
+
+ dr = devres_alloc(release_reboot_mode_device, sizeof(*dr), GFP_KERNEL);
+ if (!dr) {
+ device_remove_file(reboot->reboot_dev, &dev_attr_reboot_modes);
+ return -ENOMEM;
+ }
+
+ *dr = reboot;
+ devres_add(reboot->reboot_dev, dr);
+
+ return ret;
+}
+
/**
* reboot_mode_register - register a reboot mode driver
* @reboot: reboot mode driver
* @np: Pointer to device tree node
+ * @driver_name: Name to use when exposing the sysfs interface
+ *
+ * Registers a reboot mode driver and sets up its sysfs entries
+ * under /sys/class/reboot-mode/<driver_name>/ to allow userspace
+ * interaction with available reboot modes. The DT node is used
+ * for parsing reboot-mode arguments.
*
* Returns: 0 on success or a negative error code on failure.
*/
-int reboot_mode_register(struct reboot_mode_driver *reboot, struct device_node *np)
+int reboot_mode_register(struct reboot_mode_driver *reboot, struct device_node *np,
+ const char *driver_name)
{
struct mode_info *info;
- struct mode_info *next;
struct property *prop;
size_t len = strlen(PREFIX);
u32 magic_arg1;
u32 magic_arg2;
int ret;
- if (!np)
+ if (!np || !driver_name)
return -EINVAL;
+ ret = create_reboot_mode_device(reboot, driver_name);
+ if (ret)
+ return ret;
+
INIT_LIST_HEAD(&reboot->head);
mutex_init(&reboot->rb_lock);
@@ -144,13 +237,8 @@ int reboot_mode_register(struct reboot_mode_driver *reboot, struct device_node *
return 0;
error:
- list_for_each_entry_safe(info, next, &reboot->head, list) {
- list_del(&info->list);
- kfree_const(info->mode);
- kfree(info);
- }
-
mutex_unlock(&reboot->rb_lock);
+ device_unregister(reboot->reboot_dev);
return ret;
}
EXPORT_SYMBOL_GPL(reboot_mode_register);
@@ -161,26 +249,16 @@ EXPORT_SYMBOL_GPL(reboot_mode_register);
*/
int reboot_mode_unregister(struct reboot_mode_driver *reboot)
{
- struct mode_info *info;
- struct mode_info *next;
-
- unregister_reboot_notifier(&reboot->reboot_notifier);
-
- mutex_lock(&reboot->rb_lock);
- list_for_each_entry_safe(info, next, &reboot->head, list) {
- list_del(&info->list);
- kfree_const(info->mode);
- kfree(info);
- }
- mutex_unlock(&reboot->rb_lock);
-
+ device_unregister(reboot->reboot_dev);
return 0;
}
EXPORT_SYMBOL_GPL(reboot_mode_unregister);
static void devm_reboot_mode_release(struct device *dev, void *res)
{
- reboot_mode_unregister(*(struct reboot_mode_driver **)res);
+ struct reboot_mode_driver *reboot = *(struct reboot_mode_driver **)res;
+
+ device_unregister(reboot->reboot_dev);
}
/**
@@ -200,7 +278,7 @@ int devm_reboot_mode_register(struct device *dev,
if (!dr)
return -ENOMEM;
- rc = reboot_mode_register(reboot, reboot->dev->of_node);
+ rc = reboot_mode_register(reboot, reboot->dev->of_node, reboot->dev->driver->name);
if (rc) {
devres_free(dr);
return rc;
diff --git a/include/linux/reboot-mode.h b/include/linux/reboot-mode.h
index 370228b5161963aac1d75af752ada0e8282b1078..0b9844a71224b3e4bcc0d1e396d6c9cb11ad8c97 100644
--- a/include/linux/reboot-mode.h
+++ b/include/linux/reboot-mode.h
@@ -7,6 +7,7 @@
struct reboot_mode_driver {
struct device *dev;
+ struct device *reboot_dev;
struct list_head head;
int (*write)(struct reboot_mode_driver *reboot, u64 magic);
struct notifier_block reboot_notifier;
@@ -14,7 +15,8 @@ struct reboot_mode_driver {
struct mutex rb_lock;
};
-int reboot_mode_register(struct reboot_mode_driver *reboot, struct device_node *np);
+int reboot_mode_register(struct reboot_mode_driver *reboot, struct device_node *np,
+ const char *driver_name);
int reboot_mode_unregister(struct reboot_mode_driver *reboot);
int devm_reboot_mode_register(struct device *dev,
struct reboot_mode_driver *reboot);
--
2.34.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v13 06/10] dt-bindings: arm: Document reboot mode magic
2025-07-27 16:24 [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 Shivendra Pratap
` (4 preceding siblings ...)
2025-07-27 16:24 ` [PATCH v13 05/10] power: reset: reboot-mode: Expose sysfs for registered reboot_modes Shivendra Pratap
@ 2025-07-27 16:24 ` Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode Shivendra Pratap
` (4 subsequent siblings)
10 siblings, 0 replies; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-27 16:24 UTC (permalink / raw)
To: Bartosz Golaszewski, Bjorn Andersson, Sebastian Reichel,
Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Shivendra Pratap,
Srinivas Kandagatla, Elliot Berman
From: Elliot Berman <elliot.berman@oss.qualcomm.com>
Add bindings to describe vendor-specific reboot modes. Values here
correspond to valid parameters to vendor-specific reset types in PSCI
SYSTEM_RESET2 call.
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Elliot Berman <elliot.berman@oss.qualcomm.com>
Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
---
Documentation/devicetree/bindings/arm/psci.yaml | 43 +++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/Documentation/devicetree/bindings/arm/psci.yaml b/Documentation/devicetree/bindings/arm/psci.yaml
index 7360a2849b5bd1e4cbadac533c1a7228573288d4..da3a584c76b48e313a5d4cb7c8e0c3a3628fd1bb 100644
--- a/Documentation/devicetree/bindings/arm/psci.yaml
+++ b/Documentation/devicetree/bindings/arm/psci.yaml
@@ -98,6 +98,27 @@ properties:
[1] Kernel documentation - ARM idle states bindings
Documentation/devicetree/bindings/cpu/idle-states.yaml
+ reboot-mode:
+ type: object
+ $ref: /schemas/power/reset/reboot-mode.yaml#
+ unevaluatedProperties: false
+ properties:
+ # "mode-normal" is just SYSTEM_RESET
+ mode-normal: false
+ patternProperties:
+ "^mode-.*$":
+ minItems: 1
+ maxItems: 2
+ description: |
+ Describes a vendor-specific reset type. The string after "mode-"
+ maps a reboot mode to the parameters in the PSCI SYSTEM_RESET2 call.
+
+ Parameters are named mode-xxx = <type[, cookie]>, where xxx
+ is the name of the magic reboot mode, type is the lower 31 bits
+ of the reset_type, and, optionally, the cookie value. If the cookie
+ is not provided, it is defaulted to zero.
+ The 31st bit (vendor-resets) will be implicitly set by the driver.
+
patternProperties:
"^power-domain-":
$ref: /schemas/power/power-domain.yaml#
@@ -137,6 +158,15 @@ allOf:
required:
- cpu_off
- cpu_on
+ - if:
+ not:
+ properties:
+ compatible:
+ contains:
+ const: arm,psci-1.0
+ then:
+ properties:
+ reset-types: false
additionalProperties: false
@@ -261,4 +291,17 @@ examples:
domain-idle-states = <&cluster_ret>, <&cluster_pwrdn>;
};
};
+
+ - |+
+
+ // Case 5: SYSTEM_RESET2 vendor resets
+ psci {
+ compatible = "arm,psci-1.0";
+ method = "smc";
+
+ reboot-mode {
+ mode-edl = <0>;
+ mode-bootloader = <1 2>;
+ };
+ };
...
--
2.34.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-27 16:24 [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 Shivendra Pratap
` (5 preceding siblings ...)
2025-07-27 16:24 ` [PATCH v13 06/10] dt-bindings: arm: Document reboot mode magic Shivendra Pratap
@ 2025-07-27 16:24 ` Shivendra Pratap
2025-07-28 4:53 ` Krzysztof Kozlowski
2025-07-30 8:44 ` André Draszik
2025-07-27 16:24 ` [PATCH v13 08/10] arm64: dts: qcom: qcm6490-idp: Add PSCI SYSTEM_RESET2 types Shivendra Pratap
` (3 subsequent siblings)
10 siblings, 2 replies; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-27 16:24 UTC (permalink / raw)
To: Bartosz Golaszewski, Bjorn Andersson, Sebastian Reichel,
Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Shivendra Pratap,
Srinivas Kandagatla
SoC vendors have different types of resets which are controlled
through various hardware registers. For instance, Qualcomm SoC
may have a requirement that reboot with “bootloader” command
should reboot the device to bootloader flashing mode and reboot
with “edl” should reboot the device into Emergency flashing mode.
Setting up such reboots on Qualcomm devices can be inconsistent
across SoC platforms and may require setting different HW
registers, where some of these registers may not be accessible to
HLOS. These knobs evolve over product generations and require
more drivers. PSCI spec defines, SYSTEM_RESET2, vendor-specific
reset which can help align this requirement. Add support for PSCI
SYSTEM_RESET2, vendor-specific resets and align the implementation
to allow user-space initiated reboots to trigger these resets.
Introduce a late_initcall to register PSCI vendor-specific resets
as reboot modes. Implement a reboot-mode write function that sets
reset_type and cookie values during the reboot notifier callback.
Introduce a firmware-based call for SYSTEM_RESET2 vendor-specific
reset in the psci_sys_reset path, using reset_type and cookie if
supported by secure firmware.
By using the above implementation, userspace will be able to issue
such resets using the reboot() system call with the "*arg"
parameter as a string based command. The commands can be defined
in PSCI device tree node as “reset-types” and are based on the
reboot-mode based commands.
Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
---
drivers/firmware/psci/Kconfig | 2 ++
drivers/firmware/psci/psci.c | 57 ++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/psci/Kconfig b/drivers/firmware/psci/Kconfig
index 97944168b5e66aea1e38a7eb2d4ced8348fce64b..93ff7b071a0c364a376699733e6bc5654d56a17f 100644
--- a/drivers/firmware/psci/Kconfig
+++ b/drivers/firmware/psci/Kconfig
@@ -1,6 +1,8 @@
# SPDX-License-Identifier: GPL-2.0-only
config ARM_PSCI_FW
bool
+ select POWER_RESET
+ select REBOOT_MODE
config ARM_PSCI_CHECKER
bool "ARM PSCI checker"
diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
index 38ca190d4a22d6e7e0f06420e8478a2b0ec2fe6f..e14bcdbec1750db8aa9297c8bcdb242f58cc420e 100644
--- a/drivers/firmware/psci/psci.c
+++ b/drivers/firmware/psci/psci.c
@@ -17,6 +17,7 @@
#include <linux/printk.h>
#include <linux/psci.h>
#include <linux/reboot.h>
+#include <linux/reboot-mode.h>
#include <linux/slab.h>
#include <linux/suspend.h>
@@ -51,6 +52,14 @@ static int resident_cpu = -1;
struct psci_operations psci_ops;
static enum arm_smccc_conduit psci_conduit = SMCCC_CONDUIT_NONE;
+struct psci_vendor_sysreset2 {
+ u32 reset_type;
+ u32 cookie;
+ bool valid;
+};
+
+static struct psci_vendor_sysreset2 vendor_reset;
+
bool psci_tos_resident_on(int cpu)
{
return cpu == resident_cpu;
@@ -309,7 +318,10 @@ static int get_set_conduit_method(const struct device_node *np)
static int psci_sys_reset(struct notifier_block *nb, unsigned long action,
void *data)
{
- if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
+ if (vendor_reset.valid && psci_system_reset2_supported) {
+ invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), vendor_reset.reset_type,
+ vendor_reset.cookie, 0);
+ } else if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
psci_system_reset2_supported) {
/*
* reset_type[31] = 0 (architectural)
@@ -547,6 +559,49 @@ static const struct platform_suspend_ops psci_suspend_ops = {
.enter = psci_system_suspend_enter,
};
+static int psci_set_vendor_sys_reset2(struct reboot_mode_driver *reboot, u64 magic)
+{
+ u32 magic_32;
+
+ if (psci_system_reset2_supported) {
+ magic_32 = magic & 0xFFFFFFFF;
+ vendor_reset.reset_type = PSCI_1_1_RESET_TYPE_VENDOR_START | magic_32;
+ vendor_reset.cookie = (magic >> 32) & 0xFFFFFFFF;
+ vendor_reset.valid = true;
+ }
+
+ return NOTIFY_DONE;
+}
+
+static int __init psci_init_vendor_reset(void)
+{
+ struct reboot_mode_driver *reboot;
+ struct device_node *np;
+ int ret;
+
+ np = of_find_node_by_path("/psci/reboot-mode");
+ if (!np)
+ return -ENODEV;
+
+ reboot = kzalloc(sizeof(*reboot), GFP_KERNEL);
+ if (!reboot) {
+ of_node_put(np);
+ return -ENOMEM;
+ }
+
+ reboot->write = psci_set_vendor_sys_reset2;
+
+ ret = reboot_mode_register(reboot, np, "psci");
+ if (ret) {
+ of_node_put(np);
+ kfree(reboot);
+ return ret;
+ }
+
+ return 0;
+}
+late_initcall(psci_init_vendor_reset)
+
static void __init psci_init_system_reset2(void)
{
int ret;
--
2.34.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v13 08/10] arm64: dts: qcom: qcm6490-idp: Add PSCI SYSTEM_RESET2 types
2025-07-27 16:24 [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 Shivendra Pratap
` (6 preceding siblings ...)
2025-07-27 16:24 ` [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode Shivendra Pratap
@ 2025-07-27 16:24 ` Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 09/10] arm64: dts: qcom: qcs6490-rb3gen2: " Shivendra Pratap
` (2 subsequent siblings)
10 siblings, 0 replies; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-27 16:24 UTC (permalink / raw)
To: Bartosz Golaszewski, Bjorn Andersson, Sebastian Reichel,
Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Shivendra Pratap,
Srinivas Kandagatla, Elliot Berman, Konrad Dybcio
From: Elliot Berman <elliot.berman@oss.qualcomm.com>
Add support for SYSTEM_RESET2 vendor-specific resets in
qcm6490-idp as reboot-modes. Describe the resets: "bootloader"
will cause device to reboot and stop in the bootloader's fastboot
mode. "edl" will cause device to reboot into "emergency download
mode", which permits loading images via the Firehose protocol.
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Elliot Berman <elliot.berman@oss.qualcomm.com>
Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
---
arch/arm64/boot/dts/qcom/qcm6490-idp.dts | 7 +++++++
arch/arm64/boot/dts/qcom/sc7280.dtsi | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/qcom/qcm6490-idp.dts b/arch/arm64/boot/dts/qcom/qcm6490-idp.dts
index 7a155ef6492e176390faa3f2dbe419f5cfa62f0d..d25dbdde7dcee9fa3f1bd48a38baeae0f063023c 100644
--- a/arch/arm64/boot/dts/qcom/qcm6490-idp.dts
+++ b/arch/arm64/boot/dts/qcom/qcm6490-idp.dts
@@ -654,6 +654,13 @@ &pon_resin {
status = "okay";
};
+&psci {
+ reboot-mode {
+ mode-bootloader = <0x10001 0x2>;
+ mode-edl = <0 0x1>;
+ };
+};
+
&qupv3_id_0 {
status = "okay";
};
diff --git a/arch/arm64/boot/dts/qcom/sc7280.dtsi b/arch/arm64/boot/dts/qcom/sc7280.dtsi
index 64a2abd3010018e94eb50c534a509d6b4cf2473b..e6a99ef50b9b9ade9d2a71a14fcde429f8076dd5 100644
--- a/arch/arm64/boot/dts/qcom/sc7280.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc7280.dtsi
@@ -857,7 +857,7 @@ pmu-a78 {
interrupts = <GIC_PPI 7 IRQ_TYPE_LEVEL_LOW>;
};
- psci {
+ psci: psci {
compatible = "arm,psci-1.0";
method = "smc";
--
2.34.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v13 09/10] arm64: dts: qcom: qcs6490-rb3gen2: Add PSCI SYSTEM_RESET2 types
2025-07-27 16:24 [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 Shivendra Pratap
` (7 preceding siblings ...)
2025-07-27 16:24 ` [PATCH v13 08/10] arm64: dts: qcom: qcm6490-idp: Add PSCI SYSTEM_RESET2 types Shivendra Pratap
@ 2025-07-27 16:24 ` Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 10/10] arm64: dts: qcom: sa8775p-ride: " Shivendra Pratap
2025-07-30 8:50 ` [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 André Draszik
10 siblings, 0 replies; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-27 16:24 UTC (permalink / raw)
To: Bartosz Golaszewski, Bjorn Andersson, Sebastian Reichel,
Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Shivendra Pratap,
Srinivas Kandagatla, Elliot Berman, Konrad Dybcio
From: Elliot Berman <elliot.berman@oss.qualcomm.com>
Add support for SYSTEM_RESET2 vendor-specific resets in
qcs6490-rb3gen2 as reboot-modes. Describe the resets:
"bootloader" will cause device to reboot and stop in the
bootloader's fastboot mode. "edl" will cause device to reboot
into "emergency download mode", which permits loading images via
the Firehose protocol.
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Elliot Berman <elliot.berman@oss.qualcomm.com>
Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
---
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts b/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts
index 5fbcd48f2e2d839835fa464a8d5682f00557f82e..8cf289a3cfc4ac7014885494c27fb003a7258519 100644
--- a/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts
+++ b/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts
@@ -966,6 +966,13 @@ &pon_resin {
status = "okay";
};
+&psci {
+ reboot-mode {
+ mode-bootloader = <0x10001 0x2>;
+ mode-edl = <0 0x1>;
+ };
+};
+
&qup_uart7_cts {
/*
* Configure a bias-bus-hold on CTS to lower power
--
2.34.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v13 10/10] arm64: dts: qcom: sa8775p-ride: Add PSCI SYSTEM_RESET2 types
2025-07-27 16:24 [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 Shivendra Pratap
` (8 preceding siblings ...)
2025-07-27 16:24 ` [PATCH v13 09/10] arm64: dts: qcom: qcs6490-rb3gen2: " Shivendra Pratap
@ 2025-07-27 16:24 ` Shivendra Pratap
2025-07-30 8:50 ` [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 André Draszik
10 siblings, 0 replies; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-27 16:24 UTC (permalink / raw)
To: Bartosz Golaszewski, Bjorn Andersson, Sebastian Reichel,
Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Shivendra Pratap,
Srinivas Kandagatla, Elliot Berman, Konrad Dybcio
From: Elliot Berman <elliot.berman@oss.qualcomm.com>
Add support for SYSTEM_RESET2 vendor-specific resets in
sa8775p-ride as reboot-modes. Describe the reset types:
"bootloader" will cause device to reboot and stop in the
bootloader's fastboot mode. "edl" will cause device to reboot
into "emergency download mode", which permits loading images via
the Firehose protocol.
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Elliot Berman <elliot.berman@oss.qualcomm.com>
Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
---
arch/arm64/boot/dts/qcom/sa8775p-ride.dtsi | 7 +++++++
arch/arm64/boot/dts/qcom/sa8775p.dtsi | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/qcom/sa8775p-ride.dtsi b/arch/arm64/boot/dts/qcom/sa8775p-ride.dtsi
index 63b3031cfcc15fe2cce58c0fb7502b19f058b80c..b1bbd3270afc65e9e036e8098ae7cec3d3363a32 100644
--- a/arch/arm64/boot/dts/qcom/sa8775p-ride.dtsi
+++ b/arch/arm64/boot/dts/qcom/sa8775p-ride.dtsi
@@ -874,6 +874,13 @@ &pmm8654au_3_gpios {
"GNSS_BOOT_MODE";
};
+&psci {
+ reboot-mode {
+ mode-bootloader = <0x10001 0x2>;
+ mode-edl = <0 0x1>;
+ };
+};
+
&qupv3_id_1 {
status = "okay";
};
diff --git a/arch/arm64/boot/dts/qcom/sa8775p.dtsi b/arch/arm64/boot/dts/qcom/sa8775p.dtsi
index 9997a29901f57d7894dc1eacb6a809caa427c6c4..52466607035e663f4dc6e5c97223d5c0404650e2 100644
--- a/arch/arm64/boot/dts/qcom/sa8775p.dtsi
+++ b/arch/arm64/boot/dts/qcom/sa8775p.dtsi
@@ -622,7 +622,7 @@ pmu {
interrupts = <GIC_PPI 7 IRQ_TYPE_LEVEL_HIGH>;
};
- psci {
+ psci: psci {
compatible = "arm,psci-1.0";
method = "smc";
--
2.34.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-27 16:24 ` [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode Shivendra Pratap
@ 2025-07-28 4:53 ` Krzysztof Kozlowski
2025-07-28 9:44 ` Dmitry Baryshkov
2025-07-30 8:44 ` André Draszik
1 sibling, 1 reply; 32+ messages in thread
From: Krzysztof Kozlowski @ 2025-07-28 4:53 UTC (permalink / raw)
To: Shivendra Pratap, Bartosz Golaszewski, Bjorn Andersson,
Sebastian Reichel, Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Srinivas Kandagatla
On 27/07/2025 18:24, Shivendra Pratap wrote:
> +
> +static int __init psci_init_vendor_reset(void)
> +{
> + struct reboot_mode_driver *reboot;
> + struct device_node *np;
> + int ret;
> +
> + np = of_find_node_by_path("/psci/reboot-mode");
Why are you looking by full path, not by compatible? Is the ABI - above
path - expressed anywhere?
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-28 4:53 ` Krzysztof Kozlowski
@ 2025-07-28 9:44 ` Dmitry Baryshkov
2025-07-28 11:52 ` Krzysztof Kozlowski
0 siblings, 1 reply; 32+ messages in thread
From: Dmitry Baryshkov @ 2025-07-28 9:44 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Shivendra Pratap, Bartosz Golaszewski, Bjorn Andersson,
Sebastian Reichel, Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Srinivas Kandagatla
On Mon, Jul 28, 2025 at 06:53:14AM +0200, Krzysztof Kozlowski wrote:
> On 27/07/2025 18:24, Shivendra Pratap wrote:
> > +
> > +static int __init psci_init_vendor_reset(void)
> > +{
> > + struct reboot_mode_driver *reboot;
> > + struct device_node *np;
> > + int ret;
> > +
> > + np = of_find_node_by_path("/psci/reboot-mode");
>
>
> Why are you looking by full path, not by compatible? Is the ABI - above
> path - expressed anywhere?
PSCI node is required to have a node name of psci, it doesn't have MMIO,
so it resides in the root node and the reboot-mode is defined in the
previous patch. So, I'd assume, the path is defined.
However the question might be slightly different: why do we need a
separate initcall for reboot handling? The reasons for that need to be
documented in the commit message.
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-28 9:44 ` Dmitry Baryshkov
@ 2025-07-28 11:52 ` Krzysztof Kozlowski
2025-07-28 12:03 ` Dmitry Baryshkov
0 siblings, 1 reply; 32+ messages in thread
From: Krzysztof Kozlowski @ 2025-07-28 11:52 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: Shivendra Pratap, Bartosz Golaszewski, Bjorn Andersson,
Sebastian Reichel, Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Srinivas Kandagatla
On 28/07/2025 11:44, Dmitry Baryshkov wrote:
> On Mon, Jul 28, 2025 at 06:53:14AM +0200, Krzysztof Kozlowski wrote:
>> On 27/07/2025 18:24, Shivendra Pratap wrote:
>>> +
>>> +static int __init psci_init_vendor_reset(void)
>>> +{
>>> + struct reboot_mode_driver *reboot;
>>> + struct device_node *np;
>>> + int ret;
>>> +
>>> + np = of_find_node_by_path("/psci/reboot-mode");
>>
>>
>> Why are you looking by full path, not by compatible? Is the ABI - above
>> path - expressed anywhere?
>
> PSCI node is required to have a node name of psci, it doesn't have MMIO,
This is true
> so it resides in the root node
This might be or not might be true. It is not defined by ABI. Anyway,
you answered where the ABI would be documented, even though as I said it
is not (/psci is not), but does not answer to first part: why you are
not using compatibles which is always the preferred method?
> and the reboot-mode is defined in the
> previous patch. So, I'd assume, the path is defined.
As I said, path is not. only psci/reboot-mode is.
>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-28 11:52 ` Krzysztof Kozlowski
@ 2025-07-28 12:03 ` Dmitry Baryshkov
2025-07-28 12:23 ` Krzysztof Kozlowski
2025-07-28 16:08 ` Shivendra Pratap
0 siblings, 2 replies; 32+ messages in thread
From: Dmitry Baryshkov @ 2025-07-28 12:03 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Shivendra Pratap, Bartosz Golaszewski, Bjorn Andersson,
Sebastian Reichel, Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Srinivas Kandagatla
On 28/07/2025 14:52, Krzysztof Kozlowski wrote:
> On 28/07/2025 11:44, Dmitry Baryshkov wrote:
>> On Mon, Jul 28, 2025 at 06:53:14AM +0200, Krzysztof Kozlowski wrote:
>>> On 27/07/2025 18:24, Shivendra Pratap wrote:
>>>> +
>>>> +static int __init psci_init_vendor_reset(void)
>>>> +{
>>>> + struct reboot_mode_driver *reboot;
>>>> + struct device_node *np;
>>>> + int ret;
>>>> +
>>>> + np = of_find_node_by_path("/psci/reboot-mode");
>>>
>>>
>>> Why are you looking by full path, not by compatible? Is the ABI - above
>>> path - expressed anywhere?
>>
>> PSCI node is required to have a node name of psci, it doesn't have MMIO,
>
> This is true
>
>> so it resides in the root node
>
> This might be or not might be true. It is not defined by ABI. Anyway,
> you answered where the ABI would be documented, even though as I said it
> is not (/psci is not), but does not answer to first part: why you are
> not using compatibles which is always the preferred method?
That's a good question, I've added one from my side: why do we need an
extra late_init call.
>
>
>> and the reboot-mode is defined in the
>> previous patch. So, I'd assume, the path is defined.
>
> As I said, path is not. only psci/reboot-mode is.
Do we have an _actual_ use case where PSCI node is not at at root node?
If not, it's obviously a deficiency of the schema. Could you please
provide suggestions on how to describe that in DT schema?
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-28 12:03 ` Dmitry Baryshkov
@ 2025-07-28 12:23 ` Krzysztof Kozlowski
2025-07-28 13:23 ` Sudeep Holla
2025-07-28 15:54 ` Shivendra Pratap
2025-07-28 16:08 ` Shivendra Pratap
1 sibling, 2 replies; 32+ messages in thread
From: Krzysztof Kozlowski @ 2025-07-28 12:23 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: Shivendra Pratap, Bartosz Golaszewski, Bjorn Andersson,
Sebastian Reichel, Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Srinivas Kandagatla
On 28/07/2025 14:03, Dmitry Baryshkov wrote:
>>
>>> and the reboot-mode is defined in the
>>> previous patch. So, I'd assume, the path is defined.
>>
>> As I said, path is not. only psci/reboot-mode is.
>
> Do we have an _actual_ use case where PSCI node is not at at root node?
Yes, many cases, because it belongs as well to firmware node.
> If not, it's obviously a deficiency of the schema. Could you please
> provide suggestions on how to describe that in DT schema?
I do not see deficiency. There is no ABI that psci must be root node, so
there is no issue to fix there.
If you want to add such ABI, I will answer: no, don't, because we do not
want paths or node names to be the ABI.
Compatible is the ABI.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-28 12:23 ` Krzysztof Kozlowski
@ 2025-07-28 13:23 ` Sudeep Holla
2025-07-28 15:37 ` Dmitry Baryshkov
2025-07-28 15:54 ` Shivendra Pratap
1 sibling, 1 reply; 32+ messages in thread
From: Sudeep Holla @ 2025-07-28 13:23 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Dmitry Baryshkov, Sudeep Holla, Shivendra Pratap,
Bartosz Golaszewski, Bjorn Andersson, Sebastian Reichel,
Rob Herring, Souvik Chakravarty, Krzysztof Kozlowski,
Conor Dooley, Andy Yan, Mark Rutland, Lorenzo Pieralisi,
Arnd Bergmann, Konrad Dybcio, cros-qcom-dts-watchers, Vinod Koul,
Catalin Marinas, Will Deacon, Florian Fainelli, Mukesh Ojha,
Stephen Boyd, Andre Draszik, linux-pm, linux-kernel, devicetree,
linux-arm-kernel, linux-arm-msm, Elliot Berman,
Srinivas Kandagatla
On Mon, Jul 28, 2025 at 02:23:14PM +0200, Krzysztof Kozlowski wrote:
> On 28/07/2025 14:03, Dmitry Baryshkov wrote:
> >>
> >>> and the reboot-mode is defined in the
> >>> previous patch. So, I'd assume, the path is defined.
> >>
> >> As I said, path is not. only psci/reboot-mode is.
> >
> > Do we have an _actual_ use case where PSCI node is not at at root node?
>
> Yes, many cases, because it belongs as well to firmware node.
>
+1, I was about to make similar comment. /psci predates the formal push
to put all firmware related nodes under /firmware, so /firmware/psci is
equally possible path and should be recommended one so that all such
firmware related nodes are contained under /firmware.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-28 13:23 ` Sudeep Holla
@ 2025-07-28 15:37 ` Dmitry Baryshkov
0 siblings, 0 replies; 32+ messages in thread
From: Dmitry Baryshkov @ 2025-07-28 15:37 UTC (permalink / raw)
To: Sudeep Holla
Cc: Krzysztof Kozlowski, Shivendra Pratap, Bartosz Golaszewski,
Bjorn Andersson, Sebastian Reichel, Rob Herring,
Souvik Chakravarty, Krzysztof Kozlowski, Conor Dooley, Andy Yan,
Mark Rutland, Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Srinivas Kandagatla
On Mon, Jul 28, 2025 at 02:23:17PM +0100, Sudeep Holla wrote:
> On Mon, Jul 28, 2025 at 02:23:14PM +0200, Krzysztof Kozlowski wrote:
> > On 28/07/2025 14:03, Dmitry Baryshkov wrote:
> > >>
> > >>> and the reboot-mode is defined in the
> > >>> previous patch. So, I'd assume, the path is defined.
> > >>
> > >> As I said, path is not. only psci/reboot-mode is.
> > >
> > > Do we have an _actual_ use case where PSCI node is not at at root node?
> >
> > Yes, many cases, because it belongs as well to firmware node.
> >
>
> +1, I was about to make similar comment. /psci predates the formal push
> to put all firmware related nodes under /firmware, so /firmware/psci is
> equally possible path and should be recommended one so that all such
> firmware related nodes are contained under /firmware.
Ack, thanks for the explanation.
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-28 12:23 ` Krzysztof Kozlowski
2025-07-28 13:23 ` Sudeep Holla
@ 2025-07-28 15:54 ` Shivendra Pratap
2025-07-28 18:29 ` Dmitry Baryshkov
1 sibling, 1 reply; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-28 15:54 UTC (permalink / raw)
To: Krzysztof Kozlowski, Dmitry Baryshkov
Cc: Bartosz Golaszewski, Bjorn Andersson, Sebastian Reichel,
Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Srinivas Kandagatla
On 7/28/2025 5:53 PM, Krzysztof Kozlowski wrote:
> On 28/07/2025 14:03, Dmitry Baryshkov wrote:
>>>
>>>> and the reboot-mode is defined in the
>>>> previous patch. So, I'd assume, the path is defined.
>>>
>>> As I said, path is not. only psci/reboot-mode is.
>>
>> Do we have an _actual_ use case where PSCI node is not at at root node?
>
> Yes, many cases, because it belongs as well to firmware node.
>
>> If not, it's obviously a deficiency of the schema. Could you please
>> provide suggestions on how to describe that in DT schema?
>
> I do not see deficiency. There is no ABI that psci must be root node, so
> there is no issue to fix there.
>
> If you want to add such ABI, I will answer: no, don't, because we do not
> want paths or node names to be the ABI.
>
> Compatible is the ABI.
Will define a compatible for psci->reboot-mode node and use it to find the
node. Hope its fine to define a compatible for reboot-mode which is defined
as a property inside psci?
thanks.
>
> Best regards,
> Krzysztof
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-28 12:03 ` Dmitry Baryshkov
2025-07-28 12:23 ` Krzysztof Kozlowski
@ 2025-07-28 16:08 ` Shivendra Pratap
1 sibling, 0 replies; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-28 16:08 UTC (permalink / raw)
To: Dmitry Baryshkov, Krzysztof Kozlowski
Cc: Bartosz Golaszewski, Bjorn Andersson, Sebastian Reichel,
Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Srinivas Kandagatla
On 7/28/2025 5:33 PM, Dmitry Baryshkov wrote:
> On 28/07/2025 14:52, Krzysztof Kozlowski wrote:
>> On 28/07/2025 11:44, Dmitry Baryshkov wrote:
>>> On Mon, Jul 28, 2025 at 06:53:14AM +0200, Krzysztof Kozlowski wrote:
>>>> On 27/07/2025 18:24, Shivendra Pratap wrote:
>>>>> +
>>>>> +static int __init psci_init_vendor_reset(void)
>>>>> +{
>>>>> + struct reboot_mode_driver *reboot;
>>>>> + struct device_node *np;
>>>>> + int ret;
>>>>> +
>>>>> + np = of_find_node_by_path("/psci/reboot-mode");
>>>>
>>>>
>>>> Why are you looking by full path, not by compatible? Is the ABI - above
>>>> path - expressed anywhere?
>>>
>>> PSCI node is required to have a node name of psci, it doesn't have MMIO,
>>
>> This is true
>>
>>> so it resides in the root node
>>
>> This might be or not might be true. It is not defined by ABI. Anyway,
>> you answered where the ABI would be documented, even though as I said it
>> is not (/psci is not), but does not answer to first part: why you are
>> not using compatibles which is always the preferred method?
>
> That's a good question, I've added one from my side: why do we need an extra late_init call.
"psci" registers with reboot-mode which creates a class and a device under it for exposing
the sysfs.
psci_dt_init is called very early around setup_kernel. At that stage the class creating fails,
so psci cannot register with reboot-mode at this stage.
At early_init, the class creation is success, but the created class and the sysfs does not
enumerates under /sys/class/.
So i added explicit late_init call for this where the sysfs creation seems to work fine.
>
>>
>>
>>> and the reboot-mode is defined in the
>>> previous patch. So, I'd assume, the path is defined.
>>
>> As I said, path is not. only psci/reboot-mode is.
>
> Do we have an _actual_ use case where PSCI node is not at at root node? If not, it's obviously a deficiency of the schema. Could you please provide suggestions on how to describe that in DT schema?
>
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-28 15:54 ` Shivendra Pratap
@ 2025-07-28 18:29 ` Dmitry Baryshkov
2025-07-29 3:14 ` Shivendra Pratap
0 siblings, 1 reply; 32+ messages in thread
From: Dmitry Baryshkov @ 2025-07-28 18:29 UTC (permalink / raw)
To: Shivendra Pratap, Krzysztof Kozlowski
Cc: Bartosz Golaszewski, Bjorn Andersson, Sebastian Reichel,
Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Srinivas Kandagatla
On 28/07/2025 18:54, Shivendra Pratap wrote:
>
>
> On 7/28/2025 5:53 PM, Krzysztof Kozlowski wrote:
>> On 28/07/2025 14:03, Dmitry Baryshkov wrote:
>>>>
>>>>> and the reboot-mode is defined in the
>>>>> previous patch. So, I'd assume, the path is defined.
>>>>
>>>> As I said, path is not. only psci/reboot-mode is.
>>>
>>> Do we have an _actual_ use case where PSCI node is not at at root node?
>>
>> Yes, many cases, because it belongs as well to firmware node.
>>
>>> If not, it's obviously a deficiency of the schema. Could you please
>>> provide suggestions on how to describe that in DT schema?
>>
>> I do not see deficiency. There is no ABI that psci must be root node, so
>> there is no issue to fix there.
>>
>> If you want to add such ABI, I will answer: no, don't, because we do not
>> want paths or node names to be the ABI.
>>
>> Compatible is the ABI.
> Will define a compatible for psci->reboot-mode node and use it to find the
> node. Hope its fine to define a compatible for reboot-mode which is defined
> as a property inside psci?
I think it was more about finding the PSCI node.
>
> thanks.
>>
>> Best regards,
>> Krzysztof
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-28 18:29 ` Dmitry Baryshkov
@ 2025-07-29 3:14 ` Shivendra Pratap
0 siblings, 0 replies; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-29 3:14 UTC (permalink / raw)
To: Dmitry Baryshkov, Krzysztof Kozlowski
Cc: Bartosz Golaszewski, Bjorn Andersson, Sebastian Reichel,
Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli, Mukesh Ojha, Stephen Boyd, Andre Draszik,
linux-pm, linux-kernel, devicetree, linux-arm-kernel,
linux-arm-msm, Elliot Berman, Srinivas Kandagatla
On 7/28/2025 11:59 PM, Dmitry Baryshkov wrote:
> On 28/07/2025 18:54, Shivendra Pratap wrote:
>>
>>
>> On 7/28/2025 5:53 PM, Krzysztof Kozlowski wrote:
>>> On 28/07/2025 14:03, Dmitry Baryshkov wrote:
>>>>>
>>>>>> and the reboot-mode is defined in the
>>>>>> previous patch. So, I'd assume, the path is defined.
>>>>>
>>>>> As I said, path is not. only psci/reboot-mode is.
>>>>
>>>> Do we have an _actual_ use case where PSCI node is not at at root node?
>>>
>>> Yes, many cases, because it belongs as well to firmware node.
>>>
>>>> If not, it's obviously a deficiency of the schema. Could you please
>>>> provide suggestions on how to describe that in DT schema?
>>>
>>> I do not see deficiency. There is no ABI that psci must be root node, so
>>> there is no issue to fix there.
>>>
>>> If you want to add such ABI, I will answer: no, don't, because we do not
>>> want paths or node names to be the ABI.
>>>
>>> Compatible is the ABI.
>> Will define a compatible for psci->reboot-mode node and use it to find the
>> node. Hope its fine to define a compatible for reboot-mode which is defined
>> as a property inside psci?
>
> I think it was more about finding the PSCI node.
can either find for psci node using psci compatible "arm,psci-1.0". And then
look for reboot-mode node inside psci.
or can directly define a compatible for reboot-mode and find it using compatible.
Is there any other suggestion to find this node?
>
>>
>> thanks.
>>>
>>> Best regards,
>>> Krzysztof
>
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-27 16:24 ` [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode Shivendra Pratap
2025-07-28 4:53 ` Krzysztof Kozlowski
@ 2025-07-30 8:44 ` André Draszik
2025-07-30 13:03 ` Shivendra Pratap
1 sibling, 1 reply; 32+ messages in thread
From: André Draszik @ 2025-07-30 8:44 UTC (permalink / raw)
To: Shivendra Pratap, Bartosz Golaszewski, Bjorn Andersson,
Sebastian Reichel, Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, linux-pm,
linux-kernel, devicetree, linux-arm-kernel, linux-arm-msm,
Elliot Berman, Srinivas Kandagatla
On Sun, 2025-07-27 at 21:54 +0530, Shivendra Pratap wrote:
> SoC vendors have different types of resets which are controlled
> through various hardware registers. For instance, Qualcomm SoC
> may have a requirement that reboot with “bootloader” command
> should reboot the device to bootloader flashing mode and reboot
> with “edl” should reboot the device into Emergency flashing mode.
> Setting up such reboots on Qualcomm devices can be inconsistent
> across SoC platforms and may require setting different HW
> registers, where some of these registers may not be accessible to
> HLOS. These knobs evolve over product generations and require
> more drivers. PSCI spec defines, SYSTEM_RESET2, vendor-specific
> reset which can help align this requirement. Add support for PSCI
> SYSTEM_RESET2, vendor-specific resets and align the implementation
> to allow user-space initiated reboots to trigger these resets.
>
> Introduce a late_initcall to register PSCI vendor-specific resets
> as reboot modes. Implement a reboot-mode write function that sets
> reset_type and cookie values during the reboot notifier callback.
> Introduce a firmware-based call for SYSTEM_RESET2 vendor-specific
> reset in the psci_sys_reset path, using reset_type and cookie if
> supported by secure firmware.
>
> By using the above implementation, userspace will be able to issue
> such resets using the reboot() system call with the "*arg"
> parameter as a string based command. The commands can be defined
> in PSCI device tree node as “reset-types” and are based on the
> reboot-mode based commands.
>
> Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
> ---
> drivers/firmware/psci/Kconfig | 2 ++
> drivers/firmware/psci/psci.c | 57 ++++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 58 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/psci/Kconfig b/drivers/firmware/psci/Kconfig
> index 97944168b5e66aea1e38a7eb2d4ced8348fce64b..93ff7b071a0c364a376699733e6bc5654d56a17f 100644
> --- a/drivers/firmware/psci/Kconfig
> +++ b/drivers/firmware/psci/Kconfig
> @@ -1,6 +1,8 @@
> # SPDX-License-Identifier: GPL-2.0-only
> config ARM_PSCI_FW
> bool
> + select POWER_RESET
> + select REBOOT_MODE
>
> config ARM_PSCI_CHECKER
> bool "ARM PSCI checker"
> diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
> index 38ca190d4a22d6e7e0f06420e8478a2b0ec2fe6f..e14bcdbec1750db8aa9297c8bcdb242f58cc420e 100644
> --- a/drivers/firmware/psci/psci.c
> +++ b/drivers/firmware/psci/psci.c
> @@ -17,6 +17,7 @@
> #include <linux/printk.h>
> #include <linux/psci.h>
> #include <linux/reboot.h>
> +#include <linux/reboot-mode.h>
> #include <linux/slab.h>
> #include <linux/suspend.h>
>
> @@ -51,6 +52,14 @@ static int resident_cpu = -1;
> struct psci_operations psci_ops;
> static enum arm_smccc_conduit psci_conduit = SMCCC_CONDUIT_NONE;
>
> +struct psci_vendor_sysreset2 {
> + u32 reset_type;
> + u32 cookie;
> + bool valid;
> +};
> +
> +static struct psci_vendor_sysreset2 vendor_reset;
> +
> bool psci_tos_resident_on(int cpu)
> {
> return cpu == resident_cpu;
> @@ -309,7 +318,10 @@ static int get_set_conduit_method(const struct device_node *np)
> static int psci_sys_reset(struct notifier_block *nb, unsigned long action,
> void *data)
> {
> - if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
> + if (vendor_reset.valid && psci_system_reset2_supported) {
> + invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), vendor_reset.reset_type,
> + vendor_reset.cookie, 0);
> + } else if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
> psci_system_reset2_supported) {
> /*
> * reset_type[31] = 0 (architectural)
I don't know the PSCI spec, but it looks like with this code it's not
possible to set a reboot mode (in DT) and at the same time instruct
the firmware whether a warm or a cold reboot was requested.
Doing warm reboot is useful if e.g. RAM contents needs to be retained
for crash recovery handling, or other reasons, while in normal cases
doing a more secure cold reboot.
On the other hand, of course it's useful to be able to specify the
reboot target for normal reboots.
Is this a problem with the PSCI spec or with this specific change
geared at the Qcom implementation?
> @@ -547,6 +559,49 @@ static const struct platform_suspend_ops psci_suspend_ops = {
> .enter = psci_system_suspend_enter,
> };
>
> +static int psci_set_vendor_sys_reset2(struct reboot_mode_driver *reboot, u64 magic)
> +{
> + u32 magic_32;
> +
> + if (psci_system_reset2_supported) {
> + magic_32 = magic & 0xFFFFFFFF;
I believe usual kernel style is to use lower case for
hex values.
> + vendor_reset.reset_type = PSCI_1_1_RESET_TYPE_VENDOR_START | magic_32;
> + vendor_reset.cookie = (magic >> 32) & 0xFFFFFFFF;
dito.
Cheers,
Andre'
> + vendor_reset.valid = true;
> + }
> +
> + return NOTIFY_DONE;
> +}
> +
> +static int __init psci_init_vendor_reset(void)
> +{
> + struct reboot_mode_driver *reboot;
> + struct device_node *np;
> + int ret;
> +
> + np = of_find_node_by_path("/psci/reboot-mode");
> + if (!np)
> + return -ENODEV;
> +
> + reboot = kzalloc(sizeof(*reboot), GFP_KERNEL);
> + if (!reboot) {
> + of_node_put(np);
> + return -ENOMEM;
> + }
> +
> + reboot->write = psci_set_vendor_sys_reset2;
> +
> + ret = reboot_mode_register(reboot, np, "psci");
> + if (ret) {
> + of_node_put(np);
> + kfree(reboot);
> + return ret;
> + }
> +
> + return 0;
> +}
> +late_initcall(psci_init_vendor_reset)
> +
> static void __init psci_init_system_reset2(void)
> {
> int ret;
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2
2025-07-27 16:24 [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 Shivendra Pratap
` (9 preceding siblings ...)
2025-07-27 16:24 ` [PATCH v13 10/10] arm64: dts: qcom: sa8775p-ride: " Shivendra Pratap
@ 2025-07-30 8:50 ` André Draszik
10 siblings, 0 replies; 32+ messages in thread
From: André Draszik @ 2025-07-30 8:50 UTC (permalink / raw)
To: Shivendra Pratap, Bartosz Golaszewski, Bjorn Andersson,
Sebastian Reichel, Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, linux-pm,
linux-kernel, devicetree, linux-arm-kernel, linux-arm-msm,
Elliot Berman, Srinivas Kandagatla, Elliot Berman, Konrad Dybcio
On Sun, 2025-07-27 at 21:54 +0530, Shivendra Pratap wrote:
> The PSCI SYSTEM_RESET2 call allows vendor firmware to define
> additional reset types which could be mapped to the reboot
> argument.
>
> User-space should be able to reboot a device into different
> operational boot-states supported by underlying bootloader and
> firmware. Generally, some HW registers need to be written, based
> on which the bootloader and firmware decide the next boot state
> of device, after the reset. For example, a requirement on
> Qualcomm platforms may state that reboot with "bootloader"
> command, should reboot the device into bootloader flashing mode
> and reboot with “edl” command, should reboot the device into an
> Emergency flashing mode. Setting up such reboots on Qualcomm
> devices can be inconsistent across SoC platforms and may require
> setting different HW registers, where some of these registers may
> not be accessible to HLOS. These knobs evolve over product
> generations and require more drivers. PSCI defines a
> vendor-specific reset in SYSTEM_RESET2 spec, which enables the
> firmware to take care of underlying setting for any such
> supported vendor-specific reboot. Qualcomm firmwares are
> beginning to support and expose PSCI SYSTEM_RESET2
> vendor-specific reset types to simplify driver requirements from
> Linux. With such support added in the firmware, we now need a
> Linux interface which can make use of the firmware calls for PSCI
> vendor-specific resets. This will align such reboot requirement
> across platforms and vendors.
>
> The current psci driver supports two types of resets –
> SYSTEM_RESET2 Arch warm-reset and SYSTEM_RESET cold-reset. The
> patchset introduces the PSCI SYSTEM_RESET2 vendor-specific reset
> into the reset path of the psci driver and aligns it to work with
> reboot system call - LINUX_REBOOT_CMD_RESTART2, when used along
> with a supported string-based command in “*arg”.
>
> The patchset uses reboot-mode based commands, to define the
> supported vendor reset-types commands in psci device tree node
> and registers these commands with the reboot-mode framework.
>
> The PSCI vendor-specific reset takes two arguments, being,
> reset_type and cookie as defined by the spec. To accommodate this
> requirement, enhance the reboot-mode framework to support two
> 32-bit arguments by switching to 64-bit magic values.
>
> Along this line, the patchset also extends the reboot-mode
> framework to add a non-device-based registration function, which
> will allow drivers to register using device tree node, while
> keeping backward compatibility for existing users of reboot-mode.
> This will enable psci driver to register for reboot-mode and
> implement a write function, which will save the magic and then
> use it in psci reset path to make a vendor-specific reset call
> into the firmware. In addition, the patchset will expose a sysfs
> entry interface within reboot-mode which can be used by userspace
> to view the supported reboot-mode commands.
>
> The list of vendor-specific reset commands remains open due to
> divergent requirements across vendors, but this can be
> streamlined and standardized through dedicated device tree
> bindings.
>
> Currently three drivers register with reboot-mode framework -
> syscon-reboot-mode, nvmem-reboot-mode and qcom-pon. Consolidated
> list of commands currently added across various vendor DTs:
> mode-loader
> mode-normal
> mode-bootloader
> mode-charge
> mode-fastboot
> mode-reboot-ab-update
> mode-recovery
> mode-rescue
> mode-shutdown-thermal
> mode-shutdown-thermal-battery
>
> Detailed list of commands being used by syscon-reboot-mode:
> arm64/boot/dts/exynos/exynosautov9.dtsi:
> mode-bootloader = <EXYNOSAUTOV9_BOOT_BOOTLOADER>;
> mode-fastboot = <EXYNOSAUTOV9_BOOT_FASTBOOT>;
> mode-recovery = <EXYNOSAUTOV9_BOOT_RECOVERY>;
>
> arm64/boot/dts/exynos/google/gs101.dtsi:
> mode-bootloader = <0xfc>;
> mode-charge = <0x0a>;
> mode-fastboot = <0xfa>;
> mode-reboot-ab-update = <0x52>;
> mode-recovery = <0xff>;
> mode-rescue = <0xf9>;
> mode-shutdown-thermal = <0x51>;
> mode-shutdown-thermal-battery = <0x51>;
Just for completeness, on gs101 we also pass kernel-generated
modes from kernel_restart() or panic(), specifically DM verity's
'dm-verity device corrupted':
mode-dm-verity-device-corrupted = <0x50>;
Cheers,
Andre'
>
> arm64/boot/dts/hisilicon/hi3660-hikey960.dts:
> mode-normal = <0x77665501>;
> mode-bootloader = <0x77665500>;
> mode-recovery = <0x77665502>;
>
> arm64/boot/dts/hisilicon/hi6220-hikey.dts:
> mode-normal = <0x77665501>;
> mode-bootloader = <0x77665500>;
> mode-recovery = <0x77665502>;
>
> arm64/boot/dts/rockchip/px30.dtsi:
> mode-bootloader = <BOOT_BL_DOWNLOAD>;
> mode-fastboot = <BOOT_FASTBOOT>;
> mode-loader = <BOOT_BL_DOWNLOAD>;
> mode-normal = <BOOT_NORMAL>;
> mode-recovery = <BOOT_RECOVERY>;
>
> arm64/boot/dts/rockchip/rk3308.dtsi:
> mode-bootloader = <BOOT_BL_DOWNLOAD>;
> mode-loader = <BOOT_BL_DOWNLOAD>;
> mode-normal = <BOOT_NORMAL>;
> mode-recovery = <BOOT_RECOVERY>;
> mode-fastboot = <BOOT_FASTBOOT>;
>
> arm64/boot/dts/rockchip/rk3566-lckfb-tspi.dts:
> mode-normal = <BOOT_NORMAL>;
> mode-loader = <BOOT_BL_DOWNLOAD>;
> mode-recovery = <BOOT_RECOVERY>;
> mode-bootloader = <BOOT_FASTBOOT>;
>
> Detailed list of commands being used by nvmem-reboot-mode:
> arm64/boot/dts/qcom/pmXXXX.dtsi:(multiple qcom DTs)
> mode-recovery = <0x01>;
> mode-bootloader = <0x02>;
>
> Previous discussions around SYSTEM_RESET2:
> - https://lore.kernel.org/lkml/20230724223057.1208122-2-quic_eberman@quicinc.com/T/
> - https://lore.kernel.org/all/4a679542-b48d-7e11-f33a-63535a5c68cb@quicinc.com/
>
> Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
> Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
>
> Changes in v13:
> - Split patch1 into two (Synchronize list traversal and DT node-based
> registration) - by Dmitry.
> - Move mutex lock inside get_reboot_mode_magic - by Dmitry.
> - Reorder the patches – pull patch8 for exposing reboot-mode sysfs before
> psci patch - to align the change in reboot-mode sysfs patch.
> - Update patch- reboot-mode: Expose sysfs for registered reboot_modes
> - Introduce a driver_name in reboot_mode_register. This will be used
> in sysfs creation - by Arnd.
> - Update documentation and commit text for above.
> - Fix release function to properly call delete attr file.
> - Fix sparse warning for devres_find.
> - Add error handling for devres_find.
> - Split ABI documentation as a separate patch and update ABI documentation
> for usage of driver-name in sysfs - by Arnd
> - Update patch - psci: Implement vendor-specific resets as reboot-mode
> - Fix Kconfig for CONFIG related warning.
> - Add driver_name as "psci" in register call to reboot-mode - by Arnd
> - Link to v12: https://lore.kernel.org/r/20250721-arm-psci-system_reset2-vendor-reboots-v12-0-87bac3ec422e@oss.qualcomm.com
>
> Changes in v12:
> - Added lock for list traversals in reboot-mode - by Dmitry.
> - Added proper handling for BE and LE cases in reboot-mode - by Dmitry.
> - Removed type casting for u64 to u32 conversions. Added limit checks
> and used bitwise operations for same - by Andrew.
> - Link to v11: https://lore.kernel.org/r/20250717-arm-psci-system_reset2-vendor-reboots-v11-0-df3e2b2183c3@oss.qualcomm.com
>
> Changes in v11:
> - Remove reference of cookie in reboot-mode – Arnd/Rob
> - Introduce 64-bit magic in reboot-mode to accommodate two 32-bit
> arguments – Arnd
> - Change reset-type to reboot-mode in psci device tree binding – Arnd
> - binding no more mandates two arguments as in v10.
> - dt changes done to support this binding.
> - Remove obvious comments in psci reset path – Konrad
> - Merge sysfs and ABI doc into single patch.
> - Fix compilation issue on X86 configs.
> - Fix warnings for pr_fmt.
> - Link to v10: https://lore.kernel.org/all/569f154d-c714-1714-b898-83a42a38771c@oss.qualcomm.com/
>
> Changes in V10:
> - Change in reset-type binding to make cookie as a mandatory
> argument.
> - Change reboot-mode binding to support additional argument
> "cookie".
> From Lorenzo:
> - Use reboot-mode framework for implementing vendor-resets.
> - Modify reboot-mode framework to support two arguments
> (magic and cookie).
> - Expose sysfs for supported reboot-modes commands.
> - List out all existing reboot-mode commands and their users.
> - Added this to cover letter.
> From Dmitry:
> - Modify reboot-mode to support non-device based registration.
> - Modify reboot-mode to create a class and device to expose
> sysfs interface.
> - Link to v9: https://lore.kernel.org/all/20250303-arm-psci-system_reset2-vendor-reboots-v9-0-b2cf4a20feda@oss.qualcomm.com/
>
> Changes in v9:
> - Don't fallback to architecturally defined resets from Lorenzo.
> - Link to v8: https://lore.kernel.org/r/20241107-arm-psci-system_reset2-vendor-reboots-v8-0-e8715fa65cb5@quicinc.com
>
> Changes in v8:
> - Code style nits from Stephen
> - Add rb3gen2
> - Link to v7: https://lore.kernel.org/r/20241028-arm-psci-system_reset2-vendor-reboots-v7-0-a4c40b0ebc54@quicinc.com
>
> Changes in v7:
> - Code style nits from Stephen
> - Dropped unnecessary hunk from the sa8775p-ride patch
> - Link to v6: https://lore.kernel.org/r/20241018-arm-psci-system_reset2-vendor-reboots-v6-0-50cbe88b0a24@quicinc.com
>
> Changes in v6:
> - Rebase to v6.11 and fix trivial conflicts in qcm6490-idp
> - Add sa8775p-ride support (same as qcm6490-idp)
> - Link to v5: https://lore.kernel.org/r/20240617-arm-psci-system_reset2-vendor-reboots-v5-0-086950f650c8@quicinc.com
>
> Changes in v5:
> - Drop the nested "items" in prep for future dtschema tools
> - Link to v4: https://lore.kernel.org/r/20240611-arm-psci-system_reset2-vendor-reboots-v4-0-98f55aa74ae8@quicinc.com
>
> Changes in v4:
> - Change mode- properties from uint32-matrix to uint32-array
> - Restructure the reset-types node so only the restriction is in the
> if/then schemas and not the entire definition
> - Link to v3: https://lore.kernel.org/r/20240515-arm-psci-system_reset2-vendor-reboots-v3-0-16dd4f9c0ab4@quicinc.com
>
> Changes in v3:
> - Limit outer number of items to 1 for mode-* properties
> - Move the reboot-mode for psci under a subnode "reset-types"
> - Fix the DT node in qcm6490-idp so it doesn't overwrite the one from
> sc7820.dtsi
> - Link to v2: https://lore.kernel.org/r/20240414-arm-psci-system_reset2-vendor-reboots-v2-0-da9a055a648f@quicinc.com
>
> Changes in v2:
> - Fixes to schema as suggested by Rob and Krzysztof
> - Add qcm6490 idp as first Qualcomm device to support
> - Link to v1: https://lore.kernel.org/r/20231117-arm-psci-system_reset2-vendor-reboots-v1-0-03c4612153e2@quicinc.com
>
> Changes in v1:
> - Reference reboot-mode bindings as suggeted by Rob.
> - Link to RFC: https://lore.kernel.org/r/20231030-arm-psci-system_reset2-vendor-reboots-v1-0-dcdd63352ad1@quicinc.com
>
> ---
> Elliot Berman (4):
> dt-bindings: arm: Document reboot mode magic
> arm64: dts: qcom: qcm6490-idp: Add PSCI SYSTEM_RESET2 types
> arm64: dts: qcom: qcs6490-rb3gen2: Add PSCI SYSTEM_RESET2 types
> arm64: dts: qcom: sa8775p-ride: Add PSCI SYSTEM_RESET2 types
>
> Shivendra Pratap (6):
> power: reset: reboot-mode: Synchronize list traversal
> power: reset: reboot-mode: Add device tree node-based registration
> power: reset: reboot-mode: Add support for 64 bit magic
> Documentation: ABI: Add sysfs-class-reboot-mode-reboot_modes
> power: reset: reboot-mode: Expose sysfs for registered reboot_modes
> firmware: psci: Implement vendor-specific resets as reboot-mode
>
> .../testing/sysfs-class-reboot-mode-reboot_modes | 39 +++++
> Documentation/devicetree/bindings/arm/psci.yaml | 43 +++++
> arch/arm64/boot/dts/qcom/qcm6490-idp.dts | 7 +
> arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts | 7 +
> arch/arm64/boot/dts/qcom/sa8775p-ride.dtsi | 7 +
> arch/arm64/boot/dts/qcom/sa8775p.dtsi | 2 +-
> arch/arm64/boot/dts/qcom/sc7280.dtsi | 2 +-
> drivers/firmware/psci/Kconfig | 2 +
> drivers/firmware/psci/psci.c | 57 ++++++-
> drivers/power/reset/nvmem-reboot-mode.c | 13 +-
> drivers/power/reset/qcom-pon.c | 11 +-
> drivers/power/reset/reboot-mode.c | 174 +++++++++++++++++----
> drivers/power/reset/syscon-reboot-mode.c | 11 +-
> include/linux/reboot-mode.h | 11 +-
> 14 files changed, 342 insertions(+), 44 deletions(-)
> ---
> base-commit: d7af19298454ed155f5cf67201a70f5cf836c842
> change-id: 20250709-arm-psci-system_reset2-vendor-reboots-46c80044afcf
>
> Best regards,
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 04/10] Documentation: ABI: Add sysfs-class-reboot-mode-reboot_modes
2025-07-27 16:24 ` [PATCH v13 04/10] Documentation: ABI: Add sysfs-class-reboot-mode-reboot_modes Shivendra Pratap
@ 2025-07-30 9:06 ` André Draszik
2025-07-30 13:08 ` Shivendra Pratap
0 siblings, 1 reply; 32+ messages in thread
From: André Draszik @ 2025-07-30 9:06 UTC (permalink / raw)
To: Shivendra Pratap, Bartosz Golaszewski, Bjorn Andersson,
Sebastian Reichel, Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, linux-pm,
linux-kernel, devicetree, linux-arm-kernel, linux-arm-msm,
Elliot Berman, Srinivas Kandagatla
On Sun, 2025-07-27 at 21:54 +0530, Shivendra Pratap wrote:
> Add ABI documentation for /sys/class/reboot-mode/*/reboot_modes,
> a read-only sysfs attribute exposing the list of supported
> reboot-mode arguments. This file is created by reboot-mode
> framework and provides a user-readable interface to query
> available reboot-mode arguments.
>
> Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
> ---
> .../testing/sysfs-class-reboot-mode-reboot_modes | 39 ++++++++++++++++++++++
> 1 file changed, 39 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-class-reboot-mode-reboot_modes b/Documentation/ABI/testing/sysfs-class-reboot-mode-
> reboot_modes
> new file mode 100644
> index 0000000000000000000000000000000000000000..7147a781e5d4d11977c3a156bf4308aa13310e39
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-class-reboot-mode-reboot_modes
> @@ -0,0 +1,39 @@
> +What: /sys/class/reboot-mode/<driver>/reboot_modes
> +Date: July 2025
> +KernelVersion: 6.16
The version should probably be updated.
> +Contact: linux-pm@vger.kernel.org
> + Description:
> + This interface exposes the reboot-mode arguments
> + registered with the reboot-mode framework. It is
> + a read-only interface and provides a comma
> + separated list of reboot-mode arguments supported
> + on the current platform.
> + Example:
> + recovery,fastboot,bootloader
I'd personally find space separated like e.g. in files below /sys/power
and many other similar files below /sys easier to read.
Cheers,
Andre'
> +
> + The exact sysfs path may vary depending on the
> + name of the driver that registers the arguments.
> + Example:
> + /sys/class/reboot-mode/nvmem-reboot-mode/reboot_modes
> + /sys/class/reboot-mode/syscon-reboot-mode/reboot_modes
> + /sys/class/reboot-mode/qcom-pon/reboot_modes
> +
> + The supported arguments can be used by userspace
> + to invoke device reset using the reboot() system
> + call, with the "argument" as string to "*arg"
> + parameter along with LINUX_REBOOT_CMD_RESTART2.
> + Example:
> + reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
> + LINUX_REBOOT_CMD_RESTART2, "bootloader");
> +
> + A driver can expose the supported arguments by
> + registering them with the reboot-mode framework
> + using the property names that follow the
> + mode-<argument> format.
> + Example:
> + mode-bootloader, mode-recovery.
> +
> + This attribute is useful for scripts or initramfs
> + logic that need to programmatically determine
> + which reboot-mode arguments are valid before
> + triggering a reboot.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-30 8:44 ` André Draszik
@ 2025-07-30 13:03 ` Shivendra Pratap
2025-07-30 15:23 ` André Draszik
0 siblings, 1 reply; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-30 13:03 UTC (permalink / raw)
To: André Draszik, Bartosz Golaszewski, Bjorn Andersson,
Sebastian Reichel, Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, linux-pm,
linux-kernel, devicetree, linux-arm-kernel, linux-arm-msm,
Elliot Berman, Srinivas Kandagatla
On 7/30/2025 2:14 PM, André Draszik wrote:
> On Sun, 2025-07-27 at 21:54 +0530, Shivendra Pratap wrote:
>> SoC vendors have different types of resets which are controlled
>> through various hardware registers. For instance, Qualcomm SoC
>> may have a requirement that reboot with “bootloader” command
>> should reboot the device to bootloader flashing mode and reboot
>> with “edl” should reboot the device into Emergency flashing mode.
>> Setting up such reboots on Qualcomm devices can be inconsistent
>> across SoC platforms and may require setting different HW
>> registers, where some of these registers may not be accessible to
>> HLOS. These knobs evolve over product generations and require
>> more drivers. PSCI spec defines, SYSTEM_RESET2, vendor-specific
>> reset which can help align this requirement. Add support for PSCI
>> SYSTEM_RESET2, vendor-specific resets and align the implementation
>> to allow user-space initiated reboots to trigger these resets.
>>
>> Introduce a late_initcall to register PSCI vendor-specific resets
>> as reboot modes. Implement a reboot-mode write function that sets
>> reset_type and cookie values during the reboot notifier callback.
>> Introduce a firmware-based call for SYSTEM_RESET2 vendor-specific
>> reset in the psci_sys_reset path, using reset_type and cookie if
>> supported by secure firmware.
>>
>> By using the above implementation, userspace will be able to issue
>> such resets using the reboot() system call with the "*arg"
>> parameter as a string based command. The commands can be defined
>> in PSCI device tree node as “reset-types” and are based on the
>> reboot-mode based commands.
>>
>> Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
>> ---
>> drivers/firmware/psci/Kconfig | 2 ++
>> drivers/firmware/psci/psci.c | 57 ++++++++++++++++++++++++++++++++++++++++++-
>> 2 files changed, 58 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/firmware/psci/Kconfig b/drivers/firmware/psci/Kconfig
>> index 97944168b5e66aea1e38a7eb2d4ced8348fce64b..93ff7b071a0c364a376699733e6bc5654d56a17f 100644
>> --- a/drivers/firmware/psci/Kconfig
>> +++ b/drivers/firmware/psci/Kconfig
>> @@ -1,6 +1,8 @@
>> # SPDX-License-Identifier: GPL-2.0-only
>> config ARM_PSCI_FW
>> bool
>> + select POWER_RESET
>> + select REBOOT_MODE
>>
>> config ARM_PSCI_CHECKER
>> bool "ARM PSCI checker"
>> diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
>> index 38ca190d4a22d6e7e0f06420e8478a2b0ec2fe6f..e14bcdbec1750db8aa9297c8bcdb242f58cc420e 100644
>> --- a/drivers/firmware/psci/psci.c
>> +++ b/drivers/firmware/psci/psci.c
>> @@ -17,6 +17,7 @@
>> #include <linux/printk.h>
>> #include <linux/psci.h>
>> #include <linux/reboot.h>
>> +#include <linux/reboot-mode.h>
>> #include <linux/slab.h>
>> #include <linux/suspend.h>
>>
>> @@ -51,6 +52,14 @@ static int resident_cpu = -1;
>> struct psci_operations psci_ops;
>> static enum arm_smccc_conduit psci_conduit = SMCCC_CONDUIT_NONE;
>>
>> +struct psci_vendor_sysreset2 {
>> + u32 reset_type;
>> + u32 cookie;
>> + bool valid;
>> +};
>> +
>> +static struct psci_vendor_sysreset2 vendor_reset;
>> +
>> bool psci_tos_resident_on(int cpu)
>> {
>> return cpu == resident_cpu;
>> @@ -309,7 +318,10 @@ static int get_set_conduit_method(const struct device_node *np)
>> static int psci_sys_reset(struct notifier_block *nb, unsigned long action,
>> void *data)
>> {
>> - if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
>> + if (vendor_reset.valid && psci_system_reset2_supported) {
>> + invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), vendor_reset.reset_type,
>> + vendor_reset.cookie, 0);
>> + } else if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
>> psci_system_reset2_supported) {
>> /*
>> * reset_type[31] = 0 (architectural)
>
> I don't know the PSCI spec, but it looks like with this code it's not
> possible to set a reboot mode (in DT) and at the same time instruct
> the firmware whether a warm or a cold reboot was requested.
The code added in this patch is kind of dead, until vendor_reset.valid is set to true.
It can be true, only when both below conditions are true.
1. A SoC DT defines a psci->reboot-mode command say - "bootloader".
2. reboot sys call is issued using LINUX_REBOOT_CMD_RESTART2 and the arg* as "bootloader".
reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, "bootloader");
With that in place, warm and cold reboot just work same as before until above conditions are true.
There is no effect on regular reboots or the reboots with a "command" which is not defined in
psci->reboot-mode DT.
Now lets take a case below, where a SoC vendor wants a combination of psci->reboo-mode command and
warm/cold to work in combination. For ex. a requirement below:
- reboot command say - "bootlaoder" should do a cold reboot along with some extra HW reg writes.
- reboot command say - "edl" should do a warm reboot along with some extra HW reg writes.
1. For this, both commands will be defined in the psci->reboot-mode DT Node with the arguments that
are defined and supported by the firmware.
2. Further, such requirement will now be taken care by the underlying firmware that supports
PSCI vendor-specific reset. When we call into firmware with vendor specific reset arguments,
firmware will take care of the defined HW writes and warm/cold reset as per the mapping of the
defined arguments. Firmware and the Linux kernel here are in agreement for executing the
vendor-specific resets.
>
> Doing warm reboot is useful if e.g. RAM contents needs to be retained
> for crash recovery handling, or other reasons, while in normal cases
> doing a more secure cold reboot.
>
> On the other hand, of course it's useful to be able to specify the
> reboot target for normal reboots.
>
> Is this a problem with the PSCI spec or with this specific change
> geared at the Qcom implementation?
SoC vendor should define a vendor-specific reset in psci DT only when they support them in their
firmware.
Do we still think we are breaking anything in the spec or in the warm or the cold
reset path? If so can we discuss such use-cases?
>
>
>> @@ -547,6 +559,49 @@ static const struct platform_suspend_ops psci_suspend_ops = {
>> .enter = psci_system_suspend_enter,
>> };
>>
>> +static int psci_set_vendor_sys_reset2(struct reboot_mode_driver *reboot, u64 magic)
>> +{
>> + u32 magic_32;
>> +
>> + if (psci_system_reset2_supported) {
>> + magic_32 = magic & 0xFFFFFFFF;
>
> I believe usual kernel style is to use lower case for
> hex values.
Sure, will make it lower case.
>
>> + vendor_reset.reset_type = PSCI_1_1_RESET_TYPE_VENDOR_START | magic_32;
>> + vendor_reset.cookie = (magic >> 32) & 0xFFFFFFFF;
>
> dito.
Ack.
thanks.
>
> Cheers,
> Andre'
>
>> + vendor_reset.valid = true;
>> + }
>> +
>> + return NOTIFY_DONE;
>> +}
>> +
>> +static int __init psci_init_vendor_reset(void)
>> +{
>> + struct reboot_mode_driver *reboot;
>> + struct device_node *np;
>> + int ret;
>> +
>> + np = of_find_node_by_path("/psci/reboot-mode");
>> + if (!np)
>> + return -ENODEV;
>> +
>> + reboot = kzalloc(sizeof(*reboot), GFP_KERNEL);
>> + if (!reboot) {
>> + of_node_put(np);
>> + return -ENOMEM;
>> + }
>> +
>> + reboot->write = psci_set_vendor_sys_reset2;
>> +
>> + ret = reboot_mode_register(reboot, np, "psci");
>> + if (ret) {
>> + of_node_put(np);
>> + kfree(reboot);
>> + return ret;
>> + }
>> +
>> + return 0;
>> +}
>> +late_initcall(psci_init_vendor_reset)
>> +
>> static void __init psci_init_system_reset2(void)
>> {
>> int ret;
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 04/10] Documentation: ABI: Add sysfs-class-reboot-mode-reboot_modes
2025-07-30 9:06 ` André Draszik
@ 2025-07-30 13:08 ` Shivendra Pratap
0 siblings, 0 replies; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-30 13:08 UTC (permalink / raw)
To: André Draszik, Bartosz Golaszewski, Bjorn Andersson,
Sebastian Reichel, Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, linux-pm,
linux-kernel, devicetree, linux-arm-kernel, linux-arm-msm,
Elliot Berman, Srinivas Kandagatla
On 7/30/2025 2:36 PM, André Draszik wrote:
> On Sun, 2025-07-27 at 21:54 +0530, Shivendra Pratap wrote:
>> Add ABI documentation for /sys/class/reboot-mode/*/reboot_modes,
>> a read-only sysfs attribute exposing the list of supported
>> reboot-mode arguments. This file is created by reboot-mode
>> framework and provides a user-readable interface to query
>> available reboot-mode arguments.
>>
>> Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
>> ---
>> .../testing/sysfs-class-reboot-mode-reboot_modes | 39 ++++++++++++++++++++++
>> 1 file changed, 39 insertions(+)
>>
>> diff --git a/Documentation/ABI/testing/sysfs-class-reboot-mode-reboot_modes b/Documentation/ABI/testing/sysfs-class-reboot-mode-
>> reboot_modes
>> new file mode 100644
>> index 0000000000000000000000000000000000000000..7147a781e5d4d11977c3a156bf4308aa13310e39
>> --- /dev/null
>> +++ b/Documentation/ABI/testing/sysfs-class-reboot-mode-reboot_modes
>> @@ -0,0 +1,39 @@
>> +What: /sys/class/reboot-mode/<driver>/reboot_modes
>> +Date: July 2025
>> +KernelVersion: 6.16
>
> The version should probably be updated.
sure. will update this.
>
>> +Contact: linux-pm@vger.kernel.org
>> + Description:
>> + This interface exposes the reboot-mode arguments
>> + registered with the reboot-mode framework. It is
>> + a read-only interface and provides a comma
>> + separated list of reboot-mode arguments supported
>> + on the current platform.
>> + Example:
>> + recovery,fastboot,bootloader
>
> I'd personally find space separated like e.g. in files below /sys/power
> and many other similar files below /sys easier to read.
sure. Will make it space.
thanks.
>
> Cheers,
> Andre'
>
>
>> +
>> + The exact sysfs path may vary depending on the
>> + name of the driver that registers the arguments.
>> + Example:
>> + /sys/class/reboot-mode/nvmem-reboot-mode/reboot_modes
>> + /sys/class/reboot-mode/syscon-reboot-mode/reboot_modes
>> + /sys/class/reboot-mode/qcom-pon/reboot_modes
>> +
>> + The supported arguments can be used by userspace
>> + to invoke device reset using the reboot() system
>> + call, with the "argument" as string to "*arg"
>> + parameter along with LINUX_REBOOT_CMD_RESTART2.
>> + Example:
>> + reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
>> + LINUX_REBOOT_CMD_RESTART2, "bootloader");
>> +
>> + A driver can expose the supported arguments by
>> + registering them with the reboot-mode framework
>> + using the property names that follow the
>> + mode-<argument> format.
>> + Example:
>> + mode-bootloader, mode-recovery.
>> +
>> + This attribute is useful for scripts or initramfs
>> + logic that need to programmatically determine
>> + which reboot-mode arguments are valid before
>> + triggering a reboot.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-30 13:03 ` Shivendra Pratap
@ 2025-07-30 15:23 ` André Draszik
2025-07-30 17:31 ` Arnd Bergmann
2025-07-31 5:35 ` Shivendra Pratap
0 siblings, 2 replies; 32+ messages in thread
From: André Draszik @ 2025-07-30 15:23 UTC (permalink / raw)
To: Shivendra Pratap, Bartosz Golaszewski, Bjorn Andersson,
Sebastian Reichel, Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, linux-pm,
linux-kernel, devicetree, linux-arm-kernel, linux-arm-msm,
Elliot Berman, Srinivas Kandagatla
On Wed, 2025-07-30 at 18:33 +0530, Shivendra Pratap wrote:
>
>
> On 7/30/2025 2:14 PM, André Draszik wrote:
> > On Sun, 2025-07-27 at 21:54 +0530, Shivendra Pratap wrote:
> > > SoC vendors have different types of resets which are controlled
> > > through various hardware registers. For instance, Qualcomm SoC
> > > may have a requirement that reboot with “bootloader” command
> > > should reboot the device to bootloader flashing mode and reboot
> > > with “edl” should reboot the device into Emergency flashing mode.
> > > Setting up such reboots on Qualcomm devices can be inconsistent
> > > across SoC platforms and may require setting different HW
> > > registers, where some of these registers may not be accessible to
> > > HLOS. These knobs evolve over product generations and require
> > > more drivers. PSCI spec defines, SYSTEM_RESET2, vendor-specific
> > > reset which can help align this requirement. Add support for PSCI
> > > SYSTEM_RESET2, vendor-specific resets and align the implementation
> > > to allow user-space initiated reboots to trigger these resets.
> > >
> > > Introduce a late_initcall to register PSCI vendor-specific resets
> > > as reboot modes. Implement a reboot-mode write function that sets
> > > reset_type and cookie values during the reboot notifier callback.
> > > Introduce a firmware-based call for SYSTEM_RESET2 vendor-specific
> > > reset in the psci_sys_reset path, using reset_type and cookie if
> > > supported by secure firmware.
> > >
> > > By using the above implementation, userspace will be able to issue
> > > such resets using the reboot() system call with the "*arg"
> > > parameter as a string based command. The commands can be defined
> > > in PSCI device tree node as “reset-types” and are based on the
> > > reboot-mode based commands.
> > >
> > > Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
> > > ---
> > > drivers/firmware/psci/Kconfig | 2 ++
> > > drivers/firmware/psci/psci.c | 57 ++++++++++++++++++++++++++++++++++++++++++-
> > > 2 files changed, 58 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/firmware/psci/Kconfig b/drivers/firmware/psci/Kconfig
> > > index 97944168b5e66aea1e38a7eb2d4ced8348fce64b..93ff7b071a0c364a376699733e6bc5654d56a17f 100644
> > > --- a/drivers/firmware/psci/Kconfig
> > > +++ b/drivers/firmware/psci/Kconfig
> > > @@ -1,6 +1,8 @@
> > > # SPDX-License-Identifier: GPL-2.0-only
> > > config ARM_PSCI_FW
> > > bool
> > > + select POWER_RESET
> > > + select REBOOT_MODE
> > >
> > > config ARM_PSCI_CHECKER
> > > bool "ARM PSCI checker"
> > > diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
> > > index 38ca190d4a22d6e7e0f06420e8478a2b0ec2fe6f..e14bcdbec1750db8aa9297c8bcdb242f58cc420e 100644
> > > --- a/drivers/firmware/psci/psci.c
> > > +++ b/drivers/firmware/psci/psci.c
> > > @@ -17,6 +17,7 @@
> > > #include <linux/printk.h>
> > > #include <linux/psci.h>
> > > #include <linux/reboot.h>
> > > +#include <linux/reboot-mode.h>
> > > #include <linux/slab.h>
> > > #include <linux/suspend.h>
> > >
> > > @@ -51,6 +52,14 @@ static int resident_cpu = -1;
> > > struct psci_operations psci_ops;
> > > static enum arm_smccc_conduit psci_conduit = SMCCC_CONDUIT_NONE;
> > >
> > > +struct psci_vendor_sysreset2 {
> > > + u32 reset_type;
> > > + u32 cookie;
> > > + bool valid;
> > > +};
> > > +
> > > +static struct psci_vendor_sysreset2 vendor_reset;
> > > +
> > > bool psci_tos_resident_on(int cpu)
> > > {
> > > return cpu == resident_cpu;
> > > @@ -309,7 +318,10 @@ static int get_set_conduit_method(const struct device_node *np)
> > > static int psci_sys_reset(struct notifier_block *nb, unsigned long action,
> > > void *data)
> > > {
> > > - if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
> > > + if (vendor_reset.valid && psci_system_reset2_supported) {
> > > + invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), vendor_reset.reset_type,
> > > + vendor_reset.cookie, 0);
> > > + } else if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
> > > psci_system_reset2_supported) {
> > > /*
> > > * reset_type[31] = 0 (architectural)
> >
> > I don't know the PSCI spec, but it looks like with this code it's not
> > possible to set a reboot mode (in DT) and at the same time instruct
> > the firmware whether a warm or a cold reboot was requested.
>
> The code added in this patch is kind of dead, until vendor_reset.valid is set to true.
> It can be true, only when both below conditions are true.
> 1. A SoC DT defines a psci->reboot-mode command say - "bootloader".
> 2. reboot sys call is issued using LINUX_REBOOT_CMD_RESTART2 and the arg* as "bootloader".
> reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, "bootloader");
>
> With that in place, warm and cold reboot just work same as before until above conditions are true.
> There is no effect on regular reboots or the reboots with a "command" which is not defined in
> psci->reboot-mode DT.
>
> Now lets take a case below, where a SoC vendor wants a combination of psci->reboo-mode command and
> warm/cold to work in combination. For ex. a requirement below:
> - reboot command say - "bootlaoder" should do a cold reboot along with some extra HW reg writes.
> - reboot command say - "edl" should do a warm reboot along with some extra HW reg writes.
>
> 1. For this, both commands will be defined in the psci->reboot-mode DT Node with the arguments that
> are defined and supported by the firmware.
> 2. Further, such requirement will now be taken care by the underlying firmware that supports
> PSCI vendor-specific reset. When we call into firmware with vendor specific reset arguments,
> firmware will take care of the defined HW writes and warm/cold reset as per the mapping of the
> defined arguments. Firmware and the Linux kernel here are in agreement for executing the
> vendor-specific resets.
So that means
echo warm > /sys/kernel/reboot/mode
reboot bootloader
and
echo cold > /sys/kernel/reboot/mode
reboot bootloader
can not be distinguished.
The firmware can not know whether or not cold or warm reboot was
requested in this case by the user.
More importantly, if e.g. an OOPS / panic happens after the reboot
notifier has run (and set vendor_reset.valid because a reboot mode
was requested), a panic handler changing reboot_mode to warm to
retain RAM contents will have no effect, because the the original
code above making those distinctions can not be reached anymore.
Above scenario with OOPS / panic after reboot notifier could e.g.
happen as part of device_shutdown() - see kernel_shutdown_prepare()
> >
> > Doing warm reboot is useful if e.g. RAM contents needs to be retained
> > for crash recovery handling, or other reasons, while in normal cases
> > doing a more secure cold reboot.
> >
> > On the other hand, of course it's useful to be able to specify the
> > reboot target for normal reboots.
> >
> > Is this a problem with the PSCI spec or with this specific change
> > geared at the Qcom implementation?
>
> SoC vendor should define a vendor-specific reset in psci DT only when they support them in their
> firmware.
>
> Do we still think we are breaking anything in the spec or in the warm or the cold
> reset path? If so can we discuss such use-cases?
I don't know the spec, but see examples above.
Cheers,
Andre'
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-30 15:23 ` André Draszik
@ 2025-07-30 17:31 ` Arnd Bergmann
2025-07-31 11:05 ` André Draszik
2025-07-31 5:35 ` Shivendra Pratap
1 sibling, 1 reply; 32+ messages in thread
From: Arnd Bergmann @ 2025-07-30 17:31 UTC (permalink / raw)
To: André Draszik, Shivendra Pratap, Bartosz Golaszewski,
Bjorn Andersson, Sebastian Reichel, Rob Herring, Sudeep Holla,
Souvik Chakravarty, Krzysztof Kozlowski, Conor Dooley, Andy Yan,
Mark Rutland, Lorenzo Pieralisi, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, linux-pm,
linux-kernel, devicetree, linux-arm-kernel, linux-arm-msm,
Elliot Berman, Srinivas Kandagatla
On Wed, Jul 30, 2025, at 17:23, André Draszik wrote:
> On Wed, 2025-07-30 at 18:33 +0530, Shivendra Pratap wrote:
>> On 7/30/2025 2:14 PM, André Draszik wrote:
>> 1. For this, both commands will be defined in the psci->reboot-mode DT Node with the arguments that
>> are defined and supported by the firmware.
>> 2. Further, such requirement will now be taken care by the underlying firmware that supports
>> PSCI vendor-specific reset. When we call into firmware with vendor specific reset arguments,
>> firmware will take care of the defined HW writes and warm/cold reset as per the mapping of the
>> defined arguments. Firmware and the Linux kernel here are in agreement for executing the
>> vendor-specific resets.
>
> So that means
>
> echo warm > /sys/kernel/reboot/mode
> reboot bootloader
>
> and
>
> echo cold > /sys/kernel/reboot/mode
> reboot bootloader
>
> can not be distinguished.
>
> The firmware can not know whether or not cold or warm reboot was
> requested in this case by the user.
My feeling is that this is fine: the /sys/kernel/reboot/mode
interface is not really used on anything other than 32-bit
arm and x86 machines, and the way it is specific as
cold/warm/hard/soft/gpio is not that useful.
I think for the purpose of the new code here, we should talk
about reboot "commands" instead of "modes" to avoid confusing
between the global "enum reboot_mode" variable and the
firmware interface for reboot modes as listed in DT.
Arnd
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-30 15:23 ` André Draszik
2025-07-30 17:31 ` Arnd Bergmann
@ 2025-07-31 5:35 ` Shivendra Pratap
2025-07-31 10:25 ` André Draszik
1 sibling, 1 reply; 32+ messages in thread
From: Shivendra Pratap @ 2025-07-31 5:35 UTC (permalink / raw)
To: André Draszik, Bartosz Golaszewski, Bjorn Andersson,
Sebastian Reichel, Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, linux-pm,
linux-kernel, devicetree, linux-arm-kernel, linux-arm-msm,
Elliot Berman, Srinivas Kandagatla
On 7/30/2025 8:53 PM, André Draszik wrote:
> On Wed, 2025-07-30 at 18:33 +0530, Shivendra Pratap wrote:
>>
>>
>> On 7/30/2025 2:14 PM, André Draszik wrote:
>>> On Sun, 2025-07-27 at 21:54 +0530, Shivendra Pratap wrote:
>>>> SoC vendors have different types of resets which are controlled
>>>> through various hardware registers. For instance, Qualcomm SoC
>>>> may have a requirement that reboot with “bootloader” command
>>>> should reboot the device to bootloader flashing mode and reboot
>>>> with “edl” should reboot the device into Emergency flashing mode.
>>>> Setting up such reboots on Qualcomm devices can be inconsistent
>>>> across SoC platforms and may require setting different HW
>>>> registers, where some of these registers may not be accessible to
>>>> HLOS. These knobs evolve over product generations and require
>>>> more drivers. PSCI spec defines, SYSTEM_RESET2, vendor-specific
>>>> reset which can help align this requirement. Add support for PSCI
>>>> SYSTEM_RESET2, vendor-specific resets and align the implementation
>>>> to allow user-space initiated reboots to trigger these resets.
>>>>
>>>> Introduce a late_initcall to register PSCI vendor-specific resets
>>>> as reboot modes. Implement a reboot-mode write function that sets
>>>> reset_type and cookie values during the reboot notifier callback.
>>>> Introduce a firmware-based call for SYSTEM_RESET2 vendor-specific
>>>> reset in the psci_sys_reset path, using reset_type and cookie if
>>>> supported by secure firmware.
>>>>
>>>> By using the above implementation, userspace will be able to issue
>>>> such resets using the reboot() system call with the "*arg"
>>>> parameter as a string based command. The commands can be defined
>>>> in PSCI device tree node as “reset-types” and are based on the
>>>> reboot-mode based commands.
>>>>
>>>> Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
>>>> ---
>>>> drivers/firmware/psci/Kconfig | 2 ++
>>>> drivers/firmware/psci/psci.c | 57 ++++++++++++++++++++++++++++++++++++++++++-
>>>> 2 files changed, 58 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/firmware/psci/Kconfig b/drivers/firmware/psci/Kconfig
>>>> index 97944168b5e66aea1e38a7eb2d4ced8348fce64b..93ff7b071a0c364a376699733e6bc5654d56a17f 100644
>>>> --- a/drivers/firmware/psci/Kconfig
>>>> +++ b/drivers/firmware/psci/Kconfig
>>>> @@ -1,6 +1,8 @@
>>>> # SPDX-License-Identifier: GPL-2.0-only
>>>> config ARM_PSCI_FW
>>>> bool
>>>> + select POWER_RESET
>>>> + select REBOOT_MODE
>>>>
>>>> config ARM_PSCI_CHECKER
>>>> bool "ARM PSCI checker"
>>>> diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
>>>> index 38ca190d4a22d6e7e0f06420e8478a2b0ec2fe6f..e14bcdbec1750db8aa9297c8bcdb242f58cc420e 100644
>>>> --- a/drivers/firmware/psci/psci.c
>>>> +++ b/drivers/firmware/psci/psci.c
>>>> @@ -17,6 +17,7 @@
>>>> #include <linux/printk.h>
>>>> #include <linux/psci.h>
>>>> #include <linux/reboot.h>
>>>> +#include <linux/reboot-mode.h>
>>>> #include <linux/slab.h>
>>>> #include <linux/suspend.h>
>>>>
>>>> @@ -51,6 +52,14 @@ static int resident_cpu = -1;
>>>> struct psci_operations psci_ops;
>>>> static enum arm_smccc_conduit psci_conduit = SMCCC_CONDUIT_NONE;
>>>>
>>>> +struct psci_vendor_sysreset2 {
>>>> + u32 reset_type;
>>>> + u32 cookie;
>>>> + bool valid;
>>>> +};
>>>> +
>>>> +static struct psci_vendor_sysreset2 vendor_reset;
>>>> +
>>>> bool psci_tos_resident_on(int cpu)
>>>> {
>>>> return cpu == resident_cpu;
>>>> @@ -309,7 +318,10 @@ static int get_set_conduit_method(const struct device_node *np)
>>>> static int psci_sys_reset(struct notifier_block *nb, unsigned long action,
>>>> void *data)
>>>> {
>>>> - if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
>>>> + if (vendor_reset.valid && psci_system_reset2_supported) {
>>>> + invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), vendor_reset.reset_type,
>>>> + vendor_reset.cookie, 0);
>>>> + } else if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
>>>> psci_system_reset2_supported) {
>>>> /*
>>>> * reset_type[31] = 0 (architectural)
>>>
>>> I don't know the PSCI spec, but it looks like with this code it's not
>>> possible to set a reboot mode (in DT) and at the same time instruct
>>> the firmware whether a warm or a cold reboot was requested.
>>
>> The code added in this patch is kind of dead, until vendor_reset.valid is set to true.
>> It can be true, only when both below conditions are true.
>> 1. A SoC DT defines a psci->reboot-mode command say - "bootloader".
>> 2. reboot sys call is issued using LINUX_REBOOT_CMD_RESTART2 and the arg* as "bootloader".
>> reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, "bootloader");
>>
>> With that in place, warm and cold reboot just work same as before until above conditions are true.
>> There is no effect on regular reboots or the reboots with a "command" which is not defined in
>> psci->reboot-mode DT.
>>
>> Now lets take a case below, where a SoC vendor wants a combination of psci->reboo-mode command and
>> warm/cold to work in combination. For ex. a requirement below:
>> - reboot command say - "bootlaoder" should do a cold reboot along with some extra HW reg writes.
>> - reboot command say - "edl" should do a warm reboot along with some extra HW reg writes.
>>
>> 1. For this, both commands will be defined in the psci->reboot-mode DT Node with the arguments that
>> are defined and supported by the firmware.
>> 2. Further, such requirement will now be taken care by the underlying firmware that supports
>> PSCI vendor-specific reset. When we call into firmware with vendor specific reset arguments,
>> firmware will take care of the defined HW writes and warm/cold reset as per the mapping of the
>> defined arguments. Firmware and the Linux kernel here are in agreement for executing the
>> vendor-specific resets.
>
> So that means
>
> echo warm > /sys/kernel/reboot/mode
> reboot bootloader
>
> and
>
> echo cold > /sys/kernel/reboot/mode
> reboot bootloader
>
> can not be distinguished.
>
> The firmware can not know whether or not cold or warm reboot was
> requested in this case by the user.
>
> More importantly, if e.g. an OOPS / panic happens after the reboot
> notifier has run (and set vendor_reset.valid because a reboot mode
> was requested), a panic handler changing reboot_mode to warm to
> retain RAM contents will have no effect, because the the original
> code above making those distinctions can not be reached anymore.
>
> Above scenario with OOPS / panic after reboot notifier could e.g.
> happen as part of device_shutdown() - see kernel_shutdown_prepare()
We can handle the panic path by adding a panic_notifier in psci
and make vendor_reset.valid = false. Do you think adding this can clear
the panic scenario above or there can still be some leak?
thanks.
>
>
>>>
>>> Doing warm reboot is useful if e.g. RAM contents needs to be retained
>>> for crash recovery handling, or other reasons, while in normal cases
>>> doing a more secure cold reboot.
>>>
>>> On the other hand, of course it's useful to be able to specify the
>>> reboot target for normal reboots.
>>>
>>> Is this a problem with the PSCI spec or with this specific change
>>> geared at the Qcom implementation?
>>
>> SoC vendor should define a vendor-specific reset in psci DT only when they support them in their
>> firmware.
>>
>> Do we still think we are breaking anything in the spec or in the warm or the cold
>> reset path? If so can we discuss such use-cases?
>
> I don't know the spec, but see examples above.
>
> Cheers,
> Andre'
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-31 5:35 ` Shivendra Pratap
@ 2025-07-31 10:25 ` André Draszik
0 siblings, 0 replies; 32+ messages in thread
From: André Draszik @ 2025-07-31 10:25 UTC (permalink / raw)
To: Shivendra Pratap, Bartosz Golaszewski, Bjorn Andersson,
Sebastian Reichel, Rob Herring, Sudeep Holla, Souvik Chakravarty,
Krzysztof Kozlowski, Conor Dooley, Andy Yan, Mark Rutland,
Lorenzo Pieralisi, Arnd Bergmann, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, linux-pm,
linux-kernel, devicetree, linux-arm-kernel, linux-arm-msm,
Elliot Berman, Srinivas Kandagatla
On Thu, 2025-07-31 at 11:05 +0530, Shivendra Pratap wrote:
>
>
> On 7/30/2025 8:53 PM, André Draszik wrote:
> > More importantly, if e.g. an OOPS / panic happens after the reboot
> > notifier has run (and set vendor_reset.valid because a reboot mode
> > was requested), a panic handler changing reboot_mode to warm to
> > retain RAM contents will have no effect, because the the original
> > code above making those distinctions can not be reached anymore.
> >
> > Above scenario with OOPS / panic after reboot notifier could e.g.
> > happen as part of device_shutdown() - see kernel_shutdown_prepare()
>
> We can handle the panic path by adding a panic_notifier in psci
> and make vendor_reset.valid = false. Do you think adding this can clear
> the panic scenario above or there can still be some leak?
I think that would work. You then can't convey the reboot command, but
at that stage (panic/oops) it probably doesn't matter anymore, it only
cares about the crash handling which probably is enough.
Cheers,
Andre'
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode
2025-07-30 17:31 ` Arnd Bergmann
@ 2025-07-31 11:05 ` André Draszik
0 siblings, 0 replies; 32+ messages in thread
From: André Draszik @ 2025-07-31 11:05 UTC (permalink / raw)
To: Arnd Bergmann, Shivendra Pratap, Bartosz Golaszewski,
Bjorn Andersson, Sebastian Reichel, Rob Herring, Sudeep Holla,
Souvik Chakravarty, Krzysztof Kozlowski, Conor Dooley, Andy Yan,
Mark Rutland, Lorenzo Pieralisi, Konrad Dybcio,
cros-qcom-dts-watchers, Vinod Koul, Catalin Marinas, Will Deacon,
Florian Fainelli
Cc: Dmitry Baryshkov, Mukesh Ojha, Stephen Boyd, linux-pm,
linux-kernel, devicetree, linux-arm-kernel, linux-arm-msm,
Elliot Berman, Srinivas Kandagatla
On Wed, 2025-07-30 at 19:31 +0200, Arnd Bergmann wrote:
> On Wed, Jul 30, 2025, at 17:23, André Draszik wrote:
> > On Wed, 2025-07-30 at 18:33 +0530, Shivendra Pratap wrote:
> > > On 7/30/2025 2:14 PM, André Draszik wrote:
>
> > > 1. For this, both commands will be defined in the psci->reboot-mode DT Node with the arguments that
> > > are defined and supported by the firmware.
> > > 2. Further, such requirement will now be taken care by the underlying firmware that supports
> > > PSCI vendor-specific reset. When we call into firmware with vendor specific reset arguments,
> > > firmware will take care of the defined HW writes and warm/cold reset as per the mapping of the
> > > defined arguments. Firmware and the Linux kernel here are in agreement for executing the
> > > vendor-specific resets.
> >
> > So that means
> >
> > echo warm > /sys/kernel/reboot/mode
> > reboot bootloader
> >
> > and
> >
> > echo cold > /sys/kernel/reboot/mode
> > reboot bootloader
> >
> > can not be distinguished.
> >
> > The firmware can not know whether or not cold or warm reboot was
> > requested in this case by the user.
>
> My feeling is that this is fine: the /sys/kernel/reboot/mode
> interface is not really used on anything other than 32-bit
> arm and x86 machines, and the way it is specific as
> cold/warm/hard/soft/gpio is not that useful.
Currently, reboot_mode as such is also used by gs101 and later, we do
distinguish between the reboot_modes (cold/hard and warm/soft), although
generally not via sysfs indeed. And yes, gpio is a strangely specific
one.
I don't have insight into newer SoCs / board designs in that family,
but my understanding is that newer SoCs use PSCI for reboot as well
and I do believe being able to do cold reboot by default and warm
reboot in some cases (crash handling in particular) to still be a
valid use-case.
> I think for the purpose of the new code here, we should talk
> about reboot "commands" instead of "modes" to avoid confusing
> between the global "enum reboot_mode" variable and the
> firmware interface for reboot modes as listed in DT.
+1 It should really have been added as reboot command or reboot target
in the first place.
A.
^ permalink raw reply [flat|nested] 32+ messages in thread
end of thread, other threads:[~2025-07-31 11:08 UTC | newest]
Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-27 16:24 [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 01/10] power: reset: reboot-mode: Synchronize list traversal Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 02/10] power: reset: reboot-mode: Add device tree node-based registration Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 03/10] power: reset: reboot-mode: Add support for 64 bit magic Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 04/10] Documentation: ABI: Add sysfs-class-reboot-mode-reboot_modes Shivendra Pratap
2025-07-30 9:06 ` André Draszik
2025-07-30 13:08 ` Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 05/10] power: reset: reboot-mode: Expose sysfs for registered reboot_modes Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 06/10] dt-bindings: arm: Document reboot mode magic Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode Shivendra Pratap
2025-07-28 4:53 ` Krzysztof Kozlowski
2025-07-28 9:44 ` Dmitry Baryshkov
2025-07-28 11:52 ` Krzysztof Kozlowski
2025-07-28 12:03 ` Dmitry Baryshkov
2025-07-28 12:23 ` Krzysztof Kozlowski
2025-07-28 13:23 ` Sudeep Holla
2025-07-28 15:37 ` Dmitry Baryshkov
2025-07-28 15:54 ` Shivendra Pratap
2025-07-28 18:29 ` Dmitry Baryshkov
2025-07-29 3:14 ` Shivendra Pratap
2025-07-28 16:08 ` Shivendra Pratap
2025-07-30 8:44 ` André Draszik
2025-07-30 13:03 ` Shivendra Pratap
2025-07-30 15:23 ` André Draszik
2025-07-30 17:31 ` Arnd Bergmann
2025-07-31 11:05 ` André Draszik
2025-07-31 5:35 ` Shivendra Pratap
2025-07-31 10:25 ` André Draszik
2025-07-27 16:24 ` [PATCH v13 08/10] arm64: dts: qcom: qcm6490-idp: Add PSCI SYSTEM_RESET2 types Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 09/10] arm64: dts: qcom: qcs6490-rb3gen2: " Shivendra Pratap
2025-07-27 16:24 ` [PATCH v13 10/10] arm64: dts: qcom: sa8775p-ride: " Shivendra Pratap
2025-07-30 8:50 ` [PATCH v13 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 André Draszik
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).