[PATCH 2/4] pmdomain: core: Prepare boot performance floors before system suspend

From: Abel Vesa

Date: Tue Oct 13 2026 - 09:20:16 EST


A system suspend can occur before a provider has received sync_state().
If a domain has not been used through runtime PM, its boot performance
floor may not have been applied when genpd_sync_power_on() enables it
during resume-noirq.

Prepare boot performance floors from genpd_prepare(), where performance
callbacks may sleep. Walk the parent hierarchy even when the device's
own domain has no boot floor: a parent without direct consumers would
otherwise miss preparation entirely. Take parent locks in the existing
child-to-parent order and propagate preparation failures to the PM core.

Also retain boot power protection in genpd_sync_power_off() for domains
with a boot performance floor. This prevents the system-sleep path from
withdrawing their power vote while boot protection remains active.

Keep performance programming out of resume-noirq. Domains with their
floor already satisfied do not need another performance update, and
no floor is imposed after sync_state() releases boot protection.

Assisted-by: LLM
Signed-off-by: Abel Vesa <abel.vesa@xxxxxxxxxxxxxxxx>
---
drivers/pmdomain/core.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index 6f2b406ce049..4ff55175d899 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -1538,7 +1538,9 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock,
{
struct gpd_link *link;

- if (!genpd_status_on_unlocked(genpd) || genpd_is_always_on(genpd))
+ if (!genpd_status_on_unlocked(genpd) || genpd_is_always_on(genpd) ||
+ (genpd_is_power_unknown(genpd) && genpd->stay_on &&
+ genpd->boot_performance_state))
return;

if (genpd->suspended_count != genpd->device_count
@@ -1623,6 +1625,31 @@ static void genpd_sync_power_on(struct generic_pm_domain *genpd, bool use_lock,
genpd->status = GENPD_STATE_ON;
}

+/* Called with the domain lock held, before entering noirq. */
+static int genpd_prepare_boot_performance(struct generic_pm_domain *genpd,
+ unsigned int depth)
+{
+ struct gpd_link *link;
+ int ret;
+
+ /* Parents may need a boot floor even when this domain does not. */
+ list_for_each_entry(link, &genpd->child_links, child_node) {
+ struct generic_pm_domain *parent = link->parent;
+
+ genpd_lock_nested(parent, depth + 1);
+ ret = genpd_prepare_boot_performance(parent, depth + 1);
+ genpd_unlock(parent);
+ if (ret)
+ return ret;
+ }
+
+ if (genpd_needs_boot_performance_state(genpd))
+ return _genpd_set_performance_state(genpd,
+ genpd->performance_state, depth);
+
+ return 0;
+}
+
/**
* genpd_prepare - Start power transition of a device in a PM domain.
* @dev: Device to start the transition of.
@@ -1644,6 +1671,12 @@ static int genpd_prepare(struct device *dev)
return -EINVAL;

genpd_lock(genpd);
+ /* Performance callbacks may sleep; prepare the hierarchy before noirq. */
+ ret = genpd_prepare_boot_performance(genpd, 0);
+ if (ret) {
+ genpd_unlock(genpd);
+ return ret;
+ }
genpd->prepared_count++;
genpd_unlock(genpd);


--
2.54.0