Re: [PATCH 1/4] pmdomain: core: Support a boot performance floor until sync_state

From: Ulf Hansson

Date: Thu Nov 12 2026 - 08:06:29 EST


On Tue, Oct 13, 2026 at 2:49 PM Abel Vesa <abel.vesa@xxxxxxxxxxxxxxxx> wrote:
>
> Some providers retain conservative performance votes until their
> sync_state() callbacks run to accommodate hardware configured by
> firmware. Enforcing this policy inside the provider hides the floor
> from genpd when aggregating performance requirements towards parents.

Perhaps elaborate a bit more what this means for the performance
states for the parents.

>
> Add a provider-specified boot_performance_state for domains using
> GENPD_FLAG_POWER_UNKNOWN. Clamp the effective domain vote without
> changing individual consumer requests, and reaggregate those requests
> when sync_state releases the floor. Zero imposes no additional floor.

Why do we need to hook this up to GENPD_FLAG_POWER_UNKNOWN?

>
> Apply the floor before runtime power-on even without a preceding
> performance request. Do not skip an unchanged consumer request if the
> boot performance floor has yet to be applied.
>
> Report sync-time performance errors and continue the normal power-off
> attempt. Leave the provider sync callbacks and existing performance
> error handling in place, without introducing retries or a new recovery
> policy.
>
> Assisted-by: LLM
> Signed-off-by: Abel Vesa <abel.vesa@xxxxxxxxxxxxxxxx>
> ---
> drivers/pmdomain/core.c | 45 ++++++++++++++++++++++++++++++++++++++++-----
> include/linux/pm_domain.h | 6 ++++++
> 2 files changed, 46 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
> index 964e44c2f78f..6f2b406ce049 100644
> --- a/drivers/pmdomain/core.c
> +++ b/drivers/pmdomain/core.c
> @@ -512,6 +512,10 @@ static int _genpd_set_performance_state(struct generic_pm_domain *genpd,
> struct gpd_link *link = NULL;
> int ret;
>
> + /* Keep consumer votes intact; clamp only the effective domain vote. */
> + if (genpd_is_power_unknown(genpd) && genpd->stay_on)
> + state = max(state, genpd->boot_performance_state);
> +
> if (state == genpd->performance_state)
> return 0;
>
> @@ -555,6 +559,12 @@ static int _genpd_set_performance_state(struct generic_pm_domain *genpd,
> return ret;
> }
>
> +static bool genpd_needs_boot_performance_state(struct generic_pm_domain *genpd)
> +{
> + return genpd_is_power_unknown(genpd) && genpd->stay_on &&
> + genpd->performance_state < genpd->boot_performance_state;
> +}
> +
> static int genpd_set_performance_state(struct device *dev, unsigned int state)
> {
> struct generic_pm_domain *genpd = dev_to_genpd(dev);
> @@ -563,7 +573,7 @@ static int genpd_set_performance_state(struct device *dev, unsigned int state)
> int ret;
>
> prev_state = gpd_data->performance_state;
> - if (prev_state == state)
> + if (prev_state == state && !genpd_needs_boot_performance_state(genpd))
> return 0;
>
> gpd_data->performance_state = state;
> @@ -1180,6 +1190,14 @@ static int genpd_power_on(struct generic_pm_domain *genpd, struct device *dev,
> }
> }
>
> + /* A consumer may enable a domain without first requesting an OPP. */
> + if (genpd_needs_boot_performance_state(genpd)) {
> + ret = _genpd_set_performance_state(genpd,
> + genpd->performance_state, depth);
> + if (ret)
> + goto err;
> + }
> +
> ret = _genpd_power_on(genpd, true);
> if (ret)
> goto err;
> @@ -3794,6 +3812,25 @@ int of_genpd_parse_idle_states(struct device_node *dn,
> }
> EXPORT_SYMBOL_GPL(of_genpd_parse_idle_states);
>
> +/* Called with the domain lock held. */
> +static void genpd_sync_boot_state(struct generic_pm_domain *genpd)
> +{
> + unsigned int state;
> + int ret;
> +
> + genpd->stay_on = false;
> + if (genpd_is_power_unknown(genpd) && genpd->boot_performance_state) {
> + /* Reaggregate real votes, excluding the boot performance floor. */
> + state = _genpd_reeval_performance_state(genpd, 0);
> + ret = _genpd_set_performance_state(genpd, state, 0);
> + if (ret)
> + pr_err("%s: Failed to sync boot performance state: %d\n",
> + genpd->name, ret);
> + }
> +
> + genpd_power_off(genpd, false, 0);
> +}
> +
> /**
> * of_genpd_sync_state() - A common sync_state function for genpd providers
> * @np: The device node the genpd provider is associated with.
> @@ -3813,8 +3850,7 @@ void of_genpd_sync_state(struct device_node *np)
> list_for_each_entry(genpd, &gpd_list, gpd_list_node) {
> if (genpd->provider == of_fwnode_handle(np)) {
> genpd_lock(genpd);
> - genpd->stay_on = false;
> - genpd_power_off(genpd, false, 0);
> + genpd_sync_boot_state(genpd);
> genpd_unlock(genpd);
> }
> }
> @@ -3841,8 +3877,7 @@ static void genpd_provider_sync_state(struct device *dev)
>
> case GENPD_SYNC_STATE_SIMPLE:
> genpd_lock(genpd);
> - genpd->stay_on = false;
> - genpd_power_off(genpd, false, 0);
> + genpd_sync_boot_state(genpd);
> genpd_unlock(genpd);
> break;
>
> diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
> index 14e0e346c610..5927d9485054 100644
> --- a/include/linux/pm_domain.h
> +++ b/include/linux/pm_domain.h
> @@ -129,6 +129,11 @@ struct dev_pm_domain_list {
> * powered on during boot, genpd will prevent it
> * from being powered off until the ->sync_state
> * callback is invoked for it.
> + * Providers may also set boot_performance_state
> + * before pm_genpd_init() to specify a performance
> + * floor until sync_state. This must be a valid
> + * provider performance level, not a corner index.

What's a "corner index"?

> + * Zero disables the boot performance floor.
> */
> #define GENPD_FLAG_PM_CLK (1U << 0)
> #define GENPD_FLAG_IRQ_SAFE (1U << 1)
> @@ -221,6 +226,7 @@ struct generic_pm_domain {
> unsigned int suspended_count; /* System suspend device counter */
> unsigned int prepared_count; /* Suspend counter of prepared devices */
> unsigned int performance_state; /* Aggregated max performance state */
> + unsigned int boot_performance_state; /* Provider-specified boot floor */
> cpumask_var_t cpus; /* A cpumask of the attached CPUs */
> bool synced_poweroff; /* A consumer needs a synced poweroff */
> bool stay_on; /* Stay powered-on during boot. */
>
> --
> 2.54.0
>

Kind regards
Uffe