[PATCH] pmdomain: core: Propagate power-on errors during system resume
From: Cunhao Lu via B4 Relay
Date: Thu Dec 03 2026 - 05:09:25 EST
From: Cunhao Lu <1579567540@xxxxxx>
genpd_sync_power_on() ignores power-on errors and marks the domain on.
Genpd can then attempt to power on a child after its parent fails and
run device start and noirq resume callbacks with the domain off.
Mark each domain on only after power-on succeeds and return the first
error before either callback runs. On failure, drop the parent
subdomain references acquired by the attempt and try to power off the
parents already processed, in reverse order.
Balance suspended_count even on failure so the next suspend waits for
all devices to stop before powering off a shared domain. The void
dev_pm_genpd_resume() path logs the domain name and errno.
Fixes: 802d8b49a770 ("PM / Domains: Introduce simplified power on routine for system resume")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Cunhao Lu <1579567540@xxxxxx>
---
I found this issue while testing RK3572 power domain support.
genpd_sync_power_on() discards power-on errors and marks domains as
on. Device start and noirq resume can then run with the domain off.
This patch returns the power-on error to the PM core before either
callback runs for the affected device, unwinds parent references and
balances the suspend count. dev_pm_genpd_resume() logs the error.
Validation:
- Tested in QEMU with injected power-on errors. Before the fix, device
start and noirq resume ran after the errors. With the fix, the PM
core received the original errors and genpd skipped both callbacks
for the affected device. In a two-device test with a power-on failure,
the shared domain's suspend count returned to zero after resume. On
the next suspend, the domain powered off only after both devices
stopped.
- Tested on OK3572-C by injecting NPU parent and child power-on
failures and a shift-ready timeout. Genpd returned the original
errors and skipped the NPU consumer's noirq resume callback.
---
drivers/pmdomain/core.c | 56 ++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 46 insertions(+), 10 deletions(-)
diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index 4e0a76f1f08f..00211ed76d4a 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -1586,17 +1586,19 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock,
* @use_lock: use the lock.
* @depth: nesting count for lockdep.
*
- * This function is only called in "noirq" and "syscore" stages of system power
- * transitions. The "noirq" callbacks may be executed asynchronously, thus in
- * these cases the lock must be held.
+ * Noirq callers must hold the domain lock as callbacks may run asynchronously.
+ * Also used in syscore, cpuidle and CPU hotplug paths.
+ *
+ * Return: 0 on success or the power-on error.
*/
-static void genpd_sync_power_on(struct generic_pm_domain *genpd, bool use_lock,
- unsigned int depth)
+static int genpd_sync_power_on(struct generic_pm_domain *genpd,
+ bool use_lock, unsigned int depth)
{
struct gpd_link *link;
+ int ret;
if (genpd_status_on_unlocked(genpd))
- return;
+ return 0;
list_for_each_entry(link, &genpd->child_links, child_node) {
genpd_sd_counter_inc(link->parent);
@@ -1604,14 +1606,40 @@ static void genpd_sync_power_on(struct generic_pm_domain *genpd, bool use_lock,
if (use_lock)
genpd_lock_nested(link->parent, depth + 1);
- genpd_sync_power_on(link->parent, use_lock, depth + 1);
+ ret = genpd_sync_power_on(link->parent, use_lock, depth + 1);
if (use_lock)
genpd_unlock(link->parent);
+
+ if (ret) {
+ genpd_sd_counter_dec(link->parent);
+ goto err;
+ }
}
- _genpd_power_on(genpd, false);
+ ret = _genpd_power_on(genpd, false);
+ if (ret)
+ goto err;
+
genpd->status = GENPD_STATE_ON;
+
+ return 0;
+
+ err:
+ list_for_each_entry_continue_reverse(link,
+ &genpd->child_links,
+ child_node) {
+ genpd_sd_counter_dec(link->parent);
+
+ if (use_lock)
+ genpd_lock_nested(link->parent, depth + 1);
+
+ genpd_sync_power_off(link->parent, use_lock, depth + 1);
+ if (use_lock)
+ genpd_unlock(link->parent);
+ }
+
+ return ret;
}
/**
@@ -1737,10 +1765,13 @@ static int genpd_finish_resume(struct device *dev,
return resume_noirq(dev);
genpd_lock(genpd);
- genpd_sync_power_on(genpd, true, 0);
+ ret = genpd_sync_power_on(genpd, true, 0);
genpd->suspended_count--;
genpd_unlock(genpd);
+ if (ret)
+ return ret;
+
if (genpd->dev_ops.stop && genpd->dev_ops.start &&
!pm_runtime_status_suspended(dev)) {
ret = genpd_start_dev(genpd, dev);
@@ -1861,6 +1892,7 @@ static void genpd_switch_state(struct device *dev, bool suspend)
{
struct generic_pm_domain *genpd;
bool use_lock;
+ int ret;
genpd = dev_to_genpd_safe(dev);
if (!genpd)
@@ -1875,7 +1907,11 @@ static void genpd_switch_state(struct device *dev, bool suspend)
genpd->suspended_count++;
genpd_sync_power_off(genpd, use_lock, 0);
} else {
- genpd_sync_power_on(genpd, use_lock, 0);
+ ret = genpd_sync_power_on(genpd, use_lock, 0);
+ if (ret)
+ pr_err("Failed to resume PM domain %s: %d\n",
+ genpd->name, ret);
+
genpd->suspended_count--;
}
---
base-commit: f38b782ce0702cd07438e982ee42e1f9427d8946
change-id: 20261203-fix-genpd-resume-power-on-c78e4b4044df
Best regards,
--
Cunhao Lu <1579567540@xxxxxx>