mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nguyen Cong Thanh <congthanh.ml.2509@gmail.com>
To: Lee Jones <lee@kernel.org>, mfd@lists.linux.dev
Cc: Heiko Stuebner <heiko@sntech.de>,
	Peter Geis <pgwipeout@gmail.com>,
	Quentin Schulz <quentin.schulz@cherry.de>,
	linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH] mfd: rk8xx-core: Leave a warm restart to the next handler
Date: Fri,  4 Dec 2026 00:29:34 +0700	[thread overview]
Message-ID: <20261203172934.130136-1-congthanh.ml.2509@gmail.com> (raw)

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


                 reply	other threads:[~2026-12-03 17:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261203172934.130136-1-congthanh.ml.2509@gmail.com \
    --to=congthanh.ml.2509@gmail.com \
    --cc=heiko@sntech.de \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mfd@lists.linux.dev \
    --cc=pgwipeout@gmail.com \
    --cc=quentin.schulz@cherry.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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®