Skip to content

PSCI reboot mode driver changes#1277

Merged
Komal-Bajaj merged 5 commits into
qualcomm-linux:early/hwe/shikra/driversfrom
apateriy-qcom:topics_shikra_drivers
Jun 9, 2026
Merged

PSCI reboot mode driver changes#1277
Komal-Bajaj merged 5 commits into
qualcomm-linux:early/hwe/shikra/driversfrom
apateriy-qcom:topics_shikra_drivers

Conversation

@apateriy-qcom

Copy link
Copy Markdown

PSCI reboot mode driver changes for edl and bootloader

Shivendra Pratap and others added 4 commits June 8, 2026 10:46
Devres APIs are intended for use in drivers, and they should be
avoided in shared subsystem code which is being used by multiple
drivers. Avoid using devres based allocations in the reboot-mode
subsystem and manually free the resources.

Replace devm_kzalloc with kzalloc and handle memory cleanup
explicitly.

Fixes: 4fcd504 ("power: reset: add reboot mode driver")
Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20251109-arm-psci-system_reset2-vendor-reboots-v17-1-46e085bca4cc@oss.qualcomm.com
Signed-off-by: Anurag Pateriya <apateriy@qti.qualcomm.com>
Upstream-Status: Submitted [https://lore.kernel.org/r/20251109-arm-psci-system_reset2-vendor-reboots-v17-1-46e085bca4cc@oss.qualcomm.com]
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.

Remove the dependency on struct device and introduce support for
firmware node (fwnode) 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>
Link: https://lore.kernel.org/r/20251109-arm-psci-system_reset2-vendor-reboots-v17-2-46e085bca4cc@oss.qualcomm.com
Signed-off-by: Anurag Pateriya <apateriy@qti.qualcomm.com>
Upstream-Status: Submitted [https://lore.kernel.org/r/20251109-arm-psci-system_reset2-vendor-reboots-v17-2-46e085bca4cc@oss.qualcomm.com]
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.

Reviewed-by: Umang Chheda <umang.chheda@oss.qualcomm.com>
Reviewed-by: Nirmesh Kumar Singh <nirmesh.singh@oss.qualcomm.com>
Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20251109-arm-psci-system_reset2-vendor-reboots-v17-3-46e085bca4cc@oss.qualcomm.com
Signed-off-by: Anurag Pateriya <apateriy@qti.qualcomm.com>
Upstream-Status: Submitted [https://lore.kernel.org/r/20251109-arm-psci-system_reset2-vendor-reboots-v17-3-46e085bca4cc@oss.qualcomm.com]
Implement PSCI SYSTEM_RESET2 vendor-specific resets by registering with
the reboot-mode framework. A late_initcall registers the PSCI node's
reboot-mode child, a reboot-mode write callback sets reset_type/cookie
for the subsequent notifier, and a panic notifier clears the vendor
reset state to avoid stale values after a kernel panic.

Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20251109-arm-psci-system_reset2-vendor-reboots-v17-7-46e085bca4cc@oss.qualcomm.com
Signed-off-by: Anurag Pateriya <apateriy@qti.qualcomm.com>
Upstream-Status: Submitted [https://lore.kernel.org/r/20251109-arm-psci-system_reset2-vendor-reboots-v17-7-46e085bca4cc@oss.qualcomm.com]
@apateriy-qcom apateriy-qcom force-pushed the topics_shikra_drivers branch from cfb917d to 3521b0e Compare June 8, 2026 05:21
… set

reboot_mode_create_device() and reboot_mode_unregister_device()
unconditionally dereference reboot->dev->driver->name to name the
sysfs device.  psci_init_vendor_reset() allocates a reboot_mode_driver
with kzalloc (so reboot->dev == NULL) and never sets reboot->dev,
causing a NULL pointer dereference at boot:

  Unable to handle kernel NULL pointer dereference at virtual address 0000000000000068
  pc : reboot_mode_register+0x334/0x3b8
  psci_init_vendor_reset+0xdc/0x128
  Kernel panic - not syncing: Oops: Fatal exception

The offset 0x68 is the 'driver' pointer inside struct device on arm64,
confirming that reboot->dev itself is NULL.

Fix this by adding a 'name' field to struct reboot_mode_driver.
reboot_mode_create_device() and reboot_mode_unregister_device() now
prefer reboot->name; they fall back to reboot->dev->driver->name only
when reboot->name is NULL, and return -EINVAL / return early if neither
source is available.  Set reboot->name = "psci" in
psci_init_vendor_reset() so the sysfs device is correctly named.

Existing device-based callers (nvmem-reboot-mode, syscon-reboot-mode,
qcom-pon) are unaffected: they set reboot->dev before calling
devm_reboot_mode_register(), so the fallback path is taken as before.

Fixes: cfaf0a9 ("power: reset: reboot-mode: Expose sysfs for registered reboot_modes")
Fixes: 614b17a ("firmware: psci: Implement vendor-specific resets as reboot-mode")
Reported-by: LAVA job 91409 <https://lava-oss.qualcomm.com/scheduler/job/91409>
Signed-off-by: Salendarsingh Gaud <sgaud@qti.qualcomm.com>
Signed-off-by: Anurag Pateriya <apateriy@qti.qualcomm.com>
Upstream-Status: Inappropriate [workaround]
@apateriy-qcom apateriy-qcom force-pushed the topics_shikra_drivers branch from 3521b0e to d0c6c84 Compare June 8, 2026 05:24
@Komal-Bajaj Komal-Bajaj merged commit 83c006e into qualcomm-linux:early/hwe/shikra/drivers Jun 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants