* [RFC PATCH] mfd: rk8xx-core: Leave a warm restart to the next handler
@ 2026-12-03 17:29 Nguyen Cong Thanh
0 siblings, 0 replies; only message in thread
From: Nguyen Cong Thanh @ 2026-12-03 17:29 UTC (permalink / raw)
To: Lee Jones, mfd
Cc: Heiko Stuebner, Peter Geis, Quentin Schulz, linux-rockchip, linux-kernel
On RK809 and RK817 the restart handler sets DEV_RST, which restarts the
PMIC. It is registered at SYS_OFF_PRIO_HIGH, ahead of the PSCI handler
(priority 129), and it runs whatever the reboot mode is.
On an RK3566 board with an RK809 this loses the log of a panic. After a
restart through this handler, by reboot or by SysRq b, /sys/fs/pstore
was empty, while the vendor kernel of the board, which restarts through
the firmware, kept its console log in the same ramoops region. Asking
for a warm restart after a panic with reboot=panic_warm does not change
that, as the handler does not look at the reboot mode.
Return NOTIFY_DONE for REBOOT_WARM, so that the next handler restarts
the system. The default mode, cold, and the other modes still restart
the PMIC.
The PMIC restart came with commit 56f216d8efbc ("mfd: rk808: Add reboot
support to rk808.c"), whose submission noted that psci-reset was not
reliable on RK356x at the time. This change keeps the PMIC as the
default and only leaves it when a warm restart is asked for.
Signed-off-by: Nguyen Cong Thanh <congthanh.ml.2509@gmail.com>
---
I used Claude to investigate the issue and draft the patch and commit
message, and Codex to review the patch.
RFC: Peter, Lee, should the driver leave a warm restart to the next
handler, given that on some boards the PMIC may be the only reliable
way to restart? The v3 notes of 56f216d8efbc said psci-reset on rk356x
was not reliable until the rk356x TF-A source was released. I have not
yet tried a warm restart on mainline TF-A: v2.16 implements SYSTEM_RESET
on rk3568 (CRU global soft reset) but not SYSTEM_RESET2, so a warm
request ends up as SYSTEM_RESET there.
REBOOT_SOFT, which the PSCI handler also turns into a warm reset when
SYSTEM_RESET2 is there, still goes through the PMIC here: only the mode
I tested changes.
Tested on v6.18.48 on an RK3566 board with an RK809, vendor BL31 v1.44,
PSCI 1.1, with an earlier version of this patch that also left
REBOOT_SOFT to the next handler (the cold and warm paths are the same
as here):
- reboot=panic_warm panic=10, panic with SysRq c, 18 times: the board
came back 18/18. In the second run of 8, the next boot had the panic
record (dmesg-ramoops-0) and console-ramoops-0 in pstore, 8/8. In the
first run of 10, a bug in our userspace copy script lost the copies,
so that run counts only for coming back.
- plain reboot (mode cold), 3 times: the board came back 3/3 and pstore
was empty, as before.
Not measured: rail voltages, including the levels the regulators keep
across a warm restart, and which PSCI call the firmware received.
This exact version is build-tested only (arm64, W=1). It differs from
the version tested above only in no longer leaving REBOOT_SOFT to the
next handler and in the comment, so the warm and cold paths are the
ones tested.
drivers/mfd/rk8xx-core.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/mfd/rk8xx-core.c b/drivers/mfd/rk8xx-core.c
index 058cd4ed6..c070d3337 100644
--- a/drivers/mfd/rk8xx-core.c
+++ b/drivers/mfd/rk8xx-core.c
@@ -716,6 +716,16 @@ static int rk808_restart(struct sys_off_data *data)
unsigned int reg, bit;
int ret;
+ /*
+ * Restarting the PMIC is not a warm restart. A warm restart is asked
+ * for to keep the memory content, for example the log of a panic in
+ * a ramoops region with reboot=panic_warm, so leave it to the next
+ * handler, such as the firmware's system reset. Every other mode
+ * still restarts the PMIC.
+ */
+ if (data->mode == REBOOT_WARM)
+ return NOTIFY_DONE;
+
switch (rk808->variant) {
case RK809_ID:
case RK817_ID:
base-commit: 93360adf279353f5518e4afdc79a67c256dd352a
--
2.34.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-03 17:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-03 17:29 [RFC PATCH] mfd: rk8xx-core: Leave a warm restart to the next handler Nguyen Cong Thanh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®