linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains
@ 2025-09-09 11:11 Ulf Hansson
  2025-09-09 11:11 ` [PATCH 1/5] pmdomain: core: " Ulf Hansson
                   ` (6 more replies)
  0 siblings, 7 replies; 22+ messages in thread
From: Ulf Hansson @ 2025-09-09 11:11 UTC (permalink / raw)
  To: Geert Uytterhoeven, Nicolas Frattaroli, Saravana Kannan, linux-pm
  Cc: Stephen Boyd, Rafael J . Wysocki, Heiko Stuebner,
	Sebastian Reichel, Sebin Francis, Diederik de Haas,
	Bjorn Andersson, Abel Vesa, Peng Fan, Tomi Valkeinen,
	Johan Hovold, Maulik Shah, Michal Simek, Konrad Dybcio,
	Thierry Reding, Jonathan Hunter, Ulf Hansson, linux-arm-kernel,
	linux-kernel

Recent changes to genpd prevents those PM domains being powered-on during
initialization from being powered-off during the boot sequence. Based upon
whether CONFIG_PM_CONFIG_PM_GENERIC_DOMAINS_OF is set of not, genpd relies
on the sync_state mechanism or the genpd_power_off_unused() (which is a
late_initcall_sync), to understand when it's okay to allow these PM domains
to be powered-off.

This new behaviour in genpd has lead to problems on different platforms [1].

In this series, I am therefore suggesting to restore the behavior of
genpd_power_off_unused() along with introducing a new genpd config flag,
GENPD_FLAG_NO_STAY_ON, to allow genpd OF providers to opt-out from the new
behaviour.

Kind regards
Ulf Hansson

[1]
https://lore.kernel.org/all/20250701114733.636510-1-ulf.hansson@linaro.org/
https://lore.kernel.org/all/20250902-rk3576-lockup-regression-v1-1-c4a0c9daeb00@collabora.com/

Ulf Hansson (5):
  pmdomain: core: Restore behaviour for disabling unused PM domains
  pmdomain: rockchip: Fix regulator dependency with
    GENPD_FLAG_NO_STAY_ON
  pmdomain: renesas: rcar-sysc: Don't keep unused PM domains powered-on
  pmdomain: renesas: rcar-gen4-sysc: Don't keep unused PM domains
    powered-on
  pmdomain: renesas: rmobile-sysc: Don't keep unused PM domains
    powered-on

 drivers/pmdomain/core.c                   | 20 ++++++++++++++------
 drivers/pmdomain/renesas/rcar-gen4-sysc.c |  1 +
 drivers/pmdomain/renesas/rcar-sysc.c      |  1 +
 drivers/pmdomain/renesas/rmobile-sysc.c   |  3 ++-
 drivers/pmdomain/rockchip/pm-domains.c    |  2 +-
 include/linux/pm_domain.h                 |  7 +++++++
 6 files changed, 26 insertions(+), 8 deletions(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 1/5] pmdomain: core: Restore behaviour for disabling unused PM domains
  2025-09-09 11:11 [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains Ulf Hansson
@ 2025-09-09 11:11 ` Ulf Hansson
  2025-09-09 12:50   ` Heiko Stübner
  2025-09-11  7:56   ` Geert Uytterhoeven
  2025-09-09 11:11 ` [PATCH 2/5] pmdomain: rockchip: Fix regulator dependency with GENPD_FLAG_NO_STAY_ON Ulf Hansson
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 22+ messages in thread
From: Ulf Hansson @ 2025-09-09 11:11 UTC (permalink / raw)
  To: Geert Uytterhoeven, Nicolas Frattaroli, Saravana Kannan, linux-pm
  Cc: Stephen Boyd, Rafael J . Wysocki, Heiko Stuebner,
	Sebastian Reichel, Sebin Francis, Diederik de Haas,
	Bjorn Andersson, Abel Vesa, Peng Fan, Tomi Valkeinen,
	Johan Hovold, Maulik Shah, Michal Simek, Konrad Dybcio,
	Thierry Reding, Jonathan Hunter, Ulf Hansson, linux-arm-kernel,
	linux-kernel

Recent changes to genpd prevents those PM domains being powered-on during
initialization from being powered-off during the boot sequence. Based upon
whether CONFIG_PM_CONFIG_PM_GENERIC_DOMAINS_OF is set of not, genpd relies
on the sync_state mechanism or the genpd_power_off_unused() (which is a
late_initcall_sync), to understand when it's okay to allow these PM domains
to be powered-off.

This new behaviour in genpd has lead to problems on different platforms.
Let's therefore restore the behavior of genpd_power_off_unused().
Moreover, let's introduce GENPD_FLAG_NO_STAY_ON, to allow genpd OF
providers to opt-out from the new behaviour.

Link: https://lore.kernel.org/all/20250701114733.636510-1-ulf.hansson@linaro.org/
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Link: https://lore.kernel.org/all/20250902-rk3576-lockup-regression-v1-1-c4a0c9daeb00@collabora.com/
Reported-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Fixes: 0e789b491ba0 ("pmdomain: core: Leave powered-on genpds on until sync_state")
Fixes: 13a4b7fb6260 ("pmdomain: core: Leave powered-on genpds on until late_initcall_sync")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/pmdomain/core.c   | 20 ++++++++++++++------
 include/linux/pm_domain.h |  7 +++++++
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index 0006ab3d0789..61c2277c9ce3 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -187,6 +187,7 @@ static const struct genpd_lock_ops genpd_raw_spin_ops = {
 #define genpd_is_opp_table_fw(genpd)	(genpd->flags & GENPD_FLAG_OPP_TABLE_FW)
 #define genpd_is_dev_name_fw(genpd)	(genpd->flags & GENPD_FLAG_DEV_NAME_FW)
 #define genpd_is_no_sync_state(genpd)	(genpd->flags & GENPD_FLAG_NO_SYNC_STATE)
+#define genpd_is_no_stay_on(genpd)	(genpd->flags & GENPD_FLAG_NO_STAY_ON)
 
 static inline bool irq_safe_dev_in_sleep_domain(struct device *dev,
 		const struct generic_pm_domain *genpd)
@@ -1357,7 +1358,6 @@ static int genpd_runtime_resume(struct device *dev)
 	return ret;
 }
 
-#ifndef CONFIG_PM_GENERIC_DOMAINS_OF
 static bool pd_ignore_unused;
 static int __init pd_ignore_unused_setup(char *__unused)
 {
@@ -1382,9 +1382,6 @@ static int __init genpd_power_off_unused(void)
 	mutex_lock(&gpd_list_lock);
 
 	list_for_each_entry(genpd, &gpd_list, gpd_list_node) {
-		genpd_lock(genpd);
-		genpd->stay_on = false;
-		genpd_unlock(genpd);
 		genpd_queue_power_off_work(genpd);
 	}
 
@@ -1393,7 +1390,6 @@ static int __init genpd_power_off_unused(void)
 	return 0;
 }
 late_initcall_sync(genpd_power_off_unused);
-#endif
 
 #ifdef CONFIG_PM_SLEEP
 
@@ -2367,6 +2363,18 @@ static void genpd_lock_init(struct generic_pm_domain *genpd)
 	}
 }
 
+#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
+static void genpd_set_stay_on(struct generic_pm_domain *genpd, bool is_off)
+{
+	genpd->stay_on = !genpd_is_no_stay_on(genpd) && !is_off;
+}
+#else
+static void genpd_set_stay_on(struct generic_pm_domain *genpd, bool is_off)
+{
+	genpd->stay_on = false;
+}
+#endif
+
 /**
  * pm_genpd_init - Initialize a generic I/O PM domain object.
  * @genpd: PM domain object to initialize.
@@ -2392,7 +2400,7 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
 	INIT_WORK(&genpd->power_off_work, genpd_power_off_work_fn);
 	atomic_set(&genpd->sd_count, 0);
 	genpd->status = is_off ? GENPD_STATE_OFF : GENPD_STATE_ON;
-	genpd->stay_on = !is_off;
+	genpd_set_stay_on(genpd, is_off);
 	genpd->sync_state = GENPD_SYNC_STATE_OFF;
 	genpd->device_count = 0;
 	genpd->provider = NULL;
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index c84edf217819..f67a2cb7d781 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -115,6 +115,12 @@ struct dev_pm_domain_list {
  *				genpd provider specific way, likely through a
  *				parent device node. This flag makes genpd to
  *				skip its internal support for this.
+ *
+ * GENPD_FLAG_NO_STAY_ON:	For genpd OF providers a powered-on PM domain at
+ *				initialization is prevented from being
+ *				powered-off until the ->sync_state() callback is
+ *				invoked. This flag informs genpd to allow a
+ *				power-off without waiting for ->sync_state().
  */
 #define GENPD_FLAG_PM_CLK	 (1U << 0)
 #define GENPD_FLAG_IRQ_SAFE	 (1U << 1)
