From: "Heiko Stübner" <heiko@sntech.de>
To: Ulf Hansson <ulfh@kernel.org>,
Sebastian Reichel <sebastian.reichel@collabora.com>,
Peter Geis <pgwipeout@gmail.com>,
1579567540@qq.com
Cc: linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
Cunhao Lu <1579567540@qq.com>
Subject: Re: [PATCH v2] pmdomain: rockchip: Roll back power-on when leaving idle fails
Date: Thu, 19 Nov 2026 13:33:40 +0100 [thread overview]
Message-ID: <X4VYa84sR92_76QOKnT74g@sntech.de> (raw)
In-Reply-To: <20261118-fix-rockchip-pmdomain-power-on-rollback-v2-1-3e4e93a19996@qq.com>
Am Mittwoch, 18. November 2026, 10:03:46 Mitteleuropäische Normalzeit schrieb Cunhao Lu via B4 Relay:
> From: Cunhao Lu <1579567540@qq.com>
>
> When NIU idle exit fails after PMU power-on, clocks and the regulator
> reference are released while the domain remains powered. genpd treats
> it as off and may power off its parents.
>
> Request idle again and, if successful, use the low-level power-off path
> before releasing resources. This preserves saved QoS and notifies
> firmware while retaining the original error.
>
> If rollback fails, resources are still released and genpd may power off
> the parents.
>
> Fixes: 6b2690df3f03 ("pmdomain: rockchip: fix rockchip_pd_power error handling")
> Signed-off-by: Cunhao Lu <1579567540@qq.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
> ---
> This pre-existing idle-exit failure case was reported by Sashiko AI
> during the RK3572 mainlining work:
> https://sashiko.dev/#/patchset/20261022-add-board-ok3572-c-v1-0-0b0fd85a31ee@qq.com?part=10
>
> If leaving NIU idle fails after PMU power-on, the domain remains powered
> while genpd treats it as off. The error path releases the clocks and
> regulator reference, and genpd may power off the parent domains.
>
> This patch requests idle again and, if successful, powers the domain
> off before releasing those resources. It preserves the saved QoS state
> and original error, and uses the low-level path to notify firmware.
>
> Validation:
>
> - All 48 host simulations passed, covering power cycles, idle-exit and
> rollback failures, QoS preservation and error propagation. No sanitizer
> findings.
>
> - Hardware testing on OK3572-C: 20 patched and 50 unpatched NVM1 power
> cycles passed. Request-write injection caused native idle-exit polling
> timeouts. The fix powered the domain off in 3/3 cases; the original
> driver left it ON. QoS and the original error were preserved, and
> retries succeeded after removing the injection.
>
> Persistent rollback idle and power-off timeouts were also tested:
> resources were still released with the domain ON and genpd OFF. These
> failure paths remain unresolved, and genpd may still power off the parents.
>
> AI assistance:
>
> - Codex / DeepSeek V4.1 Flash were used for:
> - Reviewing and adjusting code style to follow community conventions
> - Automating tests
> - Collecting data
> ---
> Changes in v2:
> - Rebase onto the next branch of Ulf Hansson's linux-pm.git tree.
> - Link to v1:
> https://patch.msgid.link/20261101-fix-rockchip-pmdomain-power-on-rollback-v1-1-59a45783e33e@qq.com
> ---
> drivers/pmdomain/rockchip/pm-domains.c | 27 ++++++++++++++++++++++++++-
> 1 file changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
> index 6abef60a5b4c..2c021784316a 100644
> --- a/drivers/pmdomain/rockchip/pm-domains.c
> +++ b/drivers/pmdomain/rockchip/pm-domains.c
> @@ -648,6 +648,29 @@ static int rockchip_do_pmu_set_power_domain(struct rockchip_pm_domain *pd,
> return 0;
> }
>
> +/*
> + * The caller holds the PMU lock and transition resources. Use the low-level
> + * power-off path to avoid overwriting the saved QoS state.
> + */
> +static void rockchip_pd_power_on_rollback(struct rockchip_pm_domain *pd)
> +{
> + int ret;
> +
> + ret = rockchip_pmu_set_idle_request(pd, true);
> + if (ret < 0) {
> + dev_err(pd->pmu->dev,
> + "failed to idle domain '%s' on rollback: %d\n",
> + pd->genpd.name, ret);
> + return;
> + }
> +
> + ret = rockchip_do_pmu_set_power_domain(pd, false);
> + if (ret < 0)
> + dev_err(pd->pmu->dev,
> + "failed to power off domain '%s' on rollback: %d\n",
> + pd->genpd.name, ret);
> +}
> +
> static int rockchip_pd_power(struct rockchip_pm_domain *pd, bool power_on)
> {
> struct rockchip_pmu *pmu = pd->pmu;
> @@ -682,8 +705,10 @@ static int rockchip_pd_power(struct rockchip_pm_domain *pd, bool power_on)
> if (power_on) {
> /* if powering up, leave idle mode */
> ret = rockchip_pmu_set_idle_request(pd, false);
> - if (ret < 0)
> + if (ret < 0) {
> + rockchip_pd_power_on_rollback(pd);
> goto out;
> + }
>
> rockchip_pmu_restore_qos(pd);
> }
>
> ---
> base-commit: 6f5c8ec9302c5ad8904dbdfe8cf2a538ff835572
> change-id: 20261101-fix-rockchip-pmdomain-power-on-rollback-c11e1014ef11
>
> Best regards,
> --
> Cunhao Lu <1579567540@qq.com>
>
>
>
prev parent reply other threads:[~2026-11-19 12:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 9:03 [PATCH v2] pmdomain: rockchip: Roll back power-on when leaving idle fails Cunhao Lu via B4 Relay
2026-11-19 12:33 ` Heiko Stübner [this message]
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=X4VYa84sR92_76QOKnT74g@sntech.de \
--to=heiko@sntech.de \
--cc=1579567540@qq.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=pgwipeout@gmail.com \
--cc=sebastian.reichel@collabora.com \
--cc=ulfh@kernel.org \
/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