From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.171 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796318985; b=XpBFshpI2RPfDe7rRj3M5Qh8a6uEgkTa4bvqteyAIFeKiypTMXyL4RUpavM4j+01QV76 xyKg00Tk6QCdCCktQ99XAwaD1+dyKbM7PbxsJL1Fc69akYvmiOKoI6J52Xc2EnFiMRCpZ QwudxxBWf9MEHVhtifKpqFmHcEUDvlNjlP6V3hMCT3a5APMe/wOz1329F51zTkbrucg90 ujhf21bio672iiYC6esaweMz7WTiVZI1MAQ0tsMF594La96ZEVgrsPBvrl3GugLAgOht+ 1iEW2r7Pq4SOWuT6jAUxmLNppLJmeDy//bjNPiEN3RELYzQdDrvPk77X/9AxO3YX0bQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796318985; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=NpTaSepXGDe6PW8eVUP0hIUnGK0mdwjSTjlfTuXDxEI=; b=1FSn01i77bf/3WhIOer+m701M77iaChHCvEcUTZZSDcw7D2LjtYa9V9llZUAiZNXDh6k TL7BgYGt2sqdAYr+WMaktRV8VtrtogV496iWWClLI+YKhMIbigLkd4htaZ8iIxpbzpU4M e3GtqI9gmOkdTiQp3CabE0oOWwUPYCYLuVpC8Q5QaxsEo/Gat5+vA7ZafvSzawPFwvJ2a DoGxJix8n1LN1iyjUz0piZK8g3Oh9P/EtWKM6Bxo0pKqSWHGvbnQO3mheL+iyFaTSF8y2 nLZ+WBpLWVd9ezlkKvFzXIwPsDFnaNrKqc/ihx4QpannTVaozGsqtxNNvAH7fHtls6Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=SdTLbsG9; arc=none smtp.remote-ip=209.85.214.171 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA61C606A32C for ; Thu, 3 Dec 2026 17:29:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BA61C606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=SdTLbsG9 Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2f048476ab9so1103795ad.0 for ; Thu, 03 Dec 2026 09:29:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796318984; x=1796923784; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=NpTaSepXGDe6PW8eVUP0hIUnGK0mdwjSTjlfTuXDxEI=; b=SdTLbsG9Z2cceZe9wpl5GOE1tFfecdHmTUrlR/QE53hEKkBeWiQOBChlxMsUZrecjA dQTKVH4RdCJ4VAoImIL9KIuCQyaaNUYqR8W2B1fhxlsiotPea78J8L0PW3ULvujeAuO3 55rMxgs2fKeo3Pe4hMNnW0Tk/IfBuo/Vu/mJR3KXz7utUrEohcajSrt1/lQeXmZAREl3 2cN1oWsYlH97P0Ev/bnDBTYrRm3VUhJw8Z97vRI1Z+j08UkjH+O4yaTtgi/wrTdPXDCw xuWEE3CJm5bBSm5ZzyzEfsLlLDsTHlPfTIXfoQmvvbtjSPBP1LPzPRecAaDpOw020EV8 a7lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796318984; x=1796923784; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NpTaSepXGDe6PW8eVUP0hIUnGK0mdwjSTjlfTuXDxEI=; b=mkJ7i2+sdvfUptsbBKyxPXGWTkq5vNa5omabuciUJylYD/uZOzBD3puM+wwxJ+QYXa BG2ZxpkwHMBK3hgz8XqL1K7LS3rfsK/kYKkIPDSswM/taA4BFK7lQhdN9NyblaYK45HZ Py5dOcaiMBo5SPgenIfZcJPrV/IPezacuYon7NHArfKZm8mAt46xP+qRXKAxKACWFXrz boKrXdi7wNYZbqL3rSVbWBI7y8Yne4FsQAvUJLLG4FWY4TAcPp8v+HwoaSxZhfkkuao8 IwPedRcgnAbx0541qijv4JiytBS+jEGBomcNRwRZdl9qTkKhS5aM8eJj+l2iTGqRooiF vkDQ== X-Forwarded-Encrypted: i=1; AL+hErEXnGbeiQIVZDa1yohnZurE49CiOtfKmcBosHZzBV4tv9G0tC6DbSrnIvJCK6Iw9Ewcw87nR+NFOQ7SyxU=@vger.kernel.org X-Gm-Message-State: APuU4Z8JbgP7FOsVY7kB2ST/THx2S5KOt5qmp5TYSt5QpGZ0mLBBYnGy PI3ydEW0hosam3X/A1PwkwHgMEgKMvZz/vNJprw2D71z6WrhP2d7oRUnc/tRQIU= X-Gm-Gg: AZFdTZeU6DlDXokG6xSpk36fRoYe3h4PKow7NoLgdDVeuPByt7jDiMV+2YcjHWgqm4+ pbhWKqplKH9pEzD21/xaA7yN//3Q/sXVU95ABvbSRiTb1mgvazH17vQTdsJmXVTnsG16TMqrcx0 rDAKVabjAqk+42dxLuTkqN+7lCJ7t0mEL+ZCxvDBvGrDBkBD3YN+I26YMobEL6YN4KKpVfspd8L w+2aYiE2lWLMdR8gEP+GC02vPVMaQqpxLd3wB3r8b3v8mLeKcrLrpObdH5SzBA5Md/BNHn1tifx /ivbO0S2aebPsWzfMWn6UlvGkbG0nzVU5OUi4nuI+JIQYUwJw6nEKFLozoyWYQqUoe66X87k97N UBNsLE1CppXGgYvKkyPtX9ExXbzrj3A49zOjP7pyTAhuMuGYBLo5iagoOEwVKDF1Rcjg2M5aYDH ap2Cd3c2Dk7ON5v1yt/sXyg69Qyoff1iw7HB1dcy02eD/66y8IThmVyC4ZXG/aE9Y/LEkCZ0IqT FZbBgpwjuSVHsaU3USzfASKNRa/doxWsI+fMTS1i52beIQhpTdjIFILF3aYsp7MzUtrNj2g1wFo CQuZO0JU53TPYZAmUCJqPmF/u9OTdbFmDHzs37nNxA== X-Received: by 2002:a17:903:32c3:b0:2f0:6576:280f with SMTP id d9443c01a7336-2f065762a04mr508391665ad.19.1796318983870; Thu, 03 Dec 2026 09:29:43 -0800 (PST) Received: from CONGTHANH ([2405:4802:703:8c30:8dda:609b:7346:d02d]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f03f0c1f42sm225040105ad.25.2026.12.03.09.29.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 09:29:42 -0800 (PST) From: Nguyen Cong Thanh To: Lee Jones , mfd@lists.linux.dev Cc: Heiko Stuebner , Peter Geis , Quentin Schulz , 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 Message-ID: <20261203172934.130136-1-congthanh.ml.2509@gmail.com> X-Mailer: git-send-email 2.51.0.windows.2 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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