@@ -126,6 +132,7 @@ struct dev_pm_domain_list {
 #define GENPD_FLAG_OPP_TABLE_FW	 (1U << 7)
 #define GENPD_FLAG_DEV_NAME_FW	 (1U << 8)
 #define GENPD_FLAG_NO_SYNC_STATE (1U << 9)
+#define GENPD_FLAG_NO_STAY_ON	 (1U << 10)
 
 enum gpd_status {
 	GENPD_STATE_ON = 0,	/* PM domain is on */
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 2/5] pmdomain: rockchip: Fix regulator dependency with GENPD_FLAG_NO_STAY_ON
  2025-09-09 11:11 [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains Ulf Hansson
  2025-09-09 11:11 ` [PATCH 1/5] pmdomain: core: " Ulf Hansson
@ 2025-09-09 11:11 ` Ulf Hansson
  2025-09-09 12:50   ` Heiko Stübner
  2025-09-09 13:49   ` Nicolas Frattaroli
  2025-09-09 11:11 ` [PATCH 3/5] pmdomain: renesas: rcar-sysc: Don't keep unused PM domains powered-on Ulf Hansson
                   ` (4 subsequent siblings)
  6 siblings, 2 replies; 22+ messages in thread
From: Ulf Hansson @ 2025-09-09 11:11 UTC (permalink / raw)
  To: Geert Uytterhoeven, Nicolas Frattaroli, Saravana Kannan, linux-pm
  Cc: Stephen Boyd, Rafael J . Wysocki, Heiko Stuebner,
	Sebastian Reichel, Sebin Francis, Diederik de Haas,
	Bjorn Andersson, Abel Vesa, Peng Fan, Tomi Valkeinen,
	Johan Hovold, Maulik Shah, Michal Simek, Konrad Dybcio,
	Thierry Reding, Jonathan Hunter, Ulf Hansson, linux-arm-kernel,
	linux-kernel

The deferred regulator retrieval for Rockchip PM domains are causing some
weird dependencies. More precisely, if the power-domain is powered-on from
the HW perspective, its corresponding regulator must not be powered-off via
regulator_init_complete(), which is a late_initcall_sync.

Even on platforms that don't have the domain-supply regulator specified for
the power-domain provider, may suffer from these problems.

More precisely, things just happen to work before, because
genpd_power_off_unused() (also a late_initcall_sync) managed to power-off
the PM domain before regulator_init_complete() powered-off the regulator.

Ideally this fragile dependency must be fixed properly for the Rockchip PM
domains, but until then, let's fallback to the previous behaviour by using
the GENPD_FLAG_NO_STAY_ON flag.

Link: https://lore.kernel.org/all/20250902-rk3576-lockup-regression-v1-1-c4a0c9daeb00@collabora.com/
Reported-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Sebastian Reichel <sebastian.reichel@collabora.com>
Fixes: 0e789b491ba0 ("pmdomain: core: Leave powered-on genpds on until sync_state")
Fixes: 13a4b7fb6260 ("pmdomain: core: Leave powered-on genpds on until late_initcall_sync")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/pmdomain/rockchip/pm-domains.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
index 242570c505fb..1955c6d453e4 100644
--- a/drivers/pmdomain/rockchip/pm-domains.c
+++ b/drivers/pmdomain/rockchip/pm-domains.c
@@ -865,7 +865,7 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu,
 	pd->genpd.power_on = rockchip_pd_power_on;
 	pd->genpd.attach_dev = rockchip_pd_attach_dev;
 	pd->genpd.detach_dev = rockchip_pd_detach_dev;
-	pd->genpd.flags = GENPD_FLAG_PM_CLK;
+	pd->genpd.flags = GENPD_FLAG_PM_CLK | GENPD_FLAG_NO_STAY_ON;
 	if (pd_info->active_wakeup)
 		pd->genpd.flags |= GENPD_FLAG_ACTIVE_WAKEUP;
 	pm_genpd_init(&pd->genpd, NULL,
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 3/5] pmdomain: renesas: rcar-sysc: Don't keep unused PM domains powered-on
  2025-09-09 11:11 [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains Ulf Hansson
  2025-09-09 11:11 ` [PATCH 1/5] pmdomain: core: " Ulf Hansson
  2025-09-09 11:11 ` [PATCH 2/5] pmdomain: rockchip: Fix regulator dependency with GENPD_FLAG_NO_STAY_ON Ulf Hansson
@ 2025-09-09 11:11 ` Ulf Hansson
  2025-09-11  7:56   ` Geert Uytterhoeven
  2025-09-11  9:01   ` Geert Uytterhoeven
  2025-09-09 11:11 ` [PATCH 4/5] pmdomain: renesas: rcar-gen4-sysc: " Ulf Hansson
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 22+ messages in thread
From: Ulf Hansson @ 2025-09-09 11:11 UTC (permalink / raw)
  To: Geert Uytterhoeven, Nicolas Frattaroli, Saravana Kannan, linux-pm
  Cc: Stephen Boyd, Rafael J . Wysocki, Heiko Stuebner,
	Sebastian Reichel, Sebin Francis, Diederik de Haas,
	Bjorn Andersson, Abel Vesa, Peng Fan, Tomi Valkeinen,
	Johan Hovold, Maulik Shah, Michal Simek, Konrad Dybcio,
	Thierry Reding, Jonathan Hunter, Ulf Hansson, linux-arm-kernel,
	linux-kernel

The recent changes to genpd makes a genpd OF provider that is powered-on at
initialization to stay powered-on, until the ->sync_state() callback is
invoked for it.

This may not happen at all, if we wait for a consumer device to be probed,
leading to wasting energy. There are ways to enforce the ->sync_state()
callback to be invoked, through sysfs or via the probe-defer-timeout, but
none of them in its current form are a good fit for rcar-sysc PM domains.

Let's therefore opt-out from this behaviour of genpd for now, by using the
GENPD_FLAG_NO_STAY_ON.

Link: https://lore.kernel.org/all/20250701114733.636510-1-ulf.hansson@linaro.org/
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Fixes: 0e789b491ba0 ("pmdomain: core: Leave powered-on genpds on until sync_state")
Fixes: 13a4b7fb6260 ("pmdomain: core: Leave powered-on genpds on until late_initcall_sync")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/pmdomain/renesas/rcar-sysc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pmdomain/renesas/rcar-sysc.c b/drivers/pmdomain/renesas/rcar-sysc.c
index 2d4161170c63..d8a8ffcde38d 100644
--- a/drivers/pmdomain/renesas/rcar-sysc.c
+++ b/drivers/pmdomain/renesas/rcar-sysc.c
@@ -241,6 +241,7 @@ static int __init rcar_sysc_pd_setup(struct rcar_sysc_pd *pd)
 		}
 	}
 
+	genpd->flags |= GENPD_FLAG_NO_STAY_ON;
 	genpd->power_off = rcar_sysc_pd_power_off;
 	genpd->power_on = rcar_sysc_pd_power_on;
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 4/5] pmdomain: renesas: rcar-gen4-sysc: Don't keep unused PM domains powered-on
  2025-09-09 11:11 [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains Ulf Hansson
                   ` (2 preceding siblings ...)
  2025-09-09 11:11 ` [PATCH 3/5] pmdomain: renesas: rcar-sysc: Don't keep unused PM domains powered-on Ulf Hansson
@ 2025-09-09 11:11 ` Ulf Hansson
  2025-09-11  7:57   ` Geert Uytterhoeven
  2025-09-09 11:11 ` [PATCH 5/5] pmdomain: renesas: rmobile-sysc: " Ulf Hansson
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 22+ messages in thread
From: Ulf Hansson @ 2025-09-09 11:11 UTC (permalink / raw)
  To: Geert Uytterhoeven, Nicolas Frattaroli, Saravana Kannan, linux-pm
  Cc: Stephen Boyd, Rafael J . Wysocki, Heiko Stuebner,
	Sebastian Reichel, Sebin Francis, Diederik de Haas,
	Bjorn Andersson, Abel Vesa, Peng Fan, Tomi Valkeinen,
	Johan Hovold, Maulik Shah, Michal Simek, Konrad Dybcio,
	Thierry Reding, Jonathan Hunter, Ulf Hansson, linux-arm-kernel,
	linux-kernel

The recent changes to genpd makes a genpd OF provider that is powered-on at
initialization to stay powered-on, until the ->sync_state() callback is
invoked for it.

This may not happen at all, if we wait for a consumer device to be probed,
leading to wasting energy. There are ways to enforce the ->sync_state()
callback to be invoked, through sysfs or via the probe-defer-timeout, but
none of them in its current form are a good fit for rcar-gen4-sysc PM
domains.

Let's therefore opt-out from this behaviour of genpd for now, by using the
GENPD_FLAG_NO_STAY_ON.

Link: https://lore.kernel.org/all/20250701114733.636510-1-ulf.hansson@linaro.org/
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Fixes: 0e789b491ba0 ("pmdomain: core: Leave powered-on genpds on until sync_state")
Fixes: 13a4b7fb6260 ("pmdomain: core: Leave powered-on genpds on until late_initcall_sync")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/pmdomain/renesas/rcar-gen4-sysc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pmdomain/renesas/rcar-gen4-sysc.c b/drivers/pmdomain/renesas/rcar-gen4-sysc.c
index 5aa7fa1df8fe..7434bf42d215 100644
--- a/drivers/pmdomain/renesas/rcar-gen4-sysc.c
+++ b/drivers/pmdomain/renesas/rcar-gen4-sysc.c
@@ -251,6 +251,7 @@ static int __init rcar_gen4_sysc_pd_setup(struct rcar_gen4_sysc_pd *pd)
 		genpd->detach_dev = cpg_mssr_detach_dev;
 	}
 
+	genpd->flags |= GENPD_FLAG_NO_STAY_ON;
 	genpd->power_off = rcar_gen4_sysc_pd_power_off;
 	genpd->power_on = rcar_gen4_sysc_pd_power_on;
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 5/5] pmdomain: renesas: rmobile-sysc: Don't keep unused PM domains powered-on
  2025-09-09 11:11 [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains Ulf Hansson
                   ` (3 preceding siblings ...)
  2025-09-09 11:11 ` [PATCH 4/5] pmdomain: renesas: rcar-gen4-sysc: " Ulf Hansson
@ 2025-09-09 11:11 ` Ulf Hansson
  2025-09-11  7:58   ` Geert Uytterhoeven
  2025-09-10 19:33 ` [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains Diederik de Haas
  2025-09-12 18:36 ` Saravana Kannan
  6 siblings, 1 reply; 22+ messages in thread
From: Ulf Hansson @ 2025-09-09 11:11 UTC (permalink / raw)
  To: Geert Uytterhoeven, Nicolas Frattaroli, Saravana Kannan, linux-pm
  Cc: Stephen Boyd, Rafael J . Wysocki, Heiko Stuebner,
	Sebastian Reichel, Sebin Francis, Diederik de Haas,
	Bjorn Andersson, Abel Vesa, Peng Fan, Tomi Valkeinen,
	Johan Hovold, Maulik Shah, Michal Simek, Konrad Dybcio,
	Thierry Reding, Jonathan Hunter, Ulf Hansson, linux-arm-kernel,
	linux-kernel

The recent changes to genpd makes a genpd OF provider that is powered-on at
initialization to stay powered-on, until the ->sync_state() callback is
invoked for it.

This may not happen at all, if we wait for a consumer device to be probed,
leading to wasting energy. There are ways to enforce the ->sync_state()
callback to be invoked, through sysfs or via the probe-defer-timeout, but
none of them in its current form are a good fit for rmobile-sysc PM
domains.

Let's therefore opt-out from this behaviour of genpd for now, by using the
GENPD_FLAG_NO_STAY_ON.

Link: https://lore.kernel.org/all/20250701114733.636510-1-ulf.hansson@linaro.org/
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Fixes: 0e789b491ba0 ("pmdomain: core: Leave powered-on genpds on until sync_state")
Fixes: 13a4b7fb6260 ("pmdomain: core: Leave powered-on genpds on until late_initcall_sync")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/pmdomain/renesas/rmobile-sysc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pmdomain/renesas/rmobile-sysc.c b/drivers/pmdomain/renesas/rmobile-sysc.c
index 8eedc9a1d825..a6bf7295e909 100644
--- a/drivers/pmdomain/renesas/rmobile-sysc.c
+++ b/drivers/pmdomain/renesas/rmobile-sysc.c
@@ -100,7 +100,8 @@ static void rmobile_init_pm_domain(struct rmobile_pm_domain *rmobile_pd)
 	struct generic_pm_domain *genpd = &rmobile_pd->genpd;
 	struct dev_power_governor *gov = rmobile_pd->gov;
 
-	genpd->flags |= GENPD_FLAG_PM_CLK | GENPD_FLAG_ACTIVE_WAKEUP;
+	genpd->flags |= GENPD_FLAG_PM_CLK | GENPD_FLAG_ACTIVE_WAKEUP |
+		GENPD_FLAG_NO_STAY_ON;
 	genpd->attach_dev = cpg_mstp_attach_dev;
 	genpd->detach_dev = cpg_mstp_detach_dev;
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH 1/5] pmdomain: core: Restore behaviour for disabling unused PM domains
  2025-09-09 11:11 ` [PATCH 1/5] pmdomain: core: " Ulf Hansson
@ 2025-09-09 12:50   ` Heiko Stübner
  2025-09-11  7:56   ` Geert Uytterhoeven
  1 sibling, 0 replies; 22+ messages in thread
From: Heiko Stübner @ 2025-09-09 12:50 UTC (permalink / raw)
  To: Geert Uytterhoeven, Nicolas Frattaroli, Saravana Kannan, linux-pm,
	Ulf Hansson
  Cc: Stephen Boyd, Rafael J . Wysocki, Sebastian Reichel,
	Sebin Francis, Diederik de Haas, Bjorn Andersson, Abel Vesa,
	Peng Fan, Tomi Valkeinen, Johan Hovold, Maulik Shah, Michal Simek,
	Konrad Dybcio, Thierry Reding, Jonathan Hunter, Ulf Hansson,
	linux-arm-kernel, linux-kernel

Am Dienstag, 9. September 2025, 13:11:20 Mitteleuropäische Sommerzeit schrieb Ulf Hansson:
> Recent changes to genpd prevents those PM domains being powered-on during
> initialization from being powered-off during the boot sequence. Based upon
> whether CONFIG_PM_CONFIG_PM_GENERIC_DOMAINS_OF is set of not, genpd relies
> on the sync_state mechanism or the genpd_power_off_unused() (which is a
> late_initcall_sync), to understand when it's okay to allow these PM domains
> to be powered-off.
> 
> This new behaviour in genpd has lead to problems on different platforms.
> Let's therefore restore the behavior of genpd_power_off_unused().
> Moreover, let's introduce GENPD_FLAG_NO_STAY_ON, to allow genpd OF
> providers to opt-out from the new behaviour.
> 
> Link: https://lore.kernel.org/all/20250701114733.636510-1-ulf.hansson@linaro.org/
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Link: https://lore.kernel.org/all/20250902-rk3576-lockup-regression-v1-1-c4a0c9daeb00@collabora.com/
> Reported-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> Fixes: 0e789b491ba0 ("pmdomain: core: Leave powered-on genpds on until sync_state")
> Fixes: 13a4b7fb6260 ("pmdomain: core: Leave powered-on genpds on until late_initcall_sync")
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

NPU on rk3588 now again correctly gets its supplying regulator and
running said npu does not end up in a kernel panic :-)

Tested-by: Heiko Stuebner <heiko@sntech.de>





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/5] pmdomain: rockchip: Fix regulator dependency with GENPD_FLAG_NO_STAY_ON
  2025-09-09 11:11 ` [PATCH 2/5] pmdomain: rockchip: Fix regulator dependency with GENPD_FLAG_NO_STAY_ON Ulf Hansson
@ 2025-09-09 12:50   ` Heiko Stübner
  2025-09-09 13:49   ` Nicolas Frattaroli
  1 sibling, 0 replies; 22+ messages in thread
From: Heiko Stübner @ 2025-09-09 12:50 UTC (permalink / raw)
  To: Geert Uytterhoeven, Nicolas Frattaroli, Saravana Kannan, linux-pm,
	Ulf Hansson
  Cc: Stephen Boyd, Rafael J . Wysocki, Sebastian Reichel,
	Sebin Francis, Diederik de Haas, Bjorn Andersson, Abel Vesa,
	Peng Fan, Tomi Valkeinen, Johan Hovold, Maulik Shah, Michal Simek,
	Konrad Dybcio, Thierry Reding, Jonathan Hunter, Ulf Hansson,
	linux-arm-kernel, linux-kernel

Am Dienstag, 9. September 2025, 13:11:21 Mitteleuropäische Sommerzeit schrieb Ulf Hansson:
> The deferred regulator retrieval for Rockchip PM domains are causing some
> weird dependencies. More precisely, if the power-domain is powered-on from
> the HW perspective, its corresponding regulator must not be powered-off via
> regulator_init_complete(), which is a late_initcall_sync.
> 
> Even on platforms that don't have the domain-supply regulator specified for
> the power-domain provider, may suffer from these problems.
> 
> More precisely, things just happen to work before, because
> genpd_power_off_unused() (also a late_initcall_sync) managed to power-off
> the PM domain before regulator_init_complete() powered-off the regulator.
> 
> Ideally this fragile dependency must be fixed properly for the Rockchip PM
> domains, but until then, let's fallback to the previous behaviour by using
> the GENPD_FLAG_NO_STAY_ON flag.
> 
> Link: https://lore.kernel.org/all/20250902-rk3576-lockup-regression-v1-1-c4a0c9daeb00@collabora.com/
> Reported-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: Sebastian Reichel <sebastian.reichel@collabora.com>
> Fixes: 0e789b491ba0 ("pmdomain: core: Leave powered-on genpds on until sync_state")
> Fixes: 13a4b7fb6260 ("pmdomain: core: Leave powered-on genpds on until late_initcall_sync")
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

NPU on rk3588 now again correctly gets its supplying regulator and
running said npu does not end up in a kernel panic :-)

Tested-by: Heiko Stuebner <heiko@sntech.de>
Acked-by: Heiko Stuebner <heiko@sntech.de>




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/5] pmdomain: rockchip: Fix regulator dependency with GENPD_FLAG_NO_STAY_ON
  2025-09-09 11:11 ` [PATCH 2/5] pmdomain: rockchip: Fix regulator dependency with GENPD_FLAG_NO_STAY_ON Ulf Hansson
  2025-09-09 12:50   ` Heiko Stübner
@ 2025-09-09 13:49   ` Nicolas Frattaroli
  1 sibling, 0 replies; 22+ messages in thread
