* [PATCH v2] pmdomain: rockchip: Roll back power-on when leaving idle fails
@ 2026-11-18 9:03 Cunhao Lu via B4 Relay
2026-11-19 12:33 ` Heiko Stübner
0 siblings, 1 reply; 2+ messages in thread
From: Cunhao Lu via B4 Relay @ 2026-11-18 9:03 UTC (permalink / raw)
To: Ulf Hansson, Heiko Stuebner, Sebastian Reichel, Peter Geis
Cc: linux-pm, linux-arm-kernel, linux-rockchip, linux-kernel,
Cunhao Lu
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>
---
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>
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] pmdomain: rockchip: Roll back power-on when leaving idle fails
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
0 siblings, 0 replies; 2+ messages in thread
From: Heiko Stübner @ 2026-11-19 12:33 UTC (permalink / raw)
To: Ulf Hansson, Sebastian Reichel, Peter Geis, 1579567540
Cc: linux-pm, linux-arm-kernel, linux-rockchip, linux-kernel,
Cunhao Lu
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>
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-19 12:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox