diff mbox series

pmdomain: core: only disable unused domains after genpd_power_off_unused has passed

Message ID 20250326-pmdomain_core-v1-1-c35d342f934f@pengutronix.de (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series pmdomain: core: only disable unused domains after genpd_power_off_unused has passed | expand

Commit Message

Michael Grzeschik March 25, 2025, 11:13 p.m. UTC
If the genpd_power_off_unsused late_initcall did not pass yet, skip any
genpd_power_off call. During the boot phase possible domain consumers
could show up, so it is not helpful to disable and enable the power
domains during that time.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 drivers/pmdomain/core.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)


---
base-commit: b3c623b9a94f7f798715c87e7a75ceeecf15292f
change-id: 20250326-pmdomain_core-db2a2f2bc0a6

Best regards,
diff mbox series

Patch

diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index 6c94137865c9b568666fb296e20e8669574a9576..493eee39e726abd62df8b8def047434871d15125 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -44,6 +44,8 @@  static DEFINE_IDA(genpd_ida);
 static LIST_HEAD(gpd_list);
 static DEFINE_MUTEX(gpd_list_lock);
 
+static bool genpd_power_off_unused_passed;
+
 struct genpd_lock_ops {
 	void (*lock)(struct generic_pm_domain *genpd);
 	void (*lock_nested)(struct generic_pm_domain *genpd, int depth);
@@ -1023,6 +1025,14 @@  static void genpd_power_off_work_fn(struct work_struct *work)
 
 	genpd = container_of(work, struct generic_pm_domain, power_off_work);
 
+	/*
+	 * If the genpd_power_off_unsused late_initcall did not pass yet
+	 * skip any genpd_power_off call since we are still in boot phase
+	 * where possible pw domain consumers could show up.
+	 */
+	if (!genpd_power_off_unused_passed)
+		return;
+
 	genpd_lock(genpd);
 	genpd_power_off(genpd, false, 0);
 	genpd_unlock(genpd);
@@ -1249,6 +1259,8 @@  static int __init genpd_power_off_unused(void)
 		return 0;
 	}
 
+	genpd_power_off_unused_passed = true;
+
 	pr_info("genpd: Disabling unused power domains\n");
 	mutex_lock(&gpd_list_lock);
 
@@ -3272,6 +3284,8 @@  EXPORT_SYMBOL_GPL(of_genpd_parse_idle_states);
 
 static int __init genpd_bus_init(void)
 {
+	genpd_power_off_unused_passed = false;
+
 	return bus_register(&genpd_bus_type);
 }
 core_initcall(genpd_bus_init);