From: Nicolas Frattaroli @ 2025-09-09 13:49 UTC (permalink / raw)
  To: Geert Uytterhoeven, Saravana Kannan, linux-pm, Ulf Hansson
  Cc: Stephen Boyd, Rafael J . Wysocki, Heiko Stuebner,
	Sebastian Reichel, Sebin Francis, Diederik de Haas,
	Bjorn Andersson, Abel Vesa, Peng Fan, Tomi Valkeinen,
	Johan Hovold, Maulik Shah, Michal Simek, Konrad Dybcio,
	Thierry Reding, Jonathan Hunter, Ulf Hansson, linux-arm-kernel,
	linux-kernel

On Tuesday, 9 September 2025 13:11:21 Central European Summer Time Ulf Hansson wrote:
> The deferred regulator retrieval for Rockchip PM domains are causing some
> weird dependencies. More precisely, if the power-domain is powered-on from
> the HW perspective, its corresponding regulator must not be powered-off via
> regulator_init_complete(), which is a late_initcall_sync.
> 
> Even on platforms that don't have the domain-supply regulator specified for
> the power-domain provider, may suffer from these problems.
> 
> More precisely, things just happen to work before, because
> genpd_power_off_unused() (also a late_initcall_sync) managed to power-off
> the PM domain before regulator_init_complete() powered-off the regulator.
> 
> Ideally this fragile dependency must be fixed properly for the Rockchip PM
> domains, but until then, let's fallback to the previous behaviour by using
> the GENPD_FLAG_NO_STAY_ON flag.
> 
> Link: https://lore.kernel.org/all/20250902-rk3576-lockup-regression-v1-1-c4a0c9daeb00@collabora.com/
> Reported-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: Sebastian Reichel <sebastian.reichel@collabora.com>
> Fixes: 0e789b491ba0 ("pmdomain: core: Leave powered-on genpds on until sync_state")
> Fixes: 13a4b7fb6260 ("pmdomain: core: Leave powered-on genpds on until late_initcall_sync")
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
>  drivers/pmdomain/rockchip/pm-domains.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
> index 242570c505fb..1955c6d453e4 100644
> --- a/drivers/pmdomain/rockchip/pm-domains.c
> +++ b/drivers/pmdomain/rockchip/pm-domains.c
> @@ -865,7 +865,7 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu,
>  	pd->genpd.power_on = rockchip_pd_power_on;
>  	pd->genpd.attach_dev = rockchip_pd_attach_dev;
>  	pd->genpd.detach_dev = rockchip_pd_detach_dev;
> -	pd->genpd.flags = GENPD_FLAG_PM_CLK;
> +	pd->genpd.flags = GENPD_FLAG_PM_CLK | GENPD_FLAG_NO_STAY_ON;
>  	if (pd_info->active_wakeup)
>  		pd->genpd.flags |= GENPD_FLAG_ACTIVE_WAKEUP;
>  	pm_genpd_init(&pd->genpd, NULL,
> 

Tested-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>

Fixes the full-SoC lockup I've observed on my RK3576 Radxa ROCK 4D,
which before this patch would occur when the vdd_npu_s0 regulator
was disabled.

Thank you!

Kind regards,
Nicolas Frattaroli





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains
  2025-09-09 11:11 [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains Ulf Hansson
                   ` (4 preceding siblings ...)
  2025-09-09 11:11 ` [PATCH 5/5] pmdomain: renesas: rmobile-sysc: " Ulf Hansson
@ 2025-09-10 19:33 ` Diederik de Haas
  2025-09-11  7:18   ` Geert Uytterhoeven
  2025-09-12 18:36 ` Saravana Kannan
  6 siblings, 1 reply; 22+ messages in thread
From: Diederik de Haas @ 2025-09-10 19:33 UTC (permalink / raw)
  To: Ulf Hansson, Geert Uytterhoeven, Nicolas Frattaroli,
	Saravana Kannan, linux-pm
  Cc: Stephen Boyd, Rafael J . Wysocki, Heiko Stuebner,
	Sebastian Reichel, Sebin Francis, Bjorn Andersson, Abel Vesa,
	Peng Fan, Tomi Valkeinen, Johan Hovold, Maulik Shah, Michal Simek,
	Konrad Dybcio, Thierry Reding, Jonathan Hunter, linux-arm-kernel,
	linux-kernel, linux-rockchip, Christian Hewitt

[-- Attachment #1: Type: text/plain, Size: 3038 bytes --]

Hi,

On Tue Sep 9, 2025 at 1:11 PM CEST, Ulf Hansson wrote:
> Recent changes to genpd prevents those PM domains being powered-on during
> initialization from being powered-off during the boot sequence. Based upon
> whether CONFIG_PM_CONFIG_PM_GENERIC_DOMAINS_OF is set of not, genpd relies
> on the sync_state mechanism or the genpd_power_off_unused() (which is a
> late_initcall_sync), to understand when it's okay to allow these PM domains
> to be powered-off.
>
> This new behaviour in genpd has lead to problems on different platforms [1].
>
> In this series, I am therefore suggesting to restore the behavior of
> genpd_power_off_unused() along with introducing a new genpd config flag,
> GENPD_FLAG_NO_STAY_ON, to allow genpd OF providers to opt-out from the new
> behaviour.

Is it expected that I'm still seeing this on a Rock64 (rk3328), just
like before [1]?

  [   17.124202] rockchip-pm-domain ff100000.syscon:power-controller: sync_state() pending due to ff300000.gpu
  [   17.129799] rockchip-pm-domain ff100000.syscon:power-controller: sync_state() pending due to ff350000.video-codec
  [   17.140003] rockchip-pm-domain ff100000.syscon:power-controller: sync_state() pending due to ff360000.video-codec

This is with a 6.17-rc5 kernel with this patch set applied.
And it also has this patch from Christian Hewitt added, now in v3:
https://lore.kernel.org/linux-rockchip/20250906120810.1833016-1-christianshewitt@gmail.com/

When I boot into a 6.17-rc5 kernel without any patches applied, I do get
the 2 for ff350000.video-codec and ff360000.video-codec, but not the 
ff300000.gpu one.

Interestingly:
ff300000.gpu -> power-domains = <&power RK3328_PD_GPU>;
ff350000.video-codec -> power-domains = <&power RK3328_PD_VPU>;
ff360000.video-codec -> power-domains = <&power RK3328_PD_VIDEO>;

I would be surprised if that was a coincidence.

Cheers,
  Diederik

[1] https://lore.kernel.org/all/DCK0O99SYSCF.BMBAEUV24C1G@cknow.org/

>
> Kind regards
> Ulf Hansson
>
> [1]
> https://lore.kernel.org/all/20250701114733.636510-1-ulf.hansson@linaro.org/
> https://lore.kernel.org/all/20250902-rk3576-lockup-regression-v1-1-c4a0c9daeb00@collabora.com/
>
> Ulf Hansson (5):
>   pmdomain: core: Restore behaviour for disabling unused PM domains
>   pmdomain: rockchip: Fix regulator dependency with
>     GENPD_FLAG_NO_STAY_ON
>   pmdomain: renesas: rcar-sysc: Don't keep unused PM domains powered-on
>   pmdomain: renesas: rcar-gen4-sysc: Don't keep unused PM domains
>     powered-on
>   pmdomain: renesas: rmobile-sysc: Don't keep unused PM domains
>     powered-on
>
>  drivers/pmdomain/core.c                   | 20 ++++++++++++++------
>  drivers/pmdomain/renesas/rcar-gen4-sysc.c |  1 +
>  drivers/pmdomain/renesas/rcar-sysc.c      |  1 +
>  drivers/pmdomain/renesas/rmobile-sysc.c   |  3 ++-
>  drivers/pmdomain/rockchip/pm-domains.c    |  2 +-
>  include/linux/pm_domain.h                 |  7 +++++++
>  6 files changed, 26 insertions(+), 8 deletions(-)


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains
  2025-09-10 19:33 ` [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains Diederik de Haas
@ 2025-09-11  7:18   ` Geert Uytterhoeven
  2025-09-11  8:26     ` Diederik de Haas
  0 siblings, 1 reply; 22+ messages in thread
From: Geert Uytterhoeven @ 2025-09-11  7:18 UTC (permalink / raw)
  To: Diederik de Haas
  Cc: Ulf Hansson, Nicolas Frattaroli, Saravana Kannan, linux-pm,
	Stephen Boyd, Rafael J . Wysocki, Heiko Stuebner,
	Sebastian Reichel, Sebin Francis, Bjorn Andersson, Abel Vesa,
	Peng Fan, Tomi Valkeinen, Johan Hovold, Maulik Shah, Michal Simek,
	Konrad Dybcio, Thierry Reding, Jonathan Hunter, linux-arm-kernel,
	linux-kernel, linux-rockchip, Christian Hewitt

Hi Diederik,

On Wed, 10 Sept 2025 at 21:33, Diederik de Haas <didi.debian@cknow.org> wrote:
> On Tue Sep 9, 2025 at 1:11 PM CEST, Ulf Hansson wrote:
> > Recent changes to genpd prevents those PM domains being powered-on during
> > initialization from being powered-off during the boot sequence. Based upon
> > whether CONFIG_PM_CONFIG_PM_GENERIC_DOMAINS_OF is set of not, genpd relies
> > on the sync_state mechanism or the genpd_power_off_unused() (which is a
> > late_initcall_sync), to understand when it's okay to allow these PM domains
> > to be powered-off.
> >
> > This new behaviour in genpd has lead to problems on different platforms [1].
> >
> > In this series, I am therefore suggesting to restore the behavior of
> > genpd_power_off_unused() along with introducing a new genpd config flag,
> > GENPD_FLAG_NO_STAY_ON, to allow genpd OF providers to opt-out from the new
> > behaviour.
>
> Is it expected that I'm still seeing this on a Rock64 (rk3328), just
> like before [1]?
>
>   [   17.124202] rockchip-pm-domain ff100000.syscon:power-controller: sync_state() pending due to ff300000.gpu
>   [   17.129799] rockchip-pm-domain ff100000.syscon:power-controller: sync_state() pending due to ff350000.video-codec
>   [   17.140003] rockchip-pm-domain ff100000.syscon:power-controller: sync_state() pending due to ff360000.video-codec

Yes, as the sync state is still blocked on them.
Disabling unused PM Domains is done independently of sync state.

> This is with a 6.17-rc5 kernel with this patch set applied.
> And it also has this patch from Christian Hewitt added, now in v3:
> https://lore.kernel.org/linux-rockchip/20250906120810.1833016-1-christianshewitt@gmail.com/
>
> When I boot into a 6.17-rc5 kernel without any patches applied, I do get
> the 2 for ff350000.video-codec and ff360000.video-codec, but not the
> ff300000.gpu one.
>
> Interestingly:
> ff300000.gpu -> power-domains = <&power RK3328_PD_GPU>;
> ff350000.video-codec -> power-domains = <&power RK3328_PD_VPU>;
> ff360000.video-codec -> power-domains = <&power RK3328_PD_VIDEO>;
>
> I would be surprised if that was a coincidence.

Fw_devlinks ignores the index cell (RK3328_PD_*), hence all links are
created pointing to the pmdomain controller (in case it has a platform
driver) or the first pmdomain (in case it has not). thus blocking the
sync state call and power-down for _all_ pmdomains managed by the
controller.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 1/5] pmdomain: core: Restore behaviour for disabling unused PM domains
  2025-09-09 11:11 ` [PATCH 1/5] pmdomain: core: " Ulf Hansson
  2025-09-09 12:50   ` Heiko Stübner
@ 2025-09-11  7:56   ` Geert Uytterhoeven
  2025-09-11 10:25     ` Ulf Hansson
  1 sibling, 1 reply; 22+ messages in thread
From: Geert Uytterhoeven @ 2025-09-11  7:56 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Nicolas Frattaroli, Saravana Kannan, linux-pm, Stephen Boyd,
	Rafael J . Wysocki, Heiko Stuebner, Sebastian Reichel,
	Sebin Francis, Diederik de Haas, Bjorn Andersson, Abel Vesa,
	Peng Fan, Tomi Valkeinen, Johan Hovold, Maulik Shah, Michal Simek,
	Konrad Dybcio, Thierry Reding, Jonathan Hunter, linux-arm-kernel,
	linux-kernel

Hi Ulf,

On Tue, 9 Sept 2025 at 13:11, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> Recent changes to genpd prevents those PM domains being powered-on during
> initialization from being powered-off during the boot sequence. Based upon
> whether CONFIG_PM_CONFIG_PM_GENERIC_DOMAINS_OF is set of not, genpd relies
> on the sync_state mechanism or the genpd_power_off_unused() (which is a
> late_initcall_sync), to understand when it's okay to allow these PM domains
> to be powered-off.
>
> This new behaviour in genpd has lead to problems on different platforms.
> Let's therefore restore the behavior of genpd_power_off_unused().
> Moreover, let's introduce GENPD_FLAG_NO_STAY_ON, to allow genpd OF
> providers to opt-out from the new behaviour.
>
> Link: https://lore.kernel.org/all/20250701114733.636510-1-ulf.hansson@linaro.org/
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Link: https://lore.kernel.org/all/20250902-rk3576-lockup-regression-v1-1-c4a0c9daeb00@collabora.com/
> Reported-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> Fixes: 0e789b491ba0 ("pmdomain: core: Leave powered-on genpds on until sync_state")
> Fixes: 13a4b7fb6260 ("pmdomain: core: Leave powered-on genpds on until late_initcall_sync")
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Thanks for your patch!

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>

> --- a/include/linux/pm_domain.h
> +++ b/include/linux/pm_domain.h
> @@ -115,6 +115,12 @@ struct dev_pm_domain_list {
>   *                             genpd provider specific way, likely through a
>   *                             parent device node. This flag makes genpd to
>   *                             skip its internal support for this.
> + *
> + * GENPD_FLAG_NO_STAY_ON:      For genpd OF providers a powered-on PM domain at
> + *                             initialization is prevented from being
> + *                             powered-off until the ->sync_state() callback is
> + *                             invoked. This flag informs genpd to allow a
> + *                             power-off without waiting for ->sync_state().

This also restores power-down of pmdomains after a failed device
probe (due to a real issue, or just -EPROBE_DEFER), possibly
interfering with other devices that are part of the same pmdomain(s)
but haven't been probed yet. E.g. what if your serial console is
part of the same pmdomain?  Probably the pmdomain(s) should not
be powered down immediately, but only later, when either sync state
or genpd_power_off_unused() kicks in.

But this is a pre-existing issue, so not a blocked for this patch.

>   */
>  #define GENPD_FLAG_PM_CLK       (1U << 0)
>  #define GENPD_FLAG_IRQ_SAFE     (1U << 1)

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 3/5] pmdomain: renesas: rcar-sysc: Don't keep unused PM domains powered-on
  2025-09-09 11:11 ` [PATCH 3/5] pmdomain: renesas: rcar-sysc: Don't keep unused PM domains powered-on Ulf Hansson
@ 2025-09-11  7:56   ` Geert Uytterhoeven
  2025-09-11  9:01   ` Geert Uytterhoeven
  1 sibling, 0 replies; 22+ messages in thread
From: Geert Uytterhoeven @ 2025-09-11  7:56 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Nicolas Frattaroli, Saravana Kannan, linux-pm, Stephen Boyd,
	Rafael J . Wysocki, Heiko Stuebner, Sebastian Reichel,
	Sebin Francis, Diederik de Haas, Bjorn Andersson, Abel Vesa,
	Peng Fan, Tomi Valkeinen, Johan Hovold, Maulik Shah, Michal Simek,
	Konrad Dybcio, Thierry Reding, Jonathan Hunter, linux-arm-kernel,
	linux-kernel

On Tue, 9 Sept 2025 at 13:11, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> The recent changes to genpd makes a genpd OF provider that is powered-on at
> initialization to stay powered-on, until the ->sync_state() callback is
> invoked for it.
>
> This may not happen at all, if we wait for a consumer device to be probed,
> leading to wasting energy. There are ways to enforce the ->sync_state()
> callback to be invoked, through sysfs or via the probe-defer-timeout, but
> none of them in its current form are a good fit for rcar-sysc PM domains.
>
> Let's therefore opt-out from this behaviour of genpd for now, by using the
> GENPD_FLAG_NO_STAY_ON.
>
> Link: https://lore.kernel.org/all/20250701114733.636510-1-ulf.hansson@linaro.org/
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Fixes: 0e789b491ba0 ("pmdomain: core: Leave powered-on genpds on until sync_state")
> Fixes: 13a4b7fb6260 ("pmdomain: core: Leave powered-on genpds on until late_initcall_sync")
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
>  drivers/pmdomain/renesas/rcar-sysc.c | 1 +

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
on R-Car M2-W (koelsch) and R-Car H3 ES2.0 (salvator-xs).

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 4/5] pmdomain: renesas: rcar-gen4-sysc: Don't keep unused PM domains powered-on
  2025-09-09 11:11 ` [PATCH 4/5] pmdomain: renesas: rcar-gen4-sysc: " Ulf Hansson
@ 2025-09-11  7:57   ` Geert Uytterhoeven
  0 siblings, 0 replies; 22+ messages in thread
From: Geert Uytterhoeven @ 2025-09-11  7:57 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Nicolas Frattaroli, Saravana Kannan, linux-pm, Stephen Boyd,
	Rafael J . Wysocki, Heiko Stuebner, Sebastian Reichel,
	Sebin Francis, Diederik de Haas, Bjorn Andersson, Abel Vesa,
	Peng Fan, Tomi Valkeinen, Johan Hovold, Maulik Shah, Michal Simek,
	Konrad Dybcio, Thierry Reding, Jonathan Hunter, linux-arm-kernel,
	linux-kernel

On Tue, 9 Sept 2025 at 13:11, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> The recent changes to genpd makes a genpd OF provider that is powered-on at
> initialization to stay powered-on, until the ->sync_state() callback is
> invoked for it.
>
> This may not happen at all, if we wait for a consumer device to be probed,
> leading to wasting energy. There are ways to enforce the ->sync_state()
> callback to be invoked, through sysfs or via the probe-defer-timeout, but
> none of them in its current form are a good fit for rcar-gen4-sysc PM
> domains.
>
> Let's therefore opt-out from this behaviour of genpd for now, by using the
> GENPD_FLAG_NO_STAY_ON.
>
> Link: https://lore.kernel.org/all/20250701114733.636510-1-ulf.hansson@linaro.org/
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Fixes: 0e789b491ba0 ("pmdomain: core: Leave powered-on genpds on until sync_state")
> Fixes: 13a4b7fb6260 ("pmdomain: core: Leave powered-on genpds on until late_initcall_sync")
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
on R-Car V4M (gray hawk single).

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 5/5] pmdomain: renesas: rmobile-sysc: Don't keep unused PM domains powered-on
  2025-09-09 11:11 ` [PATCH 5/5] pmdomain: renesas: rmobile-sysc: " Ulf Hansson
@ 2025-09-11  7:58   ` Geert Uytterhoeven
  0 siblings, 0 replies; 22+ messages in thread
From: Geert Uytterhoeven @ 2025-09-11  7:58 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Nicolas Frattaroli, Saravana Kannan, linux-pm, Stephen Boyd,
	Rafael J . Wysocki, Heiko Stuebner, Sebastian Reichel,
	Sebin Francis, Diederik de Haas, Bjorn Andersson, Abel Vesa,
	Peng Fan, Tomi Valkeinen, Johan Hovold, Maulik Shah, Michal Simek,
	Konrad Dybcio, Thierry Reding, Jonathan Hunter, linux-arm-kernel,
	linux-kernel

On Tue, 9 Sept 2025 at 13:11, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> The recent changes to genpd makes a genpd OF provider that is powered-on at
> initialization to stay powered-on, until the ->sync_state() callback is
> invoked for it.
>
> This may not happen at all, if we wait for a consumer device to be probed,
> leading to wasting energy. There are ways to enforce the ->sync_state()
> callback to be invoked, through sysfs or via the probe-defer-timeout, but
> none of them in its current form are a good fit for rmobile-sysc PM
> domains.
>
> Let's therefore opt-out from this behaviour of genpd for now, by using the
> GENPD_FLAG_NO_STAY_ON.
>
> Link: https://lore.kernel.org/all/20250701114733.636510-1-ulf.hansson@linaro.org/
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Fixes: 0e789b491ba0 ("pmdomain: core: Leave powered-on genpds on until sync_state")
> Fixes: 13a4b7fb6260 ("pmdomain: core: Leave powered-on genpds on until late_initcall_sync")
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
On SH-Mobile AG5 (kzm9g) and R-Mobile A1 (armadillo).

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains
  2025-09-11  7:18   ` Geert Uytterhoeven
@ 2025-09-11  8:26     ` Diederik de Haas
  2025-09-12 18:32       ` Saravana Kannan
  0 siblings, 1 reply; 22+ messages in thread
From: Diederik de Haas @ 2025-09-11  8:26 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Ulf Hansson, Heiko Stuebner, Rafael J . Wysocki, Tomi Valkeinen,
	Thierry Reding, Saravana Kannan, Sebastian Reichel,
	Jonathan Hunter, linux-rockchip, Konrad Dybcio, Peng Fan,
	linux-pm, Johan Hovold, Sebin Francis, Michal Simek,
	linux-arm-kernel, Maulik Shah, Stephen Boyd, Bjorn Andersson,
	Christian Hewitt, linux-kernel, Abel Vesa, Nicolas Frattaroli

[-- Attachment #1: Type: text/plain, Size: 3167 bytes --]

Hi Geert,

On Thu Sep 11, 2025 at 9:18 AM CEST, Geert Uytterhoeven wrote:
> On Wed, 10 Sept 2025 at 21:33, Diederik de Haas <didi.debian@cknow.org> wrote:
>> On Tue Sep 9, 2025 at 1:11 PM CEST, Ulf Hansson wrote:
>> > Recent changes to genpd prevents those PM domains being powered-on during
>> > initialization from being powered-off during the boot sequence. Based upon
>> > whether CONFIG_PM_CONFIG_PM_GENERIC_DOMAINS_OF is set of not, genpd relies
>> > on the sync_state mechanism or the genpd_power_off_unused() (which is a
>> > late_initcall_sync), to understand when it's okay to allow these PM domains
>> > to be powered-off.
>> >
>> > This new behaviour in genpd has lead to problems on different platforms [1].
>> >
>> > In this series, I am therefore suggesting to restore the behavior of
>> > genpd_power_off_unused() along with introducing a new genpd config flag,
>> > GENPD_FLAG_NO_STAY_ON, to allow genpd OF providers to opt-out from the new
>> > behaviour.
>>
>> Is it expected that I'm still seeing this on a Rock64 (rk3328), just
>> like before [1]?
>>
>>   [   17.124202] rockchip-pm-domain ff100000.syscon:power-controller: sync_state() pending due to ff300000.gpu
>>   [   17.129799] rockchip-pm-domain ff100000.syscon:power-controller: sync_state() pending due to ff350000.video-codec
>>   [   17.140003] rockchip-pm-domain ff100000.syscon:power-controller: sync_state() pending due to ff360000.video-codec
>
> Yes, as the sync state is still blocked on them.
> Disabling unused PM Domains is done independently of sync state.
>
>> This is with a 6.17-rc5 kernel with this patch set applied.
>> And it also has this patch from Christian Hewitt added, now in v3:
>> https://lore.kernel.org/linux-rockchip/20250906120810.1833016-1-christianshewitt@gmail.com/
>>
>> When I boot into a 6.17-rc5 kernel without any patches applied, I do get
>> the 2 for ff350000.video-codec and ff360000.video-codec, but not the
>> ff300000.gpu one.
>>
>> Interestingly:
>> ff300000.gpu -> power-domains = <&power RK3328_PD_GPU>;
>> ff350000.video-codec -> power-domains = <&power RK3328_PD_VPU>;
>> ff360000.video-codec -> power-domains = <&power RK3328_PD_VIDEO>;
>>
>> I would be surprised if that was a coincidence.
>
> Fw_devlinks ignores the index cell (RK3328_PD_*), hence all links are
> created pointing to the pmdomain controller (in case it has a platform
> driver) or the first pmdomain (in case it has not). thus blocking the
> sync state call and power-down for _all_ pmdomains managed by the
> controller.

I don't think I fully understand this (not your problem due to lack of
knowledge on my part), but you mentioning 'fw_devlink' rang a bell.

Some time ago Nicolas Frattaroli and I worked on an image for PINE64's
*Quartz* devices and that added ``fw_devlink=off`` to cmdline.
I've been using it on all my Rockchip based devices, without
understanding that parameter ... but (apparently) on my 'rock64-test'
device, where I tested it with, I had removed that parameter.
Putting that parameter back ... and those warnings are gone!

Thanks a LOT for that hint!

Groetjes,
  Diederik

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 3/5] pmdomain: renesas: rcar-sysc: Don't keep unused PM domains powered-on
  2025-09-09 11:11 ` [PATCH 3/5] pmdomain: renesas: rcar-sysc: Don't keep unused PM domains powered-on Ulf Hansson
  2025-09-11  7:56   ` Geert Uytterhoeven
@ 2025-09-11  9:01   ` Geert Uytterhoeven
  2025-09-11 10:31     ` Ulf Hansson
  1 sibling, 1 reply; 22+ messages in thread
From: Geert Uytterhoeven @ 2025-09-11  9:01 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Nicolas Frattaroli, Saravana Kannan, linux-pm, Stephen Boyd,
	Rafael J . Wysocki, Heiko Stuebner, Sebastian Reichel,
	Sebin Francis, Diederik de Haas, Bjorn Andersson, Abel Vesa,
	Peng Fan, Tomi Valkeinen, Johan Hovold, Maulik Shah, Michal Simek,
	Konrad Dybcio, Thierry Reding, Jonathan Hunter, linux-arm-kernel,
	linux-kernel

Hi Ulf,

On Tue, 9 Sept 2025 at 13:11, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> The recent changes to genpd makes a genpd OF provider that is powered-on at
> initialization to stay powered-on, until the ->sync_state() callback is
> invoked for it.
>
> This may not happen at all, if we wait for a consumer device to be probed,
> leading to wasting energy. There are ways to enforce the ->sync_state()
> callback to be invoked, through sysfs or via the probe-defer-timeout, but
> none of them in its current form are a good fit for rcar-sysc PM domains.
>
> Let's therefore opt-out from this behaviour of genpd for now, by using the
> GENPD_FLAG_NO_STAY_ON.
>
> Link: https://lore.kernel.org/all/20250701114733.636510-1-ulf.hansson@linaro.org/
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Fixes: 0e789b491ba0 ("pmdomain: core: Leave powered-on genpds on until sync_state")
> Fixes: 13a4b7fb6260 ("pmdomain: core: Leave powered-on genpds on until late_initcall_sync")
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

> --- a/drivers/pmdomain/renesas/rcar-sysc.c
> +++ b/drivers/pmdomain/renesas/rcar-sysc.c
> @@ -241,6 +241,7 @@ static int __init rcar_sysc_pd_setup(struct rcar_sysc_pd *pd)
>                 }
>         }
>
> +       genpd->flags |= GENPD_FLAG_NO_STAY_ON;

