]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
pmdomain: core: Leave powered-on genpds on until sync_state
authorUlf Hansson <ulf.hansson@linaro.org>
Tue, 1 Jul 2025 11:47:24 +0000 (13:47 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Wed, 9 Jul 2025 11:29:57 +0000 (13:29 +0200)
Powering-off a genpd that was on during boot, before all of its consumer
devices have been probed, is certainly prone to problems.

For OF based platforms we can rely on using the sync_state mechanism that
the fw_devlink provides, to understand when all consumers for a genpd
provider have been probed. Let's therefore prevent these genpds from being
powered-off until the ->sync_state() callback gets called.

Note that, for non-OF based platform we will keep relying on the
late_initcall_sync, which seems to be the best we can do for now.

Suggested-by: Saravana Kannan <saravanak@google.com>
Tested-by: Hiago De Franco <hiago.franco@toradex.com> # Colibri iMX8X
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> # TI AM62A,Xilinx ZynqMP ZCU106
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20250701114733.636510-23-ulf.hansson@linaro.org
drivers/pmdomain/core.c

index 18951ed6295d8e8fb0f453919dde71bd69ca2fba..a86aeda1c955679a1ecc84c506bd95df29cb417e 100644 (file)
@@ -1324,6 +1324,7 @@ err_poweroff:
        return ret;
 }
 
+#ifndef CONFIG_PM_GENERIC_DOMAINS_OF
 static bool pd_ignore_unused;
 static int __init pd_ignore_unused_setup(char *__unused)
 {
@@ -1359,6 +1360,7 @@ static int __init genpd_power_off_unused(void)
        return 0;
 }
 late_initcall_sync(genpd_power_off_unused);
+#endif
 
 #ifdef CONFIG_PM_SLEEP
 
@@ -3459,6 +3461,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_unlock(genpd);
                }
@@ -3486,6 +3489,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_unlock(genpd);
                break;