* Re: [RFC PATCH] mfd: rk8xx-core: Leave a warm restart to the next handler
[not found] <sashiko-outbox-248402@kernel.org>
@ 2026-12-04 2:48 ` Nguyen Cong Thanh
0 siblings, 0 replies; 2+ messages in thread
From: Nguyen Cong Thanh @ 2026-12-04 2:48 UTC (permalink / raw)
To: mfd
Cc: Lee Jones, Heiko Stuebner, Peter Geis, Quentin Schulz,
linux-rockchip, linux-kernel
On Thu, 03 Dec 2026 18:35:35 +0000, sashiko-bot@kernel.org wrote:
> Does skipping DEV_RST leave RK817_SLPPIN_FUNC_MSK armed with
> SLPPIN_DN_FUN across a normal warm reboot?
Yes, I think it does. kernel_restart() runs device_shutdown() before
the restart handlers, rk8xx_shutdown() sets SLPPIN_DN_FUN in
RK817_SYS_CFG(3) on RK809/RK817 whatever system_state is, and with
DEV_RST skipped nothing clears it: rk817_pre_init_reg[] does not touch
it, and only rk8xx_resume() writes SLPPIN_NULL_FUN.
My tests did not cover this. The warm restarts I ran were all
reboot=panic_warm after a panic, which goes through emergency_restart()
and does not call device_shutdown(). A plain reboot with reboot=warm,
which does run rk8xx_shutdown(), was not tested.
For v2 I would add a patch before this one, so that rk8xx_shutdown()
sets the power-down function only when system_state is
SYSTEM_POWER_OFF and a restart leaves the sleep pin function as it
was. Lee, Peter, would you rather have that, or the sleep pin function
cleared at probe in rk817_pre_init_reg[], or both? Before v2 I will
also run plain warm reboots on the board and read RK817_SYS_CFG(3)
after them.
> Should it include:
>
> Fixes: 56f216d8efbc ("mfd: rk808: Add reboot support to rk808.c")
I left it out on purpose: the handler has restarted the PMIC in every
mode since that commit, so this is a change of behaviour rather than
a fix of a regression. I can add the tag if Lee prefers.
Thanks,
Nguyen Cong Thanh
^ permalink raw reply [flat|nested] 2+ messages in thread
* [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; 2+ messages 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] 2+ messages in thread
end of thread, other threads:[~2026-12-04 2:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <sashiko-outbox-248402@kernel.org>
2026-12-04 2:48 ` [RFC PATCH] mfd: rk8xx-core: Leave a warm restart to the next handler Nguyen Cong Thanh
2026-12-03 17:29 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®