So this applies to all PM Domains.  While this doesn't hurt, perhaps it
should not be set for always-on domains, and thus moved up, to become
an "else" branch in the "if/else if/..."-logic handling always-on
domains at the top of the function?

This applies to rar-gen4-sysc.c, too.

>         genpd->power_off = rcar_sysc_pd_power_off;
>         genpd->power_on = rcar_sysc_pd_power_on;
>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 1/5] pmdomain: core: Restore behaviour for disabling unused PM domains
  2025-09-11  7:56   ` Geert Uytterhoeven
@ 2025-09-11 10:25     ` Ulf Hansson
  0 siblings, 0 replies; 22+ messages in thread
From: Ulf Hansson @ 2025-09-11 10:25 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Nicolas Frattaroli, Saravana Kannan, linux-pm, Stephen Boyd,
	Rafael J . Wysocki, Heiko Stuebner, Sebastian Reichel,
	Sebin Francis, Diederik de Haas, Bjorn Andersson, Abel Vesa,
	Peng Fan, Tomi Valkeinen, Johan Hovold, Maulik Shah, Michal Simek,
	Konrad Dybcio, Thierry Reding, Jonathan Hunter, linux-arm-kernel,
	linux-kernel

On Thu, 11 Sept 2025 at 09:56, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Ulf,
>
> On Tue, 9 Sept 2025 at 13:11, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > Recent changes to genpd prevents those PM domains being powered-on during
> > initialization from being powered-off during the boot sequence. Based upon
> > whether CONFIG_PM_CONFIG_PM_GENERIC_DOMAINS_OF is set of not, genpd relies
> > on the sync_state mechanism or the genpd_power_off_unused() (which is a
> > late_initcall_sync), to understand when it's okay to allow these PM domains
> > to be powered-off.
> >
> > This new behaviour in genpd has lead to problems on different platforms.
> > Let's therefore restore the behavior of genpd_power_off_unused().
> > Moreover, let's introduce GENPD_FLAG_NO_STAY_ON, to allow genpd OF
> > providers to opt-out from the new behaviour.
> >
> > Link: https://lore.kernel.org/all/20250701114733.636510-1-ulf.hansson@linaro.org/
> > Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > Link: https://lore.kernel.org/all/20250902-rk3576-lockup-regression-v1-1-c4a0c9daeb00@collabora.com/
> > Reported-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> > Fixes: 0e789b491ba0 ("pmdomain: core: Leave powered-on genpds on until sync_state")
> > Fixes: 13a4b7fb6260 ("pmdomain: core: Leave powered-on genpds on until late_initcall_sync")
> > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>
> Thanks for your patch!
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> > --- a/include/linux/pm_domain.h
> > +++ b/include/linux/pm_domain.h
> > @@ -115,6 +115,12 @@ struct dev_pm_domain_list {
> >   *                             genpd provider specific way, likely through a
> >   *                             parent device node. This flag makes genpd to
> >   *                             skip its internal support for this.
> > + *
> > + * GENPD_FLAG_NO_STAY_ON:      For genpd OF providers a powered-on PM domain at
> > + *                             initialization is prevented from being
> > + *                             powered-off until the ->sync_state() callback is
> > + *                             invoked. This flag informs genpd to allow a
> > + *                             power-off without waiting for ->sync_state().
>
> This also restores power-down of pmdomains after a failed device
> probe (due to a real issue, or just -EPROBE_DEFER), possibly
> interfering with other devices that are part of the same pmdomain(s)
> but haven't been probed yet. E.g. what if your serial console is
> part of the same pmdomain?  Probably the pmdomain(s) should not
> be powered down immediately, but only later, when either sync state
> or genpd_power_off_unused() kicks in.

That is exactly one of the problems we solve with the new sync_state
support in genpd.

If you have this problem for one of the PM domains, we should not set
GENPD_FLAG_NO_STAY_ON for it. In fact, that's exactly why I added this
flag, to allow it to be set on a per genpd basis. Otherwise we might
as well have used of_genpd_sync_state().

Down the road, if we can improve the sync_state support in genpd,
especially a more fine-grained control for those providers that use
of_genpd_add_provider_onecell(), I hope we should be able to remove
this flag.

[...]

Kind regards
Uffe


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 3/5] pmdomain: renesas: rcar-sysc: Don't keep unused PM domains powered-on
  2025-09-11  9:01   ` Geert Uytterhoeven
@ 2025-09-11 10:31     ` Ulf Hansson
  0 siblings, 0 replies; 22+ messages in thread
