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

From: Ulf Hansson

Date: Thu Nov 12 2026 - 08:50:24 EST


On Tue, Oct 13, 2026 at 2:49 PM Abel Vesa <abel.vesa@xxxxxxxxxxxxxxxx> wrote:
>
> 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.

Would you mind elaborating a bit more why this is a problem for the
platforms in question?

>
> 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.

Question, if doing this in genpd_prepare() how would that protect us
from changes happening later on during system suspend, when a consumer
driver decides to update the performance state vote for its device?

In regards to system suspend, even if the sync state has not happened
yet, we are doing a power off of the genpd. I assume this is okay,
while still keeping the current genpd->performance_state or maybe it
isn't?

If there is no problem with that above, maybe it's easier to continue
to let the genpd provider (through its ->power_on() callback) manage
the restoring of the genpd->performance_state itself? In that case, we
don't need to care about the genpd->boot_performance_state, as it
should be indirectly applied anyway, right?

>
> 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.

I don't get this, sorry. What is "boot power protection"?

>
> 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.

Please rephrase this. I don't understand what "releases boot protection" means.

>
> Assisted-by: LLM
> Signed-off-by: Abel Vesa <abel.vesa@xxxxxxxxxxxxxxxx>

Kind regards
Uffe

> ---
> 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
>