From: Ulf Hansson @ 2025-09-11 10:31 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Nicolas Frattaroli, Saravana Kannan, linux-pm, Stephen Boyd,
	Rafael J . Wysocki, Heiko Stuebner, Sebastian Reichel,
	Sebin Francis, Diederik de Haas, Bjorn Andersson, Abel Vesa,
	Peng Fan, Tomi Valkeinen, Johan Hovold, Maulik Shah, Michal Simek,
	Konrad Dybcio, Thierry Reding, Jonathan Hunter, linux-arm-kernel,
	linux-kernel

On Thu, 11 Sept 2025 at 11:02, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Ulf,
>
> On Tue, 9 Sept 2025 at 13:11, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > The recent changes to genpd makes a genpd OF provider that is powered-on at
> > initialization to stay powered-on, until the ->sync_state() callback is
> > invoked for it.
> >
> > This may not happen at all, if we wait for a consumer device to be probed,
> > leading to wasting energy. There are ways to enforce the ->sync_state()
> > callback to be invoked, through sysfs or via the probe-defer-timeout, but
> > none of them in its current form are a good fit for rcar-sysc PM domains.
> >
> > Let's therefore opt-out from this behaviour of genpd for now, by using the
> > GENPD_FLAG_NO_STAY_ON.
> >
> > Link: https://lore.kernel.org/all/20250701114733.636510-1-ulf.hansson@linaro.org/
> > Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > Fixes: 0e789b491ba0 ("pmdomain: core: Leave powered-on genpds on until sync_state")
> > Fixes: 13a4b7fb6260 ("pmdomain: core: Leave powered-on genpds on until late_initcall_sync")
> > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>
> > --- a/drivers/pmdomain/renesas/rcar-sysc.c
> > +++ b/drivers/pmdomain/renesas/rcar-sysc.c
> > @@ -241,6 +241,7 @@ static int __init rcar_sysc_pd_setup(struct rcar_sysc_pd *pd)
> >                 }
> >         }
> >
> > +       genpd->flags |= GENPD_FLAG_NO_STAY_ON;
>
> So this applies to all PM Domains.  While this doesn't hurt, perhaps it
> should not be set for always-on domains, and thus moved up, to become
> an "else" branch in the "if/else if/..."-logic handling always-on
> domains at the top of the function?
>
> This applies to rar-gen4-sysc.c, too.

You have a point, but currently this doesn't really matter. Genpd will
not power-off always-on-domains no matter whether
GENPD_FLAG_NO_STAY_ON is set or not.

The whole purpose from my side was to restore the behaviour we had
before, for the Reneas PM domains. I tend to think that it's better to
apply the $subject patch as is - and leave improvements to be made on
top.

Thanks a lot for testing and reviewing!

[...]

Kind regards
Uffe


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains
  2025-09-11  8:26     ` Diederik de Haas
@ 2025-09-12 18:32       ` Saravana Kannan
  0 siblings, 0 replies; 22+ messages in thread
From: Saravana Kannan @ 2025-09-12 18:32 UTC (permalink / raw)
  To: Diederik de Haas
  Cc: Geert Uytterhoeven, Ulf Hansson, Heiko Stuebner,
	Rafael J . Wysocki, Tomi Valkeinen, Thierry Reding,
	Sebastian Reichel, Jonathan Hunter, linux-rockchip, Konrad Dybcio,
	Peng Fan, linux-pm, Johan Hovold, Sebin Francis, Michal Simek,
	linux-arm-kernel, Maulik Shah, Stephen Boyd, Bjorn Andersson,
	Christian Hewitt, linux-kernel, Abel Vesa, Nicolas Frattaroli

On Thu, Sep 11, 2025 at 1:26 AM Diederik de Haas <didi.debian@cknow.org> wrote:
>
> Hi Geert,
>
> On Thu Sep 11, 2025 at 9:18 AM CEST, Geert Uytterhoeven wrote:
> > On Wed, 10 Sept 2025 at 21:33, Diederik de Haas <didi.debian@cknow.org> wrote:
> >> On Tue Sep 9, 2025 at 1:11 PM CEST, Ulf Hansson wrote:
> >> > Recent changes to genpd prevents those PM domains being powered-on during
> >> > initialization from being powered-off during the boot sequence. Based upon
> >> > whether CONFIG_PM_CONFIG_PM_GENERIC_DOMAINS_OF is set of not, genpd relies
> >> > on the sync_state mechanism or the genpd_power_off_unused() (which is a
> >> > late_initcall_sync), to understand when it's okay to allow these PM domains
> >> > to be powered-off.
> >> >
> >> > This new behaviour in genpd has lead to problems on different platforms [1].
> >> >
> >> > In this series, I am therefore suggesting to restore the behavior of
> >> > genpd_power_off_unused() along with introducing a new genpd config flag,
> >> > GENPD_FLAG_NO_STAY_ON, to allow genpd OF providers to opt-out from the new
> >> > behaviour.
> >>
> >> Is it expected that I'm still seeing this on a Rock64 (rk3328), just
> >> like before [1]?
> >>
> >>   [   17.124202] rockchip-pm-domain ff100000.syscon:power-controller: sync_state() pending due to ff300000.gpu
> >>   [   17.129799] rockchip-pm-domain ff100000.syscon:power-controller: sync_state() pending due to ff350000.video-codec
> >>   [   17.140003] rockchip-pm-domain ff100000.syscon:power-controller: sync_state() pending due to ff360000.video-codec
> >
> > Yes, as the sync state is still blocked on them.
> > Disabling unused PM Domains is done independently of sync state.
> >
> >> This is with a 6.17-rc5 kernel with this patch set applied.
> >> And it also has this patch from Christian Hewitt added, now in v3:
> >> https://lore.kernel.org/linux-rockchip/20250906120810.1833016-1-christianshewitt@gmail.com/
> >>
> >> When I boot into a 6.17-rc5 kernel without any patches applied, I do get
> >> the 2 for ff350000.video-codec and ff360000.video-codec, but not the
> >> ff300000.gpu one.
> >>
> >> Interestingly:
> >> ff300000.gpu -> power-domains = <&power RK3328_PD_GPU>;
> >> ff350000.video-codec -> power-domains = <&power RK3328_PD_VPU>;
> >> ff360000.video-codec -> power-domains = <&power RK3328_PD_VIDEO>;
> >>
> >> I would be surprised if that was a coincidence.
> >
> > Fw_devlinks ignores the index cell (RK3328_PD_*), hence all links are
> > created pointing to the pmdomain controller (in case it has a platform
> > driver) or the first pmdomain (in case it has not). thus blocking the
> > sync state call and power-down for _all_ pmdomains managed by the
> > controller.
>
> I don't think I fully understand this (not your problem due to lack of
> knowledge on my part), but you mentioning 'fw_devlink' rang a bell.
>
> Some time ago Nicolas Frattaroli and I worked on an image for PINE64's
> *Quartz* devices and that added ``fw_devlink=off`` to cmdline.
> I've been using it on all my Rockchip based devices, without
> understanding that parameter ... but (apparently) on my 'rock64-test'
> device, where I tested it with, I had removed that parameter.
> Putting that parameter back ... and those warnings are gone!
>
> Thanks a LOT for that hint!

Please don't just disable fw_devlink using fw_devlink=off. We want to
fix any issues you are hitting with it. I might even delete this "off"
option sometime. It was meant as an early debug option.

Thanks,
Saravana


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains
  2025-09-09 11:11 [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains Ulf Hansson
                   ` (5 preceding siblings ...)
  2025-09-10 19:33 ` [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains Diederik de Haas
@ 2025-09-12 18:36 ` Saravana Kannan
  2025-09-12 18:49   ` Nicolas Frattaroli
  6 siblings, 1 reply; 22+ messages in thread
From: Saravana Kannan @ 2025-09-12 18:36 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Geert Uytterhoeven, Nicolas Frattaroli, linux-pm, Stephen Boyd,
	Rafael J . Wysocki, Heiko Stuebner, Sebastian Reichel,
	Sebin Francis, Diederik de Haas, Bjorn Andersson, Abel Vesa,
	Peng Fan, Tomi Valkeinen, Johan Hovold, Maulik Shah, Michal Simek,
	Konrad Dybcio, Thierry Reding, Jonathan Hunter, linux-arm-kernel,
	linux-kernel

On Tue, Sep 9, 2025 at 4:11 AM Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> Recent changes to genpd prevents those PM domains being powered-on during
> initialization from being powered-off during the boot sequence. Based upon
> whether CONFIG_PM_CONFIG_PM_GENERIC_DOMAINS_OF is set of not, genpd relies
> on the sync_state mechanism or the genpd_power_off_unused() (which is a
> late_initcall_sync), to understand when it's okay to allow these PM domains
> to be powered-off.
>
> This new behaviour in genpd has lead to problems on different platforms [1].
>
> In this series, I am therefore suggesting to restore the behavior of
> genpd_power_off_unused() along with introducing a new genpd config flag,
> GENPD_FLAG_NO_STAY_ON, to allow genpd OF providers to opt-out from the new
> behaviour.
>
> Kind regards
> Ulf Hansson
>
> [1]
> https://lore.kernel.org/all/20250701114733.636510-1-ulf.hansson@linaro.org/
> https://lore.kernel.org/all/20250902-rk3576-lockup-regression-v1-1-c4a0c9daeb00@collabora.com/

I'm surprised this is happening. The default behavior of sync_state()
is to never turn off a power domain until all the consumers have
probed.

Is there a consumer that's not captured correctly? If so, can we add them?

Also, there are already sync_state related kernel configs, command
line options and sysfs files that should allow people to power off
devices (at different levels of granularity) even if its consumers
haven't probed.

Thanks,
Saravana

>
> Ulf Hansson (5):
>   pmdomain: core: Restore behaviour for disabling unused PM domains
>   pmdomain: rockchip: Fix regulator dependency with
>     GENPD_FLAG_NO_STAY_ON
>   pmdomain: renesas: rcar-sysc: Don't keep unused PM domains powered-on
>   pmdomain: renesas: rcar-gen4-sysc: Don't keep unused PM domains
>     powered-on
>   pmdomain: renesas: rmobile-sysc: Don't keep unused PM domains
>     powered-on
>
>  drivers/pmdomain/core.c                   | 20 ++++++++++++++------
>  drivers/pmdomain/renesas/rcar-gen4-sysc.c |  1 +
>  drivers/pmdomain/renesas/rcar-sysc.c      |  1 +
>  drivers/pmdomain/renesas/rmobile-sysc.c   |  3 ++-
>  drivers/pmdomain/rockchip/pm-domains.c    |  2 +-
>  include/linux/pm_domain.h                 |  7 +++++++
>  6 files changed, 26 insertions(+), 8 deletions(-)
>
> --
> 2.43.0
>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains
  2025-09-12 18:36 ` Saravana Kannan
@ 2025-09-12 18:49   ` Nicolas Frattaroli
  0 siblings, 0 replies; 22+ messages in thread
From: Nicolas Frattaroli @ 2025-09-12 18:49 UTC (permalink / raw)
  To: Ulf Hansson, Saravana Kannan
  Cc: Geert Uytterhoeven, linux-pm, Stephen Boyd, Rafael J . Wysocki,
	Heiko Stuebner, Sebastian Reichel, Sebin Francis,
	Diederik de Haas, Bjorn Andersson, Abel Vesa, Peng Fan,
	Tomi Valkeinen, Johan Hovold, Maulik Shah, Michal Simek,
	Konrad Dybcio, Thierry Reding, Jonathan Hunter, linux-arm-kernel,
	linux-kernel

On Friday, 12 September 2025 20:36:35 Central European Summer Time Saravana Kannan wrote:
> On Tue, Sep 9, 2025 at 4:11 AM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> >
> > Recent changes to genpd prevents those PM domains being powered-on during
> > initialization from being powered-off during the boot sequence. Based upon
> > whether CONFIG_PM_CONFIG_PM_GENERIC_DOMAINS_OF is set of not, genpd relies
> > on the sync_state mechanism or the genpd_power_off_unused() (which is a
> > late_initcall_sync), to understand when it's okay to allow these PM domains
> > to be powered-off.
> >
> > This new behaviour in genpd has lead to problems on different platforms [1].
> >
> > In this series, I am therefore suggesting to restore the behavior of
> > genpd_power_off_unused() along with introducing a new genpd config flag,
> > GENPD_FLAG_NO_STAY_ON, to allow genpd OF providers to opt-out from the new
> > behaviour.
> >
> > Kind regards
> > Ulf Hansson
> >
> > [1]
> > https://lore.kernel.org/all/20250701114733.636510-1-ulf.hansson@linaro.org/
> > https://lore.kernel.org/all/20250902-rk3576-lockup-regression-v1-1-c4a0c9daeb00@collabora.com/
> 
> I'm surprised this is happening. The default behavior of sync_state()
> is to never turn off a power domain until all the consumers have
> probed.
> 
> Is there a consumer that's not captured correctly? If so, can we add them?

Yes, and unfortunately, not trivially so, no. In Rockchip's case, the
regulators supplying a certain power domain cannot be acquired at
pmdomain probe time, as the regulators themselves are sometimes
SPI or I2C regulators that depend on powerdomains to be up.

So we only acquire them when the power domain is enabled, which does
not happen for unused PDs. Acquiring them during PD disable also
wouldn't work, as the genpd idle check may run after the regulator
idle check.

> 
> Also, there are already sync_state related kernel configs, command
> line options and sysfs files that should allow people to power off
> devices (at different levels of granularity) even if its consumers
> haven't probed.

This series is a stop-gap solution to get us through v6.17, so that
problematic drivers like Rockchip pmdomains can be rearchitectured
to declare their dependency in some way that is not racey. This
will be somewhat non-trivial, hence the current solution for now.

> 
> Thanks,
> Saravana
> 

Kind regards,
Nicolas Frattaroli

> >
> > Ulf Hansson (5):
> >   pmdomain: core: Restore behaviour for disabling unused PM domains
> >   pmdomain: rockchip: Fix regulator dependency with
> >     GENPD_FLAG_NO_STAY_ON
> >   pmdomain: renesas: rcar-sysc: Don't keep unused PM domains powered-on
> >   pmdomain: renesas: rcar-gen4-sysc: Don't keep unused PM domains
> >     powered-on
> >   pmdomain: renesas: rmobile-sysc: Don't keep unused PM domains
> >     powered-on
> >
> >  drivers/pmdomain/core.c                   | 20 ++++++++++++++------
> >  drivers/pmdomain/renesas/rcar-gen4-sysc.c |  1 +
> >  drivers/pmdomain/renesas/rcar-sysc.c      |  1 +
> >  drivers/pmdomain/renesas/rmobile-sysc.c   |  3 ++-
> >  drivers/pmdomain/rockchip/pm-domains.c    |  2 +-
> >  include/linux/pm_domain.h                 |  7 +++++++
> >  6 files changed, 26 insertions(+), 8 deletions(-)
> >
> > --
> > 2.43.0
> >
> 






^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2025-09-12 18:50 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-09 11:11 [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains Ulf Hansson
2025-09-09 11:11 ` [PATCH 1/5] pmdomain: core: " Ulf Hansson
2025-09-09 12:50   ` Heiko Stübner
2025-09-11  7:56   ` Geert Uytterhoeven
2025-09-11 10:25     ` Ulf Hansson
2025-09-09 11:11 ` [PATCH 2/5] pmdomain: rockchip: Fix regulator dependency with GENPD_FLAG_NO_STAY_ON Ulf Hansson
2025-09-09 12:50   ` Heiko Stübner
2025-09-09 13:49   ` Nicolas Frattaroli
2025-09-09 11:11 ` [PATCH 3/5] pmdomain: renesas: rcar-sysc: Don't keep unused PM domains powered-on Ulf Hansson
2025-09-11  7:56   ` Geert Uytterhoeven
2025-09-11  9:01   ` Geert Uytterhoeven
2025-09-11 10:31     ` Ulf Hansson
2025-09-09 11:11 ` [PATCH 4/5] pmdomain: renesas: rcar-gen4-sysc: " Ulf Hansson
2025-09-11  7:57   ` Geert Uytterhoeven
2025-09-09 11:11 ` [PATCH 5/5] pmdomain: renesas: rmobile-sysc: " Ulf Hansson
2025-09-11  7:58   ` Geert Uytterhoeven
2025-09-10 19:33 ` [PATCH 0/5] pmdomain: Restore behaviour for disabling unused PM domains Diederik de Haas
2025-09-11  7:18   ` Geert Uytterhoeven
2025-09-11  8:26     ` Diederik de Haas
2025-09-12 18:32       ` Saravana Kannan
2025-09-12 18:36 ` Saravana Kannan
2025-09-12 18:49   ` Nicolas Frattaroli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).