Skip to contentSkip to conversation

pmdomain: Add generic ->sync_state() support to genpd

PATCH In review Ulf Hansson 12 participants 72 messages Jul 1, 2025 – Sep 30, 2025

Subsystems (12)
lore
Share & tools
lore
#0 lore raw

v3 cover pmdomain: Add generic ->sync_state() support to genpd

Changes in v3:
- Added a couple of patches to adress problems on some Renesas platforms. Thanks Geert and Tomi for helping out!
- Adressed a few comments from Saravanna and Konrad.
- Added some tested-by tags.

Changes in v2:
- Well, quite a lot as I discovered various problems when doing additional testing of corner-case. I suggest re-review from scratch, even if I decided to keep some reviewed-by tags.
- Added patches to allow some drivers that needs to align or opt-out from the new common behaviour in genpd.

If a PM domain (genpd) is powered-on during boot, there is probably a good reason for it. Therefore it's known to be a bad idea to allow such genpd to be powered-off before all of its consumer devices have been probed. This series intends to fix this problem.

We have been discussing these issues at LKML and at various Linux-conferences in the past. I have therefore tried to include the people I can recall being involved, but I may have forgotten some (my apologies), feel free to loop them in.

I have tested this with QEMU with a bunch of local test-drivers and DT nodes. Let me know if you want me to share this code too.

Please help review and test!
Finally, a big thanks to Saravana for all the support!

Kind regards
Ulf Hansson

Saravana Kannan (1):
driver core: Add dev_set_drv_sync_state()

Ulf Hansson (23):
pmdomain: renesas: rcar-sysc: Add genpd OF provider at
postcore_initcall
pmdomain: renesas: rmobile-sysc: Move init to postcore_initcall
pmdomain: renesas: rcar-gen4-sysc: Move init to postcore_initcall
pmdomain: core: Prevent registering devices before the bus
pmdomain: core: Add a bus and a driver for genpd providers
pmdomain: core: Add the genpd->dev to the genpd provider bus
pmdomain: core: Export a common ->sync_state() helper for genpd
providers
pmdomain: core: Prepare to add the common ->sync_state() support soc/tegra: pmc: Opt-out from genpd's common ->sync_state() support
cpuidle: psci: Opt-out from genpd's common ->sync_state() support
cpuidle: riscv-sbi: Opt-out from genpd's common ->sync_state() support
pmdomain: qcom: rpmpd: Use of_genpd_sync_state()
pmdomain: qcom: rpmhpd: Use of_genpd_sync_state() firmware/pmdomain: xilinx: Move ->sync_state() support to firmware
driver
firmware: xilinx: Don't share zynqmp_pm_init_finalize()
firmware: xilinx: Use of_genpd_sync_state()
driver core: Export get_dev_from_fwnode()
pmdomain: core: Add common ->sync_state() support for genpd providers
pmdomain: core: Default to use of_genpd_sync_state() for genpd
providers
pmdomain: core: Leave powered-on genpds on until late_initcall_sync
pmdomain: core: Leave powered-on genpds on until sync_state
cpuidle: psci: Drop redundant sync_state support
cpuidle: riscv-sbi: Drop redundant sync_state support

 drivers/base/core.c                         |   8 +-
 drivers/cpuidle/cpuidle-psci-domain.c       |  14 --
 drivers/cpuidle/cpuidle-riscv-sbi.c         |  14 --
 drivers/firmware/xilinx/zynqmp.c            |  18 +-
 drivers/pmdomain/core.c                     | 211 ++++++++++++++++++--
 drivers/pmdomain/qcom/rpmhpd.c              |   2 +
 drivers/pmdomain/qcom/rpmpd.c               |   2 +
 drivers/pmdomain/renesas/rcar-gen4-sysc.c   |   2 +-
 drivers/pmdomain/renesas/rcar-sysc.c        |  19 +-
 drivers/pmdomain/renesas/rmobile-sysc.c     |   3 +-
 drivers/pmdomain/xilinx/zynqmp-pm-domains.c |  16 --
 drivers/soc/tegra/pmc.c                     |  26 ++-
 include/linux/device.h                      |  13 ++
 include/linux/firmware/xlnx-zynqmp.h        |   6 -
 include/linux/pm_domain.h                   |  17 ++
 15 files changed, 291 insertions(+), 80 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v3 1/24 pmdomain: renesas: rcar-sysc: Add genpd OF provider at postcore_initcall

Subsequent changes to genpd adds a limitation that registering a genpd OF providers must be done after its bus registration, which is at core_initcall.

To adopt to this, let's split the initialization into two steps. The first part keep registering the PM domains with genpd at early_initcall, as this is needed to bringup the CPUs for R-Car H1, by calling rcar_sysc_power_up_cpu(). The second and new part, moves the registration of the genpd OF provider to a postcore_initcall().

---

Changes in v3:
- New patch.

---
 drivers/pmdomain/renesas/rcar-sysc.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/pmdomain/renesas/rcar-sysc.c +18 -1
index 047495f54e8a..4b310c1d35fa 100644
@@ -342,6 +342,7 @@ struct rcar_pm_domains {
 };
 
 static struct genpd_onecell_data *rcar_sysc_onecell_data;
+static struct device_node *rcar_sysc_onecell_np;
 
 static int __init rcar_sysc_pd_init(void)
 {
@@ -428,7 +429,8 @@ static int __init rcar_sysc_pd_init(void)
 		}
 	}
 
-	error = of_genpd_add_provider_onecell(np, &domains->onecell_data);
+	rcar_sysc_onecell_np = np;
+	return 0;
 
 out_put:
 	of_node_put(np);
@@ -436,6 +438,21 @@ static int __init rcar_sysc_pd_init(void)
 }
 early_initcall(rcar_sysc_pd_init);
 
+static int __init rcar_sysc_pd_init_provider(void)
+{
+	int error;
+
+	if (!rcar_sysc_onecell_np)
+		return -ENODEV;
+
+	error = of_genpd_add_provider_onecell(rcar_sysc_onecell_np,
+					      rcar_sysc_onecell_data);
+
+	of_node_put(rcar_sysc_onecell_np);
+	return error;
+}
+postcore_initcall(rcar_sysc_pd_init_provider);
+
 #ifdef CONFIG_ARCH_R8A7779
 static int rcar_sysc_power_cpu(unsigned int idx, bool on)
 {
Signature · 1 line
2.43.0
#2 lore raw

PATCH v3 2/24 pmdomain: renesas: rmobile-sysc: Move init to postcore_initcall

In reply to Ulf Hansson

Subsequent changes to genpd adds a limitation that registering a genpd OF providers must be done after its bus registration, which is at core_initcall. To adopt to this, let's move to a postcore_initcall.

---

Changes in v3:
- New patch.

---
 drivers/pmdomain/renesas/rmobile-sysc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pmdomain/renesas/rmobile-sysc.c +1 -2
index 5848e79aa438..8eedc9a1d825 100644
@@ -335,5 +335,4 @@ static int __init rmobile_init_pm_domains(void)
 
 	return ret;
 }
-
-core_initcall(rmobile_init_pm_domains);
+postcore_initcall(rmobile_init_pm_domains);
Signature · 1 line
2.43.0
#3 lore raw

PATCH v3 3/24 pmdomain: renesas: rcar-gen4-sysc: Move init to postcore_initcall

In reply to Ulf Hansson

Subsequent changes to genpd adds a limitation that registering a genpd OF providers must be done after its bus registration, which is at core_initcall. To adopt to this, let's move to a postcore_initcall.

---

Changes in v3:
- New patch.

---
 drivers/pmdomain/renesas/rcar-gen4-sysc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pmdomain/renesas/rcar-gen4-sysc.c +1 -1
index e001b5c25bed..5aa7fa1df8fe 100644
@@ -374,4 +374,4 @@ static int __init rcar_gen4_sysc_pd_init(void)
 	of_node_put(np);
 	return error;
 }
-early_initcall(rcar_gen4_sysc_pd_init);
+postcore_initcall(rcar_gen4_sysc_pd_init);
Signature · 1 line
2.43.0
#4 lore raw

PATCH v3 4/24 pmdomain: core: Prevent registering devices before the bus

In reply to Ulf Hansson

We must not register a consumer device to the genpd bus, before registering the bus itself. Even if this doesn't seem to be an issue, let's add a simple check to make sure we really avoid this from happening.

---

Changes in v3:
- New patch.

---
 drivers/pmdomain/core.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/pmdomain/core.c +13 -1
index 9a66b728fbbf..93d71164fc56 100644
@@ -2491,6 +2491,8 @@ struct of_genpd_provider {
 static LIST_HEAD(of_genpd_providers);
 /* Mutex to protect the list above. */
 static DEFINE_MUTEX(of_genpd_mutex);
+/* Used to prevent registering devices before the bus. */
+static bool genpd_bus_registered;
 
 /**
  * genpd_xlate_simple() - Xlate function for direct node-domain mapping
@@ -3179,6 +3181,9 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev,
 	if (num_domains < 0 || index >= num_domains)
 		return NULL;
 
+	if (!genpd_bus_registered)
+		return ERR_PTR(-ENODEV);
+
 	/* Allocate and register device on the genpd bus. */
 	virt_dev = kzalloc(sizeof(*virt_dev), GFP_KERNEL);
 	if (!virt_dev)
@@ -3357,7 +3362,14 @@ EXPORT_SYMBOL_GPL(of_genpd_parse_idle_states);
 
 static int __init genpd_bus_init(void)
 {
-	return bus_register(&genpd_bus_type);
+	int ret;
+
+	ret = bus_register(&genpd_bus_type);
+	if (ret)
+		return ret;
+
+	genpd_bus_registered = true;
+	return 0;
 }
 core_initcall(genpd_bus_init);
 
Signature · 1 line
2.43.0
#5 lore raw

PATCH v3 5/24 pmdomain: core: Add a bus and a driver for genpd providers

In reply to Ulf Hansson

When we create a genpd via pm_genpd_init() we are initializing a corresponding struct device for it, but we don't add the device to any bus_type. It has not really been needed as the device is used as cookie to help us manage OPP tables.

However, to prepare to make better use of the device, let's add a new genpd provider bus_type and a corresponding genpd provider driver. Subsequent changes will make use of this.

---

Changes in v3:
- Dropped unnecessary callbacks and convert to use struct device_driver.

---
 drivers/pmdomain/core.c | 53 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 52 insertions(+), 1 deletion(-)
drivers/pmdomain/core.c +52 -1
index 93d71164fc56..a41f5f91e87f 100644
@@ -27,6 +27,16 @@
 /* Provides a unique ID for each genpd device */
 static DEFINE_IDA(genpd_ida);
 
+/* The bus for genpd_providers. */
+static const struct bus_type genpd_provider_bus_type = {
+	.name		= "genpd_provider",
+};
+
+/* The parent for genpd_provider devices. */
+static struct device genpd_provider_bus = {
+	.init_name = "genpd_provider",
+};
+
 #define GENPD_RETRY_MAX_MS	250		/* Approximate */
 
 #define GENPD_DEV_CALLBACK(genpd, type, callback, dev)		\
@@ -2262,6 +2272,8 @@ static int genpd_alloc_data(struct generic_pm_domain *genpd)
 	genpd->gd = gd;
 	device_initialize(&genpd->dev);
 	genpd->dev.release = genpd_provider_release;
+	genpd->dev.bus = &genpd_provider_bus_type;
+	genpd->dev.parent = &genpd_provider_bus;
 
 	if (!genpd_is_dev_name_fw(genpd)) {
 		dev_set_name(&genpd->dev, "%s", genpd->name);
@@ -3360,16 +3372,55 @@ int of_genpd_parse_idle_states(struct device_node *dn,
 }
 EXPORT_SYMBOL_GPL(of_genpd_parse_idle_states);
 
+static int genpd_provider_probe(struct device *dev)
+{
+	return 0;
+}
+
+static void genpd_provider_sync_state(struct device *dev)
+{
+}
+
+static struct device_driver genpd_provider_drv = {
+	.name = "genpd_provider",
+	.bus = &genpd_provider_bus_type,
+	.probe = genpd_provider_probe,
+	.sync_state = genpd_provider_sync_state,
+	.suppress_bind_attrs = true,
+};
+
 static int __init genpd_bus_init(void)
 {
 	int ret;
 
+	ret = device_register(&genpd_provider_bus);
+	if (ret) {
+		put_device(&genpd_provider_bus);
+		return ret;
+	}
+
+	ret = bus_register(&genpd_provider_bus_type);
+	if (ret)
+		goto err_dev;
+
 	ret = bus_register(&genpd_bus_type);
 	if (ret)
-		return ret;
+		goto err_prov_bus;
+
+	ret = driver_register(&genpd_provider_drv);
+	if (ret)
+		goto err_bus;
 
 	genpd_bus_registered = true;
 	return 0;
+
+err_bus:
+	bus_unregister(&genpd_bus_type);
+err_prov_bus:
+	bus_unregister(&genpd_provider_bus_type);
+err_dev:
+	device_unregister(&genpd_provider_bus);
+	return ret;
 }
 core_initcall(genpd_bus_init);
 
Signature · 1 line
2.43.0
#6 lore raw

PATCH v3 6/24 pmdomain: core: Add the genpd->dev to the genpd provider bus

In reply to Ulf Hansson

To take the next step for a more common handling of the genpd providers, let's add the genpd->dev to the genpd provider bus when registering a genpd OF provider.

Also note, to allow us to add devices to the genpd provider bus we need to make sure the bus has been registered first, which is done via a core_initcall. Hence, calls to of_genpd_add_provider_simple|onecell() must be done after the bus has been registered, else they will fail.

---

Changes in v3:
- Prevent adding the device until the genpd provider bus is registered.

---
 drivers/pmdomain/core.c | 44 +++++++++++++++++++++++++++++++----------
 1 file changed, 34 insertions(+), 10 deletions(-)
drivers/pmdomain/core.c +34 -10
index a41f5f91e87f..79dc0bf406f0 100644
@@ -2611,16 +2611,25 @@ int of_genpd_add_provider_simple(struct device_node *np,
 	if (!np || !genpd)
 		return -EINVAL;
 
+	if (!genpd_bus_registered)
+		return -ENODEV;
+
 	if (!genpd_present(genpd))
 		return -EINVAL;
 
 	genpd->dev.of_node = np;
 
+	ret = device_add(&genpd->dev);
+	if (ret)
+		return ret;
+
 	/* Parse genpd OPP table */
 	if (!genpd_is_opp_table_fw(genpd) && genpd->set_performance_state) {
 		ret = dev_pm_opp_of_add_table(&genpd->dev);
-		if (ret)
-			return dev_err_probe(&genpd->dev, ret, "Failed to add OPP table\n");
+		if (ret) {
+			dev_err_probe(&genpd->dev, ret, "Failed to add OPP table\n");
+			goto err_del;
+		}
 
 		/*
 		 * Save table for faster processing while setting performance
@@ -2631,19 +2640,22 @@ int of_genpd_add_provider_simple(struct device_node *np,
 	}
 
 	ret = genpd_add_provider(np, genpd_xlate_simple, genpd);
-	if (ret) {
-		if (genpd->opp_table) {
-			dev_pm_opp_put_opp_table(genpd->opp_table);
-			dev_pm_opp_of_remove_table(&genpd->dev);
-		}
-
-		return ret;
-	}
+	if (ret)
+		goto err_opp;
 
 	genpd->provider = &np->fwnode;
 	genpd->has_provider = true;
 
 	return 0;
+
+err_opp:
+	if (genpd->opp_table) {
+		dev_pm_opp_put_opp_table(genpd->opp_table);
+		dev_pm_opp_of_remove_table(&genpd->dev);
+	}
+err_del:
+	device_del(&genpd->dev);
+	return ret;
 }
 EXPORT_SYMBOL_GPL(of_genpd_add_provider_simple);
 
@@ -2662,6 +2674,9 @@ int of_genpd_add_provider_onecell(struct device_node *np,
 	if (!np || !data)
 		return -EINVAL;
 
+	if (!genpd_bus_registered)
+		return -ENODEV;
+
 	if (!data->xlate)
 		data->xlate = genpd_xlate_onecell;
 
@@ -2675,12 +2690,17 @@ int of_genpd_add_provider_onecell(struct device_node *np,
 
 		genpd->dev.of_node = np;
 
+		ret = device_add(&genpd->dev);
+		if (ret)
+			goto error;
+
 		/* Parse genpd OPP table */
 		if (!genpd_is_opp_table_fw(genpd) && genpd->set_performance_state) {
 			ret = dev_pm_opp_of_add_table_indexed(&genpd->dev, i);
 			if (ret) {
 				dev_err_probe(&genpd->dev, ret,
 					      "Failed to add OPP table for index %d\n", i);
+				device_del(&genpd->dev);
 				goto error;
 			}
 
@@ -2716,6 +2736,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
 			dev_pm_opp_put_opp_table(genpd->opp_table);
 			dev_pm_opp_of_remove_table(&genpd->dev);
 		}
+
+		device_del(&genpd->dev);
 	}
 
 	return ret;
@@ -2748,6 +2770,8 @@ void of_genpd_del_provider(struct device_node *np)
 						dev_pm_opp_put_opp_table(gpd->opp_table);
 						dev_pm_opp_of_remove_table(&gpd->dev);
 					}
+
+					device_del(&gpd->dev);
 				}
 			}
 
Signature · 1 line
2.43.0
#7 lore raw

PATCH v3 7/24 pmdomain: core: Export a common ->sync_state() helper for genpd providers

In reply to Ulf Hansson

In some cases the typical platform driver that act as genpd provider, may need its own ->sync_state() callback to manage various things. In this regards, the provider most likely wants to allow its corresponding genpds to be powered-off.

For this reason, let's introduce a new genpd helper function, of_genpd_sync_state() that helps genpd provider drivers to achieve this.

---
 drivers/pmdomain/core.c   | 27 +++++++++++++++++++++++++++
 include/linux/pm_domain.h |  3 +++
 2 files changed, 30 insertions(+)
drivers/pmdomain/core.c +27 -0
index 79dc0bf406f0..0a6593a1b1c8 100644
@@ -3396,6 +3396,33 @@ int of_genpd_parse_idle_states(struct device_node *dn,
 }
 EXPORT_SYMBOL_GPL(of_genpd_parse_idle_states);
 
+/**
+ * of_genpd_sync_state() - A common sync_state function for genpd providers
+ * @np: The device node the genpd provider is associated with.
+ *
+ * The @np that corresponds to a genpd provider may provide one or multiple
+ * genpds. This function makes use @np to find the genpds that belongs to the
+ * provider. For each genpd we try a power-off.
+ */
+void of_genpd_sync_state(struct device_node *np)
+{
+	struct generic_pm_domain *genpd;
+
+	if (!np)
+		return;
+
+	mutex_lock(&gpd_list_lock);
+	list_for_each_entry(genpd, &gpd_list, gpd_list_node) {
+		if (genpd->provider == of_fwnode_handle(np)) {
+			genpd_lock(genpd);
+			genpd_power_off(genpd, false, 0);
+			genpd_unlock(genpd);
+		}
+	}
+	mutex_unlock(&gpd_list_lock);
+}
+EXPORT_SYMBOL_GPL(of_genpd_sync_state);
+
 static int genpd_provider_probe(struct device *dev)
 {
 	return 0;
include/linux/pm_domain.h +3 -0
index 0b18160901a2..3578196e6626 100644
@@ -431,6 +431,7 @@ int of_genpd_remove_subdomain(const struct of_phandle_args *parent_spec,
 struct generic_pm_domain *of_genpd_remove_last(struct device_node *np);
 int of_genpd_parse_idle_states(struct device_node *dn,
 			       struct genpd_power_state **states, int *n);
+void of_genpd_sync_state(struct device_node *np);
 
 int genpd_dev_pm_attach(struct device *dev);
 struct device *genpd_dev_pm_attach_by_id(struct device *dev,
@@ -476,6 +477,8 @@ static inline int of_genpd_parse_idle_states(struct device_node *dn,
 	return -ENODEV;
 }
 
+static inline void of_genpd_sync_state(struct device_node *np) {}
+
 static inline int genpd_dev_pm_attach(struct device *dev)
 {
 	return 0;
Signature · 1 line
2.43.0
#8 lore raw

PATCH v3 8/24 pmdomain: core: Prepare to add the common ->sync_state() support

In reply to Ulf Hansson

Before we can implement the common ->sync_state() support in genpd, we need to allow a few specific genpd providers to opt out from the new behaviour.

Let's introduce GENPD_FLAG_NO_SYNC_STATE as a new genpd config option, to allow providers to opt out.

---
 include/linux/pm_domain.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/linux/pm_domain.h +6 -0
index 3578196e6626..9329554b9c4a 100644
@@ -104,6 +104,11 @@ struct dev_pm_domain_list {
  * GENPD_FLAG_DEV_NAME_FW:	Instructs genpd to generate an unique device name
  *				using ida. It is used by genpd providers which
  *				get their genpd-names directly from FW.
+ *
+ * GENPD_FLAG_NO_SYNC_STATE:	The ->sync_state() support is implemented in a
+ *				genpd provider specific way, likely through a
+ *				parent device node. This flag makes genpd to
+ *				skip its internal support for this.
  */
 #define GENPD_FLAG_PM_CLK	 (1U << 0)
 #define GENPD_FLAG_IRQ_SAFE	 (1U << 1)
@@ -114,6 +119,7 @@ struct dev_pm_domain_list {
 #define GENPD_FLAG_MIN_RESIDENCY (1U << 6)
 #define GENPD_FLAG_OPP_TABLE_FW	 (1U << 7)
 #define GENPD_FLAG_DEV_NAME_FW	 (1U << 8)
+#define GENPD_FLAG_NO_SYNC_STATE (1U << 9)
 
 enum gpd_status {
 	GENPD_STATE_ON = 0,	/* PM domain is on */
Signature · 1 line
2.43.0
#9 lore raw

PATCH v3 9/24 soc/tegra: pmc: Opt-out from genpd's common ->sync_state() support

In reply to Ulf Hansson

Tegra implements its own specific ->sync_state() callback for the genpd providers. Let's set the GENPD_FLAG_NO_SYNC_STATE to inform genpd about it.

Moreover, let's call of_genpd_sync_state() to make sure genpd tries to power off unused PM domains.

---
 drivers/soc/tegra/pmc.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)
drivers/soc/tegra/pmc.c +19 -7
index e0d67bfe955c..d209e3435878 100644
@@ -418,7 +418,6 @@ struct tegra_pmc_soc {
  * @irq: chip implementation for the IRQ domain
  * @clk_nb: pclk clock changes handler
  * @core_domain_state_synced: flag marking the core domain's state as synced
- * @core_domain_registered: flag marking the core domain as registered
  * @wake_type_level_map: Bitmap indicating level type for non-dual edge wakes
  * @wake_type_dual_edge_map: Bitmap indicating if a wake is dual-edge or not
  * @wake_sw_status_map: Bitmap to hold raw status of wakes without mask
@@ -462,7 +461,6 @@ struct tegra_pmc {
 	struct notifier_block clk_nb;
 
 	bool core_domain_state_synced;
-	bool core_domain_registered;
 
 	unsigned long *wake_type_level_map;
 	unsigned long *wake_type_dual_edge_map;
@@ -1297,6 +1295,7 @@ static int tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np)
 
 	pg->id = id;
 	pg->genpd.name = np->name;
+	pg->genpd.flags = GENPD_FLAG_NO_SYNC_STATE;
 	pg->genpd.power_off = tegra_genpd_power_off;
 	pg->genpd.power_on = tegra_genpd_power_on;
 	pg->pmc = pmc;
@@ -1406,6 +1405,7 @@ static int tegra_pmc_core_pd_add(struct tegra_pmc *pmc, struct device_node *np)
 		return -ENOMEM;
 
 	genpd->name = "core";
+	genpd->flags = GENPD_FLAG_NO_SYNC_STATE;
 	genpd->set_performance_state = tegra_pmc_core_pd_set_performance_state;
 
 	err = devm_pm_opp_set_regulators(pmc->dev, rname);
@@ -1425,8 +1425,6 @@ static int tegra_pmc_core_pd_add(struct tegra_pmc *pmc, struct device_node *np)
 		goto remove_genpd;
 	}
 
-	pmc->core_domain_registered = true;
-
 	return 0;
 
 remove_genpd:
@@ -4263,8 +4261,25 @@ static const struct of_device_id tegra_pmc_match[] = {
 
 static void tegra_pmc_sync_state(struct device *dev)
 {
+	struct device_node *np, *child;
 	int err;
 
+	np = of_get_child_by_name(dev->of_node, "powergates");
+	if (!np)
+		return;
+
+	for_each_child_of_node(np, child)
+		of_genpd_sync_state(child);
+
+	of_node_put(np);
+
+	np = of_get_child_by_name(dev->of_node, "core-domain");
+	if (!np)
+		return;
+
+	of_genpd_sync_state(np);
+	of_node_put(np);
+
 	/*
 	 * Newer device-trees have power domains, but we need to prepare all
 	 * device drivers with runtime PM and OPP support first, otherwise
@@ -4278,9 +4293,6 @@ static void tegra_pmc_sync_state(struct device *dev)
 	 * no dependencies that will block the state syncing. We shouldn't
 	 * mark the domain as synced in this case.
 	 */
-	if (!pmc->core_domain_registered)
-		return;
-
 	pmc->core_domain_state_synced = true;
 
 	/* this is a no-op if core regulator isn't used */
Signature · 1 line
2.43.0
#10 lore raw

PATCH v3 10/24 cpuidle: psci: Opt-out from genpd's common ->sync_state() support

In reply to Ulf Hansson

The cpuidle-psci-domain implements its own specific ->sync_state() callback. Let's set the GENPD_FLAG_NO_SYNC_STATE to inform genpd about it.

Moreover, let's call of_genpd_sync_state() to make sure genpd tries to power off unused PM domains.

---
 drivers/cpuidle/cpuidle-psci-domain.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/cpuidle/cpuidle-psci-domain.c +7 -1
index 2041f59116ce..b880ce2df8b5 100644
@@ -63,7 +63,8 @@ static int psci_pd_init(struct device_node *np, bool use_osi)
 	if (!pd_provider)
 		goto free_pd;
 
-	pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN;
+	pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN |
+		     GENPD_FLAG_NO_SYNC_STATE;
 
 	/*
 	 * Allow power off when OSI has been successfully enabled.
@@ -128,11 +129,16 @@ static void psci_pd_remove(void)
 
 static void psci_cpuidle_domain_sync_state(struct device *dev)
 {
+	struct psci_pd_provider *pd_provider;
+
 	/*
 	 * All devices have now been attached/probed to the PM domain topology,
 	 * hence it's fine to allow domain states to be picked.
 	 */
 	psci_pd_allow_domain_state = true;
+
+	list_for_each_entry(pd_provider, &psci_pd_providers, link)
+		of_genpd_sync_state(pd_provider->node);
 }
 
 static const struct of_device_id psci_of_match[] = {
Signature · 1 line
2.43.0
#11 lore raw

PATCH v3 11/24 cpuidle: riscv-sbi: Opt-out from genpd's common ->sync_state() support

In reply to Ulf Hansson

The riscv-sbi-domain implements its own specific ->sync_state() callback. Let's set the GENPD_FLAG_NO_SYNC_STATE to inform genpd about it.

Moreover, let's call of_genpd_sync_state() to make sure genpd tries to power off unused PM domains.

---
 drivers/cpuidle/cpuidle-riscv-sbi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/cpuidle/cpuidle-riscv-sbi.c +7 -1
index 0fe1ece9fbdc..83d58d00872f 100644
@@ -347,11 +347,16 @@ static int sbi_cpuidle_init_cpu(struct device *dev, int cpu)
 
 static void sbi_cpuidle_domain_sync_state(struct device *dev)
 {
+	struct sbi_pd_provider *pd_provider;
+
 	/*
 	 * All devices have now been attached/probed to the PM domain
 	 * topology, hence it's fine to allow domain states to be picked.
 	 */
 	sbi_cpuidle_pd_allow_domain_state = true;
+
+	list_for_each_entry(pd_provider, &sbi_pd_providers, link)
+		of_genpd_sync_state(pd_provider->node);
 }
 
 #ifdef CONFIG_DT_IDLE_GENPD
@@ -396,7 +401,8 @@ static int sbi_pd_init(struct device_node *np)
 	if (!pd_provider)
 		goto free_pd;
 
-	pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN;
+	pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN |
+		     GENPD_FLAG_NO_SYNC_STATE;
 
 	/* Allow power off when OSI is available. */
 	if (sbi_cpuidle_use_osi)
Signature · 1 line
2.43.0
Reviewed-by on v3 11/24
#12 lore raw

Re: [PATCH v3 11/24] cpuidle: riscv-sbi: Opt-out from genpd's common ->sync_state() support

Quoted 7 lines · Ulf Hansson

The riscv-sbi-domain implements its own specific ->sync_state() callback. Let's set the GENPD_FLAG_NO_SYNC_STATE to inform genpd about it.

Moreover, let's call of_genpd_sync_state() to make sure genpd tries to power off unused PM domains.

Quoted 9 lines
---
 drivers/cpuidle/cpuidle-riscv-sbi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

LGTM

maintainer Reviewed-by on v3 11/24
#13 lore raw

Re: [PATCH v3 11/24] cpuidle: riscv-sbi: Opt-out from genpd's common ->sync_state() support

In reply to Ulf Hansson
Quoted 4 lines · Ulf Hansson

The riscv-sbi-domain implements its own specific ->sync_state() callback. Let's set the GENPD_FLAG_NO_SYNC_STATE to inform genpd about it.

Quoted 8 lines

Moreover, let's call of_genpd_sync_state() to make sure genpd tries to power off unused PM domains.

LGTM.

Regards,
Anup

Quoted 38 lines
---
 drivers/cpuidle/cpuidle-riscv-sbi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/cpuidle/cpuidle-riscv-sbi.c +7 -2
index 0fe1ece9fbdc..83d58d00872f 100644
@@ -347,11 +347,16 @@ static int sbi_cpuidle_init_cpu(struct device *dev, int cpu)
 
 static void sbi_cpuidle_domain_sync_state(struct device *dev)
 {
+       struct sbi_pd_provider *pd_provider;
+
        /*
         * All devices have now been attached/probed to the PM domain
         * topology, hence it's fine to allow domain states to be picked.
         */
        sbi_cpuidle_pd_allow_domain_state = true;
+
+       list_for_each_entry(pd_provider, &sbi_pd_providers, link)
+               of_genpd_sync_state(pd_provider->node);
 }
 
 #ifdef CONFIG_DT_IDLE_GENPD
@@ -396,7 +401,8 @@ static int sbi_pd_init(struct device_node *np)
        if (!pd_provider)
                goto free_pd;
 
-       pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN;
+       pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN |
+                    GENPD_FLAG_NO_SYNC_STATE;
 
        /* Allow power off when OSI is available. */
        if (sbi_cpuidle_use_osi)
--

2.43.0

#14 lore raw

Re: [PATCH v3 11/24] cpuidle: riscv-sbi: Opt-out from genpd's common ->sync_state() support

In reply to Ulf Hansson
This series was applied to riscv/linux.git (fixes) by Ulf Hansson <[email protected]>:

Hello:

This series was applied to riscv/linux.git (fixes) by Ulf Hansson <[email protected]>:

Quoted 6 lines · On Tue, 1 Jul 2025 13:47:13 +0200 you wrote:

The riscv-sbi-domain implements its own specific ->sync_state() callback. Let's set the GENPD_FLAG_NO_SYNC_STATE to inform genpd about it.

Moreover, let's call of_genpd_sync_state() to make sure genpd tries to power off unused PM domains.

Quoted 7 lines

[...]

Here is the summary with links:
- [v3,11/24] cpuidle: riscv-sbi: Opt-out from genpd's common ->sync_state() support

    https://git.kernel.org/riscv/c/ee766b017586
  - [v3,24/24] cpuidle: riscv-sbi: Drop redundant sync_state support
    https://git.kernel.org/riscv/c/eb34a0b5fee7

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#15 lore raw

PATCH v3 12/24 pmdomain: qcom: rpmpd: Use of_genpd_sync_state()

In reply to Ulf Hansson

To make sure genpd tries to power off unused PM domains, let's call of_genpd_sync_state() from our own ->sync_state() callback.

---

Changes in v3:
- Fixup the prefix in the commit-message-header.

---
 drivers/pmdomain/qcom/rpmpd.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pmdomain/qcom/rpmpd.c +2 -0
index 0be6b3026e3a..833c46944600 100644
@@ -1144,6 +1144,8 @@ static void rpmpd_sync_state(struct device *dev)
 	unsigned int i;
 	int ret;
 
+	of_genpd_sync_state(dev->of_node);
+
 	mutex_lock(&rpmpd_lock);
 	for (i = 0; i < desc->num_pds; i++) {
 		pd = rpmpds[i];
Signature · 1 line
2.43.0
#16 lore raw

PATCH v3 13/24 pmdomain: qcom: rpmhpd: Use of_genpd_sync_state()

In reply to Ulf Hansson

To make sure genpd tries to power off unused PM domains, let's call of_genpd_sync_state() from our own ->sync_state() callback.

---
 drivers/pmdomain/qcom/rpmhpd.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pmdomain/qcom/rpmhpd.c +2 -0
index 078323b85b56..d9ad6a94b3ab 100644
@@ -1027,6 +1027,8 @@ static void rpmhpd_sync_state(struct device *dev)
 	unsigned int i;
 	int ret;
 
+	of_genpd_sync_state(dev->of_node);
+
 	mutex_lock(&rpmhpd_lock);
 	for (i = 0; i < desc->num_pds; i++) {
 		pd = rpmhpds[i];
Signature · 1 line
2.43.0
#17 lore raw

PATCH v3 14/24 firmware/pmdomain: xilinx: Move ->sync_state() support to firmware driver

In reply to Ulf Hansson

Rather than having the genpd provider to add device_links for each device that gets attached, to implement the ->sync_state() support, let's rely on fw_devlink to do this for us.

In this way, we can simplify the code by moving the ->sync_state() callback into the firmware driver, so let's do that.

---
 drivers/firmware/xilinx/zynqmp.c            | 10 ++++++++++
 drivers/pmdomain/xilinx/zynqmp-pm-domains.c | 16 ----------------
 2 files changed, 10 insertions(+), 16 deletions(-)
drivers/firmware/xilinx/zynqmp.c +10 -0
index 7356e860e65c..a91a0191c689 100644
@@ -2100,6 +2100,15 @@ static void zynqmp_firmware_remove(struct platform_device *pdev)
 	platform_device_unregister(em_dev);
 }
 
+static void zynqmp_firmware_sync_state(struct device *dev)
+{
+	if (!of_device_is_compatible(dev->of_node, "xlnx,zynqmp-firmware"))
+		return;
+
+	if (zynqmp_pm_init_finalize())
+		dev_warn(dev, "failed to release power management to firmware\n");
+}
+
 static const struct of_device_id zynqmp_firmware_of_match[] = {
 	{.compatible = "xlnx,zynqmp-firmware"},
 	{.compatible = "xlnx,versal-firmware"},
@@ -2112,6 +2121,7 @@ static struct platform_driver zynqmp_firmware_driver = {
 		.name = "zynqmp_firmware",
 		.of_match_table = zynqmp_firmware_of_match,
 		.dev_groups = zynqmp_firmware_groups,
+		.sync_state = zynqmp_firmware_sync_state,
 	},
 	.probe = zynqmp_firmware_probe,
 	.remove = zynqmp_firmware_remove,
drivers/pmdomain/xilinx/zynqmp-pm-domains.c +0 -16
index d579220a4500..b5aedd6e33ad 100644
@@ -153,14 +153,8 @@ static int zynqmp_gpd_attach_dev(struct generic_pm_domain *domain,
 				 struct device *dev)
 {
 	struct zynqmp_pm_domain *pd = to_zynqmp_pm_domain(domain);
-	struct device_link *link;
 	int ret;
 
-	link = device_link_add(dev, &domain->dev, DL_FLAG_SYNC_STATE_ONLY);
-	if (!link)
-		dev_dbg(&domain->dev, "failed to create device link for %s\n",
-			dev_name(dev));
-
 	/* If this is not the first device to attach there is nothing to do */
 	if (domain->device_count)
 		return 0;
@@ -298,19 +292,9 @@ static void zynqmp_gpd_remove(struct platform_device *pdev)
 	of_genpd_del_provider(pdev->dev.parent->of_node);
 }
 
-static void zynqmp_gpd_sync_state(struct device *dev)
-{
-	int ret;
-
-	ret = zynqmp_pm_init_finalize();
-	if (ret)
-		dev_warn(dev, "failed to release power management to firmware\n");
-}
-
 static struct platform_driver zynqmp_power_domain_driver = {
 	.driver	= {
 		.name = "zynqmp_power_controller",
-		.sync_state = zynqmp_gpd_sync_state,
 	},
 	.probe = zynqmp_gpd_probe,
 	.remove = zynqmp_gpd_remove,
Signature · 1 line
2.43.0
#18 lore raw

PATCH v3 15/24 firmware: xilinx: Don't share zynqmp_pm_init_finalize()

In reply to Ulf Hansson

As there no longer any users outside the zynqmp firmware driver of zynqmp_pm_init_finalize(), let's turn into a local static function.

---
 drivers/firmware/xilinx/zynqmp.c     | 3 +--
 include/linux/firmware/xlnx-zynqmp.h | 6 ------
 2 files changed, 1 insertion(+), 8 deletions(-)
drivers/firmware/xilinx/zynqmp.c +1 -2
index a91a0191c689..87ddbb7d11c2 100644
@@ -1299,11 +1299,10 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_bootmode_write);
  * This API function is to be used for notify the power management controller
  * about the completed power management initialization.
  */
-int zynqmp_pm_init_finalize(void)
+static int zynqmp_pm_init_finalize(void)
 {
 	return zynqmp_pm_invoke_fn(PM_PM_INIT_FINALIZE, NULL, 0);
 }
-EXPORT_SYMBOL_GPL(zynqmp_pm_init_finalize);
 
 /**
  * zynqmp_pm_set_suspend_mode()	- Set system suspend mode
include/linux/firmware/xlnx-zynqmp.h +0 -6
index 6d4dbc196b93..ae48d619c4e0 100644
@@ -585,7 +585,6 @@ int zynqmp_pm_reset_assert(const u32 reset,
 int zynqmp_pm_reset_get_status(const u32 reset, u32 *status);
 unsigned int zynqmp_pm_bootmode_read(u32 *ps_mode);
 int zynqmp_pm_bootmode_write(u32 ps_mode);
-int zynqmp_pm_init_finalize(void);
 int zynqmp_pm_set_suspend_mode(u32 mode);
 int zynqmp_pm_request_node(const u32 node, const u32 capabilities,
 			   const u32 qos, const enum zynqmp_pm_request_ack ack);
@@ -746,11 +745,6 @@ static inline int zynqmp_pm_bootmode_write(u32 ps_mode)
 	return -ENODEV;
 }
 
-static inline int zynqmp_pm_init_finalize(void)
-{
-	return -ENODEV;
-}
-
 static inline int zynqmp_pm_set_suspend_mode(u32 mode)
 {
 	return -ENODEV;
Signature · 1 line
2.43.0
#19 lore raw

PATCH v3 16/24 firmware: xilinx: Use of_genpd_sync_state()

In reply to Ulf Hansson

To make sure genpd tries to power off unused PM domains, let's call of_genpd_sync_state() from our own ->sync_state() callback.

---
 drivers/firmware/xilinx/zynqmp.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/firmware/xilinx/zynqmp.c +6 -1
index 87ddbb7d11c2..02da3e48bc8f 100644
@@ -20,6 +20,7 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
+#include <linux/pm_domain.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
 #include <linux/hashtable.h>
@@ -2101,9 +2102,13 @@ static void zynqmp_firmware_remove(struct platform_device *pdev)
 
 static void zynqmp_firmware_sync_state(struct device *dev)
 {
-	if (!of_device_is_compatible(dev->of_node, "xlnx,zynqmp-firmware"))
+	struct device_node *np = dev->of_node;
+
+	if (!of_device_is_compatible(np, "xlnx,zynqmp-firmware"))
 		return;
 
+	of_genpd_sync_state(np);
+
 	if (zynqmp_pm_init_finalize())
 		dev_warn(dev, "failed to release power management to firmware\n");
 }
Signature · 1 line
2.43.0
#20 lore raw

PATCH v3 17/24 driver core: Export get_dev_from_fwnode()

In reply to Ulf Hansson

It has turned out get_dev_from_fwnode() is useful at a few other places outside of the driver core, as in gpiolib.c for example. Therefore let's make it available as a common helper function.

---
 drivers/base/core.c    | 8 ++++++--
 include/linux/device.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/base/core.c +6 -2
index cbc0099d8ef2..6f91ece7c06a 100644
@@ -1881,8 +1881,6 @@ static void fw_devlink_unblock_consumers(struct device *dev)
 	device_links_write_unlock();
 }
 
-#define get_dev_from_fwnode(fwnode)	get_device((fwnode)->dev)
-
 static bool fwnode_init_without_drv(struct fwnode_handle *fwnode)
 {
 	struct device *dev;
@@ -5281,6 +5279,12 @@ void device_set_node(struct device *dev, struct fwnode_handle *fwnode)
 }
 EXPORT_SYMBOL_GPL(device_set_node);
 
+struct device *get_dev_from_fwnode(struct fwnode_handle *fwnode)
+{
+	return get_device((fwnode)->dev);
+}
+EXPORT_SYMBOL_GPL(get_dev_from_fwnode);
+
 int device_match_name(struct device *dev, const void *name)
 {
 	return sysfs_streq(dev_name(dev), name);
include/linux/device.h +1 -0
index 4940db137fff..315b00171335 100644
@@ -1048,6 +1048,7 @@ void device_set_node(struct device *dev, struct fwnode_handle *fwnode);
 int device_add_of_node(struct device *dev, struct device_node *of_node);
 void device_remove_of_node(struct device *dev);
 void device_set_of_node_from_dev(struct device *dev, const struct device *dev2);
+struct device *get_dev_from_fwnode(struct fwnode_handle *fwnode);
 
 static inline struct device_node *dev_of_node(struct device *dev)
 {
Signature · 1 line
2.43.0
maintainer Acked-by on v3 17/24
#21 lore raw

Re: [PATCH v3 17/24] driver core: Export get_dev_from_fwnode()

Quoted 9 lines · Ulf Hansson

It has turned out get_dev_from_fwnode() is useful at a few other places outside of the driver core, as in gpiolib.c for example. Therefore let's make it available as a common helper function.

Quoted 5 lines
---
 drivers/base/core.c    | 8 ++++++--
 include/linux/device.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)
maintainer
#22 lore raw

Re: [PATCH v3 17/24] driver core: Export get_dev_from_fwnode()

Quoted 16 lines · Greg Kroah-Hartman
Quoted 9 lines · Ulf Hansson

It has turned out get_dev_from_fwnode() is useful at a few other places outside of the driver core, as in gpiolib.c for example. Therefore let's make it available as a common helper function.

Quoted 5 lines
---
 drivers/base/core.c    | 8 ++++++--
 include/linux/device.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)
Quoted 1 line

I'm a bit concerned about exporting get_dev_from_fwnode() -- at least without a clear note on that this helper should be used with caution.

AFAIK, a struct fwnode_handle instance does not have a reference count for its struct device pointer.

Hence, calling get_dev_from_fwnode() with a valid fwnode handle is not enough. The caller also needs to ensure that the device the fwnode has a pointer to has not been released yet.

If this really needs to be exported, can we please add documentation covering this properly?

- Danilo

#23 lore raw

Re: [PATCH v3 17/24] driver core: Export get_dev_from_fwnode()

Quoted 20 lines · Danilo Krummrich
Quoted 16 lines · Greg Kroah-Hartman
Quoted 9 lines · Ulf Hansson

It has turned out get_dev_from_fwnode() is useful at a few other places outside of the driver core, as in gpiolib.c for example. Therefore let's make it available as a common helper function.

Quoted 5 lines
---
 drivers/base/core.c    | 8 ++++++--
 include/linux/device.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)
Quoted 1 line
Quoted 7 lines

I'm a bit concerned about exporting get_dev_from_fwnode() -- at least without a clear note on that this helper should be used with caution.

AFAIK, a struct fwnode_handle instance does not have a reference count for its struct device pointer.

Hence, calling get_dev_from_fwnode() with a valid fwnode handle is not enough.

Not enough for what?

Quoted 2 lines

The caller also needs to ensure that the device the fwnode has a pointer to has not been released yet.

Why? The point of the API is to give you the driver core's notion of the primary device that corresponds to a fwnode at that instant.

There's no refcount needed for that. This is just a simpler way than looping through all the devices to find the first device that has that specific fwnode.

It's only the device that needs to be ref counted because the caller needs to do stuff with it.

-Saravana

maintainer
#24 lore raw

Re: [PATCH v3 17/24] driver core: Export get_dev_from_fwnode()

Quoted 24 lines · Saravana Kannan
Quoted 23 lines · Danilo Krummrich
Quoted 16 lines · Greg Kroah-Hartman
Quoted 9 lines · Ulf Hansson

It has turned out get_dev_from_fwnode() is useful at a few other places outside of the driver core, as in gpiolib.c for example. Therefore let's make it available as a common helper function.

Quoted 5 lines
---
 drivers/base/core.c    | 8 ++++++--
 include/linux/device.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)
Quoted 1 line

I'm a bit concerned about exporting get_dev_from_fwnode() -- at least without a clear note on that this helper should be used with caution.

Quoted 6 lines
Quoted 4 lines

AFAIK, a struct fwnode_handle instance does not have a reference count for its struct device pointer.

Hence, calling get_dev_from_fwnode() with a valid fwnode handle is not enough.

Not enough for what?

Having a valid pointer to a fwnode does not guarantee that fwnode->dev is a valid pointer. Given that fwnode is reference counted itself, but only has a weak reference of the device behind fwnode->dev, the device may have been released already.

If the scope this function is called from can't guarantee that fwnode->dev has not been released yet, it's a potential UAF.

Yes, device_del() sets dev->fwnode->dev = NULL. But that makes it still racy.

If someone has a reference count on the fwnode and calls get_dev_from_fwnode() while device_del() runs concurrently (assuming that device_del() drops the last reference of the device), it's a race with a potential UAF.

We should warn about this, when makeing get_dev_from_fwnode() and API that can be used by *everyone*.

- Danilo

#25 lore raw

PATCH v3 18/24 pmdomain: core: Add common ->sync_state() support for genpd providers

In reply to Ulf Hansson

If the genpd provider's fwnode doesn't have an associated struct device with it, we can make use of the generic genpd->dev and it corresponding driver internally in genpd to manage ->sync_state().

More precisely, while adding a genpd OF provider let's check if the fwnode has a device and if not, make the preparation to handle ->sync_state() internally through the genpd_provider_driver and the genpd_provider_bus.

Note that, genpd providers may opt out from this behaviour by setting the GENPD_FLAG_NO_SYNC_STATE config options for the genpds in question.

---
 drivers/pmdomain/core.c   | 52 +++++++++++++++++++++++++++++++++++++--
 include/linux/pm_domain.h |  7 ++++++
 2 files changed, 57 insertions(+), 2 deletions(-)
drivers/pmdomain/core.c +50 -2
index 0a6593a1b1c8..ca47f91b9e91 100644
@@ -186,6 +186,7 @@ static const struct genpd_lock_ops genpd_raw_spin_ops = {
 #define genpd_is_rpm_always_on(genpd)	(genpd->flags & GENPD_FLAG_RPM_ALWAYS_ON)
 #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)
 
 static inline bool irq_safe_dev_in_sleep_domain(struct device *dev,
 		const struct generic_pm_domain *genpd)
@@ -2351,6 +2352,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->sync_state = GENPD_SYNC_STATE_OFF;
 	genpd->device_count = 0;
 	genpd->provider = NULL;
 	genpd->device_id = -ENXIO;
@@ -2606,6 +2608,8 @@ static bool genpd_present(const struct generic_pm_domain *genpd)
 int of_genpd_add_provider_simple(struct device_node *np,
 				 struct generic_pm_domain *genpd)
 {
+	struct fwnode_handle *fwnode;
+	struct device *dev;
 	int ret;
 
 	if (!np || !genpd)
@@ -2619,6 +2623,15 @@ int of_genpd_add_provider_simple(struct device_node *np,
 
 	genpd->dev.of_node = np;
 
+	fwnode = of_fwnode_handle(np);
+	dev = get_dev_from_fwnode(fwnode);
+	if (!dev && !genpd_is_no_sync_state(genpd)) {
+		genpd->sync_state = GENPD_SYNC_STATE_SIMPLE;
+		device_set_node(&genpd->dev, fwnode);
+	}
+
+	put_device(dev);
+
 	ret = device_add(&genpd->dev);
 	if (ret)
 		return ret;
@@ -2643,7 +2656,7 @@ int of_genpd_add_provider_simple(struct device_node *np,
 	if (ret)
 		goto err_opp;
 
-	genpd->provider = &np->fwnode;
+	genpd->provider = fwnode;
 	genpd->has_provider = true;
 
 	return 0;
@@ -2668,8 +2681,11 @@ int of_genpd_add_provider_onecell(struct device_node *np,
 				  struct genpd_onecell_data *data)
 {
 	struct generic_pm_domain *genpd;
+	struct fwnode_handle *fwnode;
+	struct device *dev;
 	unsigned int i;
 	int ret = -EINVAL;
+	bool sync_state = false;
 
 	if (!np || !data)
 		return -EINVAL;
@@ -2680,6 +2696,13 @@ int of_genpd_add_provider_onecell(struct device_node *np,
 	if (!data->xlate)
 		data->xlate = genpd_xlate_onecell;
 
+	fwnode = of_fwnode_handle(np);
+	dev = get_dev_from_fwnode(fwnode);
+	if (!dev)
+		sync_state = true;
+
+	put_device(dev);
+
 	for (i = 0; i < data->num_domains; i++) {
 		genpd = data->domains[i];
 
@@ -2690,6 +2713,12 @@ int of_genpd_add_provider_onecell(struct device_node *np,
 
 		genpd->dev.of_node = np;
 
+		if (sync_state && !genpd_is_no_sync_state(genpd)) {
+			genpd->sync_state = GENPD_SYNC_STATE_ONECELL;
+			device_set_node(&genpd->dev, fwnode);
+			sync_state = false;
+		}
+
 		ret = device_add(&genpd->dev);
 		if (ret)
 			goto error;
@@ -2712,7 +2741,7 @@ int of_genpd_add_provider_onecell(struct device_node *np,
 			WARN_ON(IS_ERR(genpd->opp_table));
 		}
 
-		genpd->provider = &np->fwnode;
+		genpd->provider = fwnode;
 		genpd->has_provider = true;
 	}
 
@@ -3430,6 +3459,25 @@ static int genpd_provider_probe(struct device *dev)
 
 static void genpd_provider_sync_state(struct device *dev)
 {
+	struct generic_pm_domain *genpd = container_of(dev, struct generic_pm_domain, dev);
+
+	switch (genpd->sync_state) {
+	case GENPD_SYNC_STATE_OFF:
+		break;
+
+	case GENPD_SYNC_STATE_ONECELL:
+		of_genpd_sync_state(dev->of_node);
+		break;
+
+	case GENPD_SYNC_STATE_SIMPLE:
+		genpd_lock(genpd);
+		genpd_power_off(genpd, false, 0);
+		genpd_unlock(genpd);
+		break;
+
+	default:
+		break;
+	}
 }
 
 static struct device_driver genpd_provider_drv = {
include/linux/pm_domain.h +7 -0
index 9329554b9c4a..d68e07dadc99 100644
@@ -133,6 +133,12 @@ enum genpd_notication {
 	GENPD_NOTIFY_ON,
 };
 
+enum genpd_sync_state {
+	GENPD_SYNC_STATE_OFF = 0,
+	GENPD_SYNC_STATE_SIMPLE,
+	GENPD_SYNC_STATE_ONECELL,
+};
+
 struct dev_power_governor {
 	bool (*power_down_ok)(struct dev_pm_domain *domain);
 	bool (*suspend_ok)(struct device *dev);
@@ -193,6 +199,7 @@ struct generic_pm_domain {
 	unsigned int performance_state;	/* Aggregated max performance state */
 	cpumask_var_t cpus;		/* A cpumask of the attached CPUs */
 	bool synced_poweroff;		/* A consumer needs a synced poweroff */
+	enum genpd_sync_state sync_state; /* How sync_state is managed. */
 	int (*power_off)(struct generic_pm_domain *domain);
 	int (*power_on)(struct generic_pm_domain *domain);
 	struct raw_notifier_head power_notifiers; /* Power on/off notifiers */
Signature · 1 line
2.43.0
#26 lore raw

PATCH v3 19/24 driver core: Add dev_set_drv_sync_state()

In reply to Ulf Hansson

From: Saravana Kannan <[email protected]>

This can be used by frameworks to set the sync_state() helper functions for drivers that don't already have them set.

---
 include/linux/device.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/linux/device.h +12 -0
index 315b00171335..686f2a578fbd 100644
@@ -917,6 +917,18 @@ static inline bool dev_has_sync_state(struct device *dev)
 	return false;
 }
 
+static inline int dev_set_drv_sync_state(struct device *dev,
+					 void (*fn)(struct device *dev))
+{
+	if (!dev || !dev->driver)
+		return 0;
+	if (dev->driver->sync_state && dev->driver->sync_state != fn)
+		return -EBUSY;
+	if (!dev->driver->sync_state)
+		dev->driver->sync_state = fn;
+	return 0;
+}
+
 static inline void dev_set_removable(struct device *dev,
 				     enum device_removable removable)
 {
Signature · 1 line
2.43.0
#27 lore raw

PATCH v3 20/24 pmdomain: core: Default to use of_genpd_sync_state() for genpd providers

In reply to Ulf Hansson

Unless the typical platform driver that act as genpd provider, has its own ->sync_state() callback implemented let's default to use of_genpd_sync_state().

More precisely, while adding a genpd OF provider let's assign the ->sync_state() callback, in case the fwnode has a device and its driver doesn't have the ->sync_state() set already. In this way the typical platform driver doesn't need to assign ->sync_state(), unless it has some additional things to manage beyond genpds.

---
 drivers/pmdomain/core.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/pmdomain/core.c +9 -0
index ca47f91b9e91..5cef6de60c72 100644
@@ -2600,6 +2600,11 @@ static bool genpd_present(const struct generic_pm_domain *genpd)
 	return ret;
 }
 
+static void genpd_sync_state(struct device *dev)
+{
+	return of_genpd_sync_state(dev->of_node);
+}
+
 /**
  * of_genpd_add_provider_simple() - Register a simple PM domain provider
  * @np: Device node pointer associated with the PM domain provider.
@@ -2628,6 +2633,8 @@ int of_genpd_add_provider_simple(struct device_node *np,
 	if (!dev && !genpd_is_no_sync_state(genpd)) {
 		genpd->sync_state = GENPD_SYNC_STATE_SIMPLE;
 		device_set_node(&genpd->dev, fwnode);
+	} else {
+		dev_set_drv_sync_state(dev, genpd_sync_state);
 	}
 
 	put_device(dev);
@@ -2700,6 +2707,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
 	dev = get_dev_from_fwnode(fwnode);
 	if (!dev)
 		sync_state = true;
+	else
+		dev_set_drv_sync_state(dev, genpd_sync_state);
 
 	put_device(dev);
 
Signature · 1 line
2.43.0
maintainer
#28 lore raw

Re: [PATCH v3 20/24] pmdomain: core: Default to use of_genpd_sync_state() for genpd providers

Hi Ulf,

Quoted 44 lines · Ulf Hansson

Unless the typical platform driver that act as genpd provider, has its own ->sync_state() callback implemented let's default to use of_genpd_sync_state().

More precisely, while adding a genpd OF provider let's assign the ->sync_state() callback, in case the fwnode has a device and its driver doesn't have the ->sync_state() set already. In this way the typical platform driver doesn't need to assign ->sync_state(), unless it has some additional things to manage beyond genpds.

---
  drivers/pmdomain/core.c | 9 +++++++++
  1 file changed, 9 insertions(+)
drivers/pmdomain/core.c +7 -0
index ca47f91b9e91..5cef6de60c72 100644
@@ -2600,6 +2600,11 @@ static bool genpd_present(const struct generic_pm_domain *genpd)
  	return ret;
  }
 
+static void genpd_sync_state(struct device *dev)
+{
+	return of_genpd_sync_state(dev->of_node);
+}
+
  /**
   * of_genpd_add_provider_simple() - Register a simple PM domain provider
   * @np: Device node pointer associated with the PM domain provider.
@@ -2628,6 +2633,8 @@ int of_genpd_add_provider_simple(struct device_node *np,
  	if (!dev && !genpd_is_no_sync_state(genpd)) {
  		genpd->sync_state = GENPD_SYNC_STATE_SIMPLE;
  		device_set_node(&genpd->dev, fwnode);
+	} else {
+		dev_set_drv_sync_state(dev, genpd_sync_state);
  	}
 
  	put_device(dev);

drivers/pmdomain/core.c int of_genpd_add_provider_onecell(struct device_node *np, · line 2714

Quoted 8 lines
drivers/pmdomain/core.c +2 -0
@@ -2700,6 +2707,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
  	dev = get_dev_from_fwnode(fwnode);
  	if (!dev)
  		sync_state = true;
+	else
+		dev_set_drv_sync_state(dev, genpd_sync_state);
 
  	put_device(dev);
 

Following this change I am seeing the following warning on our Tegra194 devices ...

WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 17000000.gpu WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 3960000.cec WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 15380000.nvjpg WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 154c0000.nvenc WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 15a80000.nvenc

Per your change [0], the 'GENPD_FLAG_NO_SYNC_STATE' is set for Tegra and so should Tegra be using of_genpd_sync_state() by default?

Thanks
Jon

[0] https://lore.kernel.org/all/[email protected]/

Signature · 1 line
nvpublic
#29 lore raw

Re: [PATCH v3 20/24] pmdomain: core: Default to use of_genpd_sync_state() for genpd providers

Quoted 60 lines · Jon Hunter

Hi Ulf,

Quoted 44 lines · Ulf Hansson

Unless the typical platform driver that act as genpd provider, has its own ->sync_state() callback implemented let's default to use of_genpd_sync_state().

More precisely, while adding a genpd OF provider let's assign the ->sync_state() callback, in case the fwnode has a device and its driver doesn't have the ->sync_state() set already. In this way the typical platform driver doesn't need to assign ->sync_state(), unless it has some additional things to manage beyond genpds.

---
  drivers/pmdomain/core.c | 9 +++++++++
  1 file changed, 9 insertions(+)
drivers/pmdomain/core.c +7 -0
index ca47f91b9e91..5cef6de60c72 100644
@@ -2600,6 +2600,11 @@ static bool genpd_present(const struct generic_pm_domain *genpd)
      return ret;
  }
 
+static void genpd_sync_state(struct device *dev)
+{
+     return of_genpd_sync_state(dev->of_node);
+}
+
  /**
   * of_genpd_add_provider_simple() - Register a simple PM domain provider
   * @np: Device node pointer associated with the PM domain provider.
@@ -2628,6 +2633,8 @@ int of_genpd_add_provider_simple(struct device_node *np,
      if (!dev && !genpd_is_no_sync_state(genpd)) {
              genpd->sync_state = GENPD_SYNC_STATE_SIMPLE;
              device_set_node(&genpd->dev, fwnode);
+     } else {
+             dev_set_drv_sync_state(dev, genpd_sync_state);
      }
 
      put_device(dev);

drivers/pmdomain/core.c int of_genpd_add_provider_onecell(struct device_node *np, · line 2714

Quoted 8 lines
drivers/pmdomain/core.c +2 -0
@@ -2700,6 +2707,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
      dev = get_dev_from_fwnode(fwnode);
      if (!dev)
              sync_state = true;
+     else
+             dev_set_drv_sync_state(dev, genpd_sync_state);
 
      put_device(dev);
 

Following this change I am seeing the following warning on our Tegra194 devices ...

Quoted 8 lines

WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 17000000.gpu WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 3960000.cec WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 15380000.nvjpg WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 154c0000.nvenc WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 15a80000.nvenc

Per your change [0], the 'GENPD_FLAG_NO_SYNC_STATE' is set for Tegra and so should Tegra be using of_genpd_sync_state() by default?

This is a different power-domain provider (bpmp) in drivers/firmware/tegra/bpmp.c and drivers/pmdomain/tegra/powergate-bpmp.c.

For the bpmp we don't need GENPD_FLAG_NO_SYNC_STATE, as the power-domain provider is described along with the "nvidia,tegra186-bpmp" compatible string. In the other case (drivers/soc/tegra/pmc.c) the "core-domain" and "powergates" are described through child-nodes, while ->sync_state() is managed by the parent-device-node.

In the bpmp case there is no ->sync_state() callback assigned, which means genpd decides to assign a default one.

The reason for the warnings above is because we are still waiting for those devices to be probed, hence the ->sync_state() callback is still waiting to be invoked. Enforcing ->sync_state() callback to be invoked can be done via user-space if that is needed.

Did that make sense?

Quoted 8 lines

Thanks
Jon

[0] https://lore.kernel.org/all/[email protected]/
--
nvpublic

Kind regards
Uffe

maintainer
#30 lore raw

Re: [PATCH v3 20/24] pmdomain: core: Default to use of_genpd_sync_state() for genpd providers

Hi Ulf,

Quoted 84 lines · Ulf Hansson
Quoted 60 lines · Jon Hunter

Hi Ulf,

Quoted 44 lines · Ulf Hansson

Unless the typical platform driver that act as genpd provider, has its own ->sync_state() callback implemented let's default to use of_genpd_sync_state().

More precisely, while adding a genpd OF provider let's assign the ->sync_state() callback, in case the fwnode has a device and its driver doesn't have the ->sync_state() set already. In this way the typical platform driver doesn't need to assign ->sync_state(), unless it has some additional things to manage beyond genpds.

---
   drivers/pmdomain/core.c | 9 +++++++++
   1 file changed, 9 insertions(+)
drivers/pmdomain/core.c +7 -0
index ca47f91b9e91..5cef6de60c72 100644
@@ -2600,6 +2600,11 @@ static bool genpd_present(const struct generic_pm_domain *genpd)
       return ret;
   }
 
+static void genpd_sync_state(struct device *dev)
+{
+     return of_genpd_sync_state(dev->of_node);
+}
+
   /**
    * of_genpd_add_provider_simple() - Register a simple PM domain provider
    * @np: Device node pointer associated with the PM domain provider.
@@ -2628,6 +2633,8 @@ int of_genpd_add_provider_simple(struct device_node *np,
       if (!dev && !genpd_is_no_sync_state(genpd)) {
               genpd->sync_state = GENPD_SYNC_STATE_SIMPLE;
               device_set_node(&genpd->dev, fwnode);
+     } else {
+             dev_set_drv_sync_state(dev, genpd_sync_state);
       }
 
       put_device(dev);

drivers/pmdomain/core.c int of_genpd_add_provider_onecell(struct device_node *np, · line 2714

Quoted 8 lines
drivers/pmdomain/core.c +2 -0
@@ -2700,6 +2707,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
       dev = get_dev_from_fwnode(fwnode);
       if (!dev)
               sync_state = true;
+     else
+             dev_set_drv_sync_state(dev, genpd_sync_state);
 
       put_device(dev);
 

Following this change I am seeing the following warning on our Tegra194 devices ...

Quoted 8 lines

WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 17000000.gpu WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 3960000.cec WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 15380000.nvjpg WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 154c0000.nvenc WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 15a80000.nvenc

Per your change [0], the 'GENPD_FLAG_NO_SYNC_STATE' is set for Tegra and so should Tegra be using of_genpd_sync_state() by default?

This is a different power-domain provider (bpmp) in drivers/firmware/tegra/bpmp.c and drivers/pmdomain/tegra/powergate-bpmp.c.

For the bpmp we don't need GENPD_FLAG_NO_SYNC_STATE, as the power-domain provider is described along with the "nvidia,tegra186-bpmp" compatible string. In the other case (drivers/soc/tegra/pmc.c) the "core-domain" and "powergates" are described through child-nodes, while ->sync_state() is managed by the parent-device-node.

In the bpmp case there is no ->sync_state() callback assigned, which means genpd decides to assign a default one.

Quoted 6 lines

The reason for the warnings above is because we are still waiting for those devices to be probed, hence the ->sync_state() callback is still waiting to be invoked. Enforcing ->sync_state() callback to be invoked can be done via user-space if that is needed.

Did that make sense?

Sorry for the delay, I was on vacation. Yes makes sense and drivers for some of the above drivers are not yet upstreamed to mainline and so this would be expected for now.

Thanks
Jon

Signature · 1 line
nvpublic
maintainer
#31 lore raw

Re: [PATCH v3 20/24] pmdomain: core: Default to use of_genpd_sync_state() for genpd providers

Hi Ulf,

On 03/09/2025 13:33, Jon Hunter wrote:

...

Quoted 26 lines
Quoted 26 lines
Quoted 11 lines

Following this change I am seeing the following warning on our Tegra194 devices ...

   WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 17000000.gpu WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 3960000.cec WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 15380000.nvjpg WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 154c0000.nvenc WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 15a80000.nvenc

Per your change [0], the 'GENPD_FLAG_NO_SYNC_STATE' is set for Tegra and so should Tegra be using of_genpd_sync_state() by default?

This is a different power-domain provider (bpmp) in drivers/firmware/tegra/bpmp.c and drivers/pmdomain/tegra/powergate-bpmp.c.

For the bpmp we don't need GENPD_FLAG_NO_SYNC_STATE, as the power-domain provider is described along with the "nvidia,tegra186-bpmp" compatible string. In the other case (drivers/soc/tegra/pmc.c) the "core-domain" and "powergates" are described through child-nodes, while ->sync_state() is managed by the parent-device-node.

In the bpmp case there is no ->sync_state() callback assigned, which means genpd decides to assign a default one.

Quoted 8 lines
Quoted 6 lines

The reason for the warnings above is because we are still waiting for those devices to be probed, hence the ->sync_state() callback is still waiting to be invoked. Enforcing ->sync_state() callback to be invoked can be done via user-space if that is needed.

Did that make sense?

Sorry for the delay, I was on vacation. Yes makes sense and drivers for some of the above drivers are not yet upstreamed to mainline and so this would be expected for now.

I have been doing more testing and do see a lot of "tegra-bpmp bpmp: sync_state() pending due to" on our platforms for basically are driver that is built as a module. It seems a bit noisy given that these do eventually probe OK. I am wondering if this should be more of a dev_info() or dev_dbg() print?

Cheers
Jon

Signature · 1 line
nvpublic
#32 lore raw

Re: [PATCH v3 20/24] pmdomain: core: Default to use of_genpd_sync_state() for genpd providers

Quoted 49 lines · Jon Hunter

Hi Ulf,

On 03/09/2025 13:33, Jon Hunter wrote:

...

Quoted 35 lines
Quoted 35 lines
Quoted 13 lines

Following this change I am seeing the following warning on our Tegra194 devices ...

WARNING KERN tegra-bpmp bpmp: sync_state() pending due to
17000000.gpu
WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 3960000.cec WARNING KERN tegra-bpmp bpmp: sync_state() pending due to
15380000.nvjpg
WARNING KERN tegra-bpmp bpmp: sync_state() pending due to
154c0000.nvenc
WARNING KERN tegra-bpmp bpmp: sync_state() pending due to
15a80000.nvenc

Quoted 2 lines

Per your change [0], the 'GENPD_FLAG_NO_SYNC_STATE' is set for Tegra and so should Tegra be using of_genpd_sync_state() by default?

This is a different power-domain provider (bpmp) in drivers/firmware/tegra/bpmp.c and drivers/pmdomain/tegra/powergate-bpmp.c.

For the bpmp we don't need GENPD_FLAG_NO_SYNC_STATE, as the power-domain provider is described along with the "nvidia,tegra186-bpmp" compatible string. In the other case (drivers/soc/tegra/pmc.c) the "core-domain" and "powergates" are described through child-nodes, while ->sync_state() is managed by the parent-device-node.

In the bpmp case there is no ->sync_state() callback assigned, which means genpd decides to assign a default one.

The reason for the warnings above is because we are still waiting for those devices to be probed, hence the ->sync_state() callback is still waiting to be invoked. Enforcing ->sync_state() callback to be invoked can be done via user-space if that is needed.

Quoted 5 lines
Quoted 1 line

Did that make sense?

Sorry for the delay, I was on vacation. Yes makes sense and drivers for some of the above drivers are not yet upstreamed to mainline and so this would be expected for now.

Quoted 5 lines

I have been doing more testing and do see a lot of "tegra-bpmp bpmp:
sync_state() pending due to" on our platforms for basically are driver that is built as a module. It seems a bit noisy given that these do eventually probe OK. I am wondering if this should be more of a dev_info() or dev_dbg() print?

Yes, I agree. We have had similar reports for other platforms too.

I intend to send a patch for this in the next day or so.

Kind regards
Uffe

maintainer
#33 lore raw

Re: [PATCH v3 20/24] pmdomain: core: Default to use of_genpd_sync_state() for genpd providers

Quoted 56 lines · Ulf Hansson
Quoted 49 lines · Jon Hunter

Hi Ulf,

On 03/09/2025 13:33, Jon Hunter wrote:

...

Quoted 35 lines
Quoted 35 lines
Quoted 13 lines

Following this change I am seeing the following warning on our Tegra194 devices ...

WARNING KERN tegra-bpmp bpmp: sync_state() pending due to
17000000.gpu
WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 3960000.cec WARNING KERN tegra-bpmp bpmp: sync_state() pending due to
15380000.nvjpg
WARNING KERN tegra-bpmp bpmp: sync_state() pending due to
154c0000.nvenc
WARNING KERN tegra-bpmp bpmp: sync_state() pending due to
15a80000.nvenc

Quoted 2 lines

Per your change [0], the 'GENPD_FLAG_NO_SYNC_STATE' is set for Tegra and so should Tegra be using of_genpd_sync_state() by default?

This is a different power-domain provider (bpmp) in drivers/firmware/tegra/bpmp.c and drivers/pmdomain/tegra/powergate-bpmp.c.

For the bpmp we don't need GENPD_FLAG_NO_SYNC_STATE, as the power-domain provider is described along with the "nvidia,tegra186-bpmp" compatible string. In the other case (drivers/soc/tegra/pmc.c) the "core-domain" and "powergates" are described through child-nodes, while ->sync_state() is managed by the parent-device-node.

In the bpmp case there is no ->sync_state() callback assigned, which means genpd decides to assign a default one.

The reason for the warnings above is because we are still waiting for those devices to be probed, hence the ->sync_state() callback is still waiting to be invoked. Enforcing ->sync_state() callback to be invoked can be done via user-space if that is needed.

Quoted 5 lines
Quoted 1 line

Did that make sense?

Sorry for the delay, I was on vacation. Yes makes sense and drivers for some of the above drivers are not yet upstreamed to mainline and so this would be expected for now.

Quoted 5 lines

I have been doing more testing and do see a lot of "tegra-bpmp bpmp:
sync_state() pending due to" on our platforms for basically are driver that is built as a module. It seems a bit noisy given that these do eventually probe OK. I am wondering if this should be more of a dev_info() or dev_dbg() print?

Quoted 3 lines

Yes, I agree. We have had similar reports for other platforms too.

I intend to send a patch for this in the next day or so.

OK great! Please CC me and I will be happy to test.

Cheers
Jon

Signature · 1 line
nvpublic
#34 lore raw

Re: [PATCH v3 20/24] pmdomain: core: Default to use of_genpd_sync_state() for genpd providers

In reply to Jon Hunter
Quoted 44 lines · Jon Hunter

Hi Ulf,

On 03/09/2025 13:33, Jon Hunter wrote:

...

Quoted 37 lines
Quoted 36 lines
Quoted 13 lines

Following this change I am seeing the following warning on our Tegra194 devices ...

WARNING KERN tegra-bpmp bpmp: sync_state() pending due to
17000000.gpu
WARNING KERN tegra-bpmp bpmp: sync_state() pending due to 3960000.cec WARNING KERN tegra-bpmp bpmp: sync_state() pending due to
15380000.nvjpg
WARNING KERN tegra-bpmp bpmp: sync_state() pending due to
154c0000.nvenc
WARNING KERN tegra-bpmp bpmp: sync_state() pending due to
15a80000.nvenc

Quoted 2 lines

Per your change [0], the 'GENPD_FLAG_NO_SYNC_STATE' is set for Tegra and so should Tegra be using of_genpd_sync_state() by default?

This is a different power-domain provider (bpmp) in drivers/firmware/tegra/bpmp.c and drivers/pmdomain/tegra/powergate-bpmp.c.

For the bpmp we don't need GENPD_FLAG_NO_SYNC_STATE, as the power-domain provider is described along with the "nvidia,tegra186-bpmp" compatible string. In the other case (drivers/soc/tegra/pmc.c) the "core-domain" and "powergates" are described through child-nodes, while ->sync_state() is managed by the parent-device-node.

In the bpmp case there is no ->sync_state() callback assigned, which means genpd decides to assign a default one.

The reason for the warnings above is because we are still waiting for those devices to be probed, hence the ->sync_state() callback is still waiting to be invoked. Enforcing ->sync_state() callback to be invoked can be done via user-space if that is needed.

Did that make sense?

Quoted 8 lines
Quoted 3 lines

Sorry for the delay, I was on vacation. Yes makes sense and drivers for some of the above drivers are not yet upstreamed to mainline and so this would be expected for now.

I have been doing more testing and do see a lot of "tegra-bpmp bpmp:
sync_state() pending due to" on our platforms for basically are driver that is built as a module.

It being "built as a module" is not reason enough for this warning to happen though. One of the main points of fw_devlink is for things to work just as well with modules.

In this particular system, do you never plan to load the modules? Or is the module load just missing this timeout by a few seconds or something?

If these can be turned off, why not turn these off using the sysfs file or the timeout commandline option to turn them off? You are burning power by leaving these on. A warning seems appropriate to me.

-Saravana

maintainer
#35 lore raw

Re: [PATCH v3 20/24] pmdomain: core: Default to use of_genpd_sync_state() for genpd providers

On 25/09/2025 23:31, Saravana Kannan wrote:

...

Quoted 11 lines
Quoted 3 lines

I have been doing more testing and do see a lot of "tegra-bpmp bpmp:
sync_state() pending due to" on our platforms for basically are driver that is built as a module.

It being "built as a module" is not reason enough for this warning to happen though. One of the main points of fw_devlink is for things to work just as well with modules.

In this particular system, do you never plan to load the modules? Or is the module load just missing this timeout by a few seconds or something?

We absolutely do load the drivers. Initially, I observed cases where drivers are missing, but doing more testing with the necessary drivers present, I still see such messages. A lot of our test infrastructure is set up to use NFS for mounting to the rootfs and so I am wondering if that can also be a factor?

Quoted 3 lines

If these can be turned off, why not turn these off using the sysfs file or the timeout commandline option to turn them off? You are burning power by leaving these on. A warning seems appropriate to me.

Again the drivers get loaded, so that shouldn't be the case.

Jon

Signature · 1 line
nvpublic
#36 lore raw

Re: [PATCH v3 20/24] pmdomain: core: Default to use of_genpd_sync_state() for genpd providers

Quoted 24 lines · Jon Hunter

On 25/09/2025 23:31, Saravana Kannan wrote:

...

Quoted 11 lines
Quoted 3 lines

I have been doing more testing and do see a lot of "tegra-bpmp bpmp:
sync_state() pending due to" on our platforms for basically are driver that is built as a module.

It being "built as a module" is not reason enough for this warning to happen though. One of the main points of fw_devlink is for things to work just as well with modules.

In this particular system, do you never plan to load the modules? Or is the module load just missing this timeout by a few seconds or something?

We absolutely do load the drivers. Initially, I observed cases where drivers are missing, but doing more testing with the necessary drivers present, I still see such messages. A lot of our test infrastructure is set up to use NFS for mounting to the rootfs and so I am wondering if that can also be a factor?

Quoted 6 lines
Quoted 3 lines

If these can be turned off, why not turn these off using the sysfs file or the timeout commandline option to turn them off? You are burning power by leaving these on. A warning seems appropriate to me.

Again the drivers get loaded, so that shouldn't be the case.

I realized that we also have an orthogonal, but related problem.

In fact, the genpd in question actually may already have been powered-off, completely defeating the purpose of the printed warning that we are discussing.

In genpd we enable the ->sync_state() support, no matter whether the genpd is powered-on or powered-off at initialization. Although, it's only when a genpd is powered-on at init, when we prevent it from being powered-off until the ->sync_state() callback gets invoked. Ideally, we should be able to skip enabling the ->sync_state() support for genpd in these cases, possibly silencing some of these prints. I will have a look at this and get back to you.

Kind regards
Uffe

#37 lore raw

PATCH v3 21/24 pmdomain: core: Leave powered-on genpds on until late_initcall_sync

In reply to Ulf Hansson

Powering-off a genpd that was on during boot, before all of its consumer devices have been probed, is certainly prone to problems.

As a step to improve this situation, let's prevent these genpds from being powered-off until genpd_power_off_unused() gets called, which is a late_initcall_sync().

Note that, this still doesn't guarantee that all the consumer devices has been probed before we allow to power-off the genpds. Yet, this should be a step in the right direction.

---
 drivers/pmdomain/core.c   | 10 ++++++++--
 include/linux/pm_domain.h |  1 +
 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/pmdomain/core.c +8 -2
index 5cef6de60c72..18951ed6295d 100644
@@ -931,11 +931,12 @@ static void genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
 	 * The domain is already in the "power off" state.
 	 * System suspend is in progress.
 	 * The domain is configured as always on.
+	 * The domain was on at boot and still need to stay on.
 	 * The domain has a subdomain being powered on.
 	 */
 	if (!genpd_status_on(genpd) || genpd->prepared_count > 0 ||
 	    genpd_is_always_on(genpd) || genpd_is_rpm_always_on(genpd) ||
-	    atomic_read(&genpd->sd_count) > 0)
+	    genpd->stay_on || atomic_read(&genpd->sd_count) > 0)
 		return;
 
 	/*
@@ -1346,8 +1347,12 @@ static int __init genpd_power_off_unused(void)
 	pr_info("genpd: Disabling unused power domains\n");
 	mutex_lock(&gpd_list_lock);
 
-	list_for_each_entry(genpd, &gpd_list, gpd_list_node)
+	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);
+	}
 
 	mutex_unlock(&gpd_list_lock);
 
@@ -2352,6 +2357,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->sync_state = GENPD_SYNC_STATE_OFF;
 	genpd->device_count = 0;
 	genpd->provider = NULL;
include/linux/pm_domain.h +1 -0
index d68e07dadc99..99556589f45e 100644
@@ -199,6 +199,7 @@ struct generic_pm_domain {
 	unsigned int performance_state;	/* Aggregated max performance state */
 	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. */
 	enum genpd_sync_state sync_state; /* How sync_state is managed. */
 	int (*power_off)(struct generic_pm_domain *domain);
 	int (*power_on)(struct generic_pm_domain *domain);
Signature · 1 line
2.43.0
#38 lore raw

Re: [PATCH v3 21/24] pmdomain: core: Leave powered-on genpds on until late_initcall_sync

Quoted 7 lines · Ulf Hansson

Powering-off a genpd that was on during boot, before all of its consumer devices have been probed, is certainly prone to problems.

As a step to improve this situation, let's prevent these genpds from being powered-off until genpd_power_off_unused() gets called, which is a late_initcall_sync().

Quoted 8 lines

Note that, this still doesn't guarantee that all the consumer devices has been probed before we allow to power-off the genpds. Yet, this should be a step in the right direction.

This change has a side effect on some Exynos based boards, which have display and bootloader is configured to setup a splash screen on it. Since today's linux-next, those boards fails to boot, because of the IOMMU page fault.

This happens because the display controller is enabled and configured to perform the scanout from the spash-screen buffer until the respective driver will reset it in driver probe() function. This however doesn't work with IOMMU, which is being probed earlier than the display controller driver, what in turn causes IOMMU page fault once the IOMMU driver gets attached. This worked before applying this patch, because the power domain of display controller was simply turned off early effectively reseting the display controller.

This has been discussed a bit recently:
https://lore.kernel.org/all/[email protected]/
and I can add a workaround for this issue in the bootloaders of those boards, but this is something that has to be somehow addressed in a generic way.

Quoted 50 lines
---
  drivers/pmdomain/core.c   | 10 ++++++++--
  include/linux/pm_domain.h |  1 +
  2 files changed, 9 insertions(+), 2 deletions(-)
drivers/pmdomain/core.c +8 -2
index 5cef6de60c72..18951ed6295d 100644
@@ -931,11 +931,12 @@ static void genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
  	 * The domain is already in the "power off" state.
  	 * System suspend is in progress.
  	 * The domain is configured as always on.
+	 * The domain was on at boot and still need to stay on.
  	 * The domain has a subdomain being powered on.
  	 */
  	if (!genpd_status_on(genpd) || genpd->prepared_count > 0 ||
  	    genpd_is_always_on(genpd) || genpd_is_rpm_always_on(genpd) ||
-	    atomic_read(&genpd->sd_count) > 0)
+	    genpd->stay_on || atomic_read(&genpd->sd_count) > 0)
  		return;
 
  	/*
@@ -1346,8 +1347,12 @@ static int __init genpd_power_off_unused(void)
  	pr_info("genpd: Disabling unused power domains\n");
  	mutex_lock(&gpd_list_lock);
 
-	list_for_each_entry(genpd, &gpd_list, gpd_list_node)
+	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);
+	}
 
  	mutex_unlock(&gpd_list_lock);
 
@@ -2352,6 +2357,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->sync_state = GENPD_SYNC_STATE_OFF;
  	genpd->device_count = 0;
  	genpd->provider = NULL;
include/linux/pm_domain.h +0 -0
index d68e07dadc99..99556589f45e 100644

include/linux/pm_domain.h struct generic_pm_domain { · line 205

Quoted 7 lines
include/linux/pm_domain.h +1 -0
@@ -199,6 +199,7 @@ struct generic_pm_domain {
  	unsigned int performance_state;	/* Aggregated max performance state */
  	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. */
  	enum genpd_sync_state sync_state; /* How sync_state is managed. */
  	int (*power_off)(struct generic_pm_domain *domain);
  	int (*power_on)(struct generic_pm_domain *domain);

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
#39 lore raw

Re: [PATCH v3 21/24] pmdomain: core: Leave powered-on genpds on until late_initcall_sync

Quoted 18 lines · Marek Szyprowski
Quoted 7 lines · Ulf Hansson

Powering-off a genpd that was on during boot, before all of its consumer devices have been probed, is certainly prone to problems.

As a step to improve this situation, let's prevent these genpds from being powered-off until genpd_power_off_unused() gets called, which is a late_initcall_sync().

Quoted 8 lines

Note that, this still doesn't guarantee that all the consumer devices has been probed before we allow to power-off the genpds. Yet, this should be a step in the right direction.

Quoted 4 lines

This change has a side effect on some Exynos based boards, which have display and bootloader is configured to setup a splash screen on it. Since today's linux-next, those boards fails to boot, because of the IOMMU page fault.

Thanks for reporting, let's try to fix this as soon as possible then.

Quoted 9 lines

This happens because the display controller is enabled and configured to perform the scanout from the spash-screen buffer until the respective driver will reset it in driver probe() function. This however doesn't work with IOMMU, which is being probed earlier than the display controller driver, what in turn causes IOMMU page fault once the IOMMU driver gets attached. This worked before applying this patch, because the power domain of display controller was simply turned off early effectively reseting the display controller.

I can certainly try to help to find a solution, but I believe I need some more details of what is happening.

Perhaps you can point me to some relevant DTS file to start with?

Quoted 6 lines

This has been discussed a bit recently:
https://lore.kernel.org/all/[email protected]/
and I can add a workaround for this issue in the bootloaders of those boards, but this is something that has to be somehow addressed in a generic way.

It kind of sounds like there is a missing power-domain not being described in DT for the IOMMU, but I might have understood the whole thing wrong.

Let's see if we can work something out in the next few days, otherwise we need to find another way to let some genpds for these platforms to opt out from this new behaviour.

Kind regards
Uffe

Quoted 64 lines
Quoted 51 lines
---
  drivers/pmdomain/core.c   | 10 ++++++++--
  include/linux/pm_domain.h |  1 +
  2 files changed, 9 insertions(+), 2 deletions(-)
drivers/pmdomain/core.c +8 -2
index 5cef6de60c72..18951ed6295d 100644
@@ -931,11 +931,12 @@ static void genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
       * The domain is already in the "power off" state.
       * System suspend is in progress.
       * The domain is configured as always on.
+      * The domain was on at boot and still need to stay on.
       * The domain has a subdomain being powered on.
       */
      if (!genpd_status_on(genpd) || genpd->prepared_count > 0 ||
          genpd_is_always_on(genpd) || genpd_is_rpm_always_on(genpd) ||
-         atomic_read(&genpd->sd_count) > 0)
+         genpd->stay_on || atomic_read(&genpd->sd_count) > 0)
              return;
 
      /*
@@ -1346,8 +1347,12 @@ static int __init genpd_power_off_unused(void)
      pr_info("genpd: Disabling unused power domains\n");
      mutex_lock(&gpd_list_lock);
 
-     list_for_each_entry(genpd, &gpd_list, gpd_list_node)
+     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);
+     }
 
      mutex_unlock(&gpd_list_lock);
 
@@ -2352,6 +2357,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->sync_state = GENPD_SYNC_STATE_OFF;
      genpd->device_count = 0;
      genpd->provider = NULL;
include/linux/pm_domain.h +0 -0
index d68e07dadc99..99556589f45e 100644

include/linux/pm_domain.h struct generic_pm_domain { · line 205

Quoted 7 lines
include/linux/pm_domain.h +1 -0
@@ -199,6 +199,7 @@ struct generic_pm_domain {
      unsigned int performance_state; /* Aggregated max performance state */
      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. */
      enum genpd_sync_state sync_state; /* How sync_state is managed. */
      int (*power_off)(struct generic_pm_domain *domain);
      int (*power_on)(struct generic_pm_domain *domain);

Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland

maintainer
#40 lore raw

Re: [PATCH v3 21/24] pmdomain: core: Leave powered-on genpds on until late_initcall_sync

Hi Ulf,

Quoted 48 lines · Ulf Hansson
Quoted 18 lines · Marek Szyprowski
Quoted 7 lines · Ulf Hansson

Powering-off a genpd that was on during boot, before all of its consumer devices have been probed, is certainly prone to problems.

As a step to improve this situation, let's prevent these genpds from being powered-off until genpd_power_off_unused() gets called, which is a late_initcall_sync().

Quoted 8 lines

Note that, this still doesn't guarantee that all the consumer devices has been probed before we allow to power-off the genpds. Yet, this should be a step in the right direction.

Quoted 4 lines

This change has a side effect on some Exynos based boards, which have display and bootloader is configured to setup a splash screen on it. Since today's linux-next, those boards fails to boot, because of the IOMMU page fault.

Thanks for reporting, let's try to fix this as soon as possible then.

Quoted 9 lines

This happens because the display controller is enabled and configured to perform the scanout from the spash-screen buffer until the respective driver will reset it in driver probe() function. This however doesn't work with IOMMU, which is being probed earlier than the display controller driver, what in turn causes IOMMU page fault once the IOMMU driver gets attached. This worked before applying this patch, because the power domain of display controller was simply turned off early effectively reseting the display controller.

I can certainly try to help to find a solution, but I believe I need some more details of what is happening.

Perhaps you can point me to some relevant DTS file to start with?

Quoted 6 lines

This has been discussed a bit recently:
https://lore.kernel.org/all/[email protected]/
and I can add a workaround for this issue in the bootloaders of those boards, but this is something that has to be somehow addressed in a generic way.

Quoted 7 lines

It kind of sounds like there is a missing power-domain not being described in DT for the IOMMU, but I might have understood the whole thing wrong.

Let's see if we can work something out in the next few days, otherwise we need to find another way to let some genpds for these platforms to opt out from this new behaviour.

Have you found any resolution for this? I have also noticed a boot regression on one of our Tegra210 boards and bisect is pointing to this commit. I don't see any particular crash, but a hang on boot.

If there is any debug we can enable to see which pmdomain is the problem let me know.

Thanks!
Jon

Signature · 1 line
nvpublic
#41 lore raw

Re: [PATCH v3 21/24] pmdomain: core: Leave powered-on genpds on until late_initcall_sync

Quoted 56 lines · Jon Hunter

Hi Ulf,

Quoted 52 lines · Ulf Hansson
Quoted 18 lines · Marek Szyprowski
Quoted 7 lines · Ulf Hansson

Powering-off a genpd that was on during boot, before all of its consumer devices have been probed, is certainly prone to problems.

As a step to improve this situation, let's prevent these genpds from being powered-off until genpd_power_off_unused() gets called, which is a late_initcall_sync().

Quoted 8 lines

Note that, this still doesn't guarantee that all the consumer devices has been probed before we allow to power-off the genpds. Yet, this should be a step in the right direction.

Quoted 4 lines

This change has a side effect on some Exynos based boards, which have display and bootloader is configured to setup a splash screen on it. Since today's linux-next, those boards fails to boot, because of the IOMMU page fault.

Thanks for reporting, let's try to fix this as soon as possible then.

Quoted 9 lines

This happens because the display controller is enabled and configured to perform the scanout from the spash-screen buffer until the respective driver will reset it in driver probe() function. This however doesn't work with IOMMU, which is being probed earlier than the display controller driver, what in turn causes IOMMU page fault once the IOMMU driver gets attached. This worked before applying this patch, because the power domain of display controller was simply turned off early effectively reseting the display controller.

I can certainly try to help to find a solution, but I believe I need some more details of what is happening.

Perhaps you can point me to some relevant DTS file to start with?

Quoted 6 lines

This has been discussed a bit recently:
https://lore.kernel.org/all/[email protected]/
and I can add a workaround for this issue in the bootloaders of those boards, but this is something that has to be somehow addressed in a generic way.

It kind of sounds like there is a missing power-domain not being described in DT for the IOMMU, but I might have understood the whole thing wrong.

Quoted 7 lines
Quoted 3 lines

Let's see if we can work something out in the next few days, otherwise we need to find another way to let some genpds for these platforms to opt out from this new behaviour.

Have you found any resolution for this? I have also noticed a boot regression on one of our Tegra210 boards and bisect is pointing to this commit. I don't see any particular crash, but a hang on boot.

Thanks for reporting!

For Exynos we opt-out from the behaviour by enforcing a sync_state of all PM domains upfront [1], which means before any devices get attached.

Even if that defeats the purpose of the $subject series, this was one way forward that solved the problem. When the boot-ordering problem (that's how I understood the issue) for Exynos gets resolved, we should be able to drop the hack, at least that's the idea.

Quoted 3 lines

If there is any debug we can enable to see which pmdomain is the problem let me know.

There aren't many debug prints in genpd that I think makes much sense to enable, but you can always give it a try. Since you are hanging, obviously you can't look at the genpd debugfs data...

Note that, the interesting PM domains are those that are powered-on when calling pm_genpd_init(). As a start, I would add some debug prints in () to see which PM domains that are relevant to track. Potentially you could then try to power them off and register them accordingly with genpd. One by one, to see which of them is causing the problem.

Another option could be to add a new genpd config flag (GENPD_FLAG_DONT_STAY_ON or something along those lines), that informs genpd to not set the genpd->stay_on in pm_genpd_init(). Then tegra_powergate_add() would have to set GENPD_FLAG_DONT_STAY_ON for those genpds that really need it.

Kind regards
Uffe

[1]
https://lore.kernel.org/all/[email protected]/

#42 lore raw

Re: [PATCH v3 21/24] pmdomain: core: Leave powered-on genpds on until late_initcall_sync

Quoted 81 lines · Ulf Hansson
Quoted 56 lines · Jon Hunter

Hi Ulf,

Quoted 52 lines · Ulf Hansson
Quoted 18 lines · Marek Szyprowski
Quoted 7 lines · Ulf Hansson

Powering-off a genpd that was on during boot, before all of its consumer devices have been probed, is certainly prone to problems.

As a step to improve this situation, let's prevent these genpds from being powered-off until genpd_power_off_unused() gets called, which is a late_initcall_sync().

Quoted 8 lines

Note that, this still doesn't guarantee that all the consumer devices has been probed before we allow to power-off the genpds. Yet, this should be a step in the right direction.

Quoted 4 lines

This change has a side effect on some Exynos based boards, which have display and bootloader is configured to setup a splash screen on it. Since today's linux-next, those boards fails to boot, because of the IOMMU page fault.

Thanks for reporting, let's try to fix this as soon as possible then.

Quoted 9 lines

This happens because the display controller is enabled and configured to perform the scanout from the spash-screen buffer until the respective driver will reset it in driver probe() function. This however doesn't work with IOMMU, which is being probed earlier than the display controller driver, what in turn causes IOMMU page fault once the IOMMU driver gets attached. This worked before applying this patch, because the power domain of display controller was simply turned off early effectively reseting the display controller.

I can certainly try to help to find a solution, but I believe I need some more details of what is happening.

Perhaps you can point me to some relevant DTS file to start with?

Quoted 6 lines

This has been discussed a bit recently:
https://lore.kernel.org/all/[email protected]/
and I can add a workaround for this issue in the bootloaders of those boards, but this is something that has to be somehow addressed in a generic way.

It kind of sounds like there is a missing power-domain not being described in DT for the IOMMU, but I might have understood the whole thing wrong.

Quoted 7 lines
Quoted 3 lines

Let's see if we can work something out in the next few days, otherwise we need to find another way to let some genpds for these platforms to opt out from this new behaviour.

Have you found any resolution for this? I have also noticed a boot regression on one of our Tegra210 boards and bisect is pointing to this commit. I don't see any particular crash, but a hang on boot.

Thanks for reporting!

For Exynos we opt-out from the behaviour by enforcing a sync_state of all PM domains upfront [1], which means before any devices get attached.

Even if that defeats the purpose of the $subject series, this was one way forward that solved the problem. When the boot-ordering problem (that's how I understood the issue) for Exynos gets resolved, we should be able to drop the hack, at least that's the idea.

Quoted 3 lines

If there is any debug we can enable to see which pmdomain is the problem let me know.

Quoted 7 lines

There aren't many debug prints in genpd that I think makes much sense to enable, but you can always give it a try. Since you are hanging, obviously you can't look at the genpd debugfs data...

Note that, the interesting PM domains are those that are powered-on when calling pm_genpd_init(). As a start, I would add some debug prints in () to see which PM domains that are relevant to track.

/s/()/tegra_powergate_add()

Quoted 15 lines

Potentially you could then try to power them off and register them accordingly with genpd. One by one, to see which of them is causing the problem.

Another option could be to add a new genpd config flag (GENPD_FLAG_DONT_STAY_ON or something along those lines), that informs genpd to not set the genpd->stay_on in pm_genpd_init(). Then tegra_powergate_add() would have to set GENPD_FLAG_DONT_STAY_ON for those genpds that really need it.

Kind regards
Uffe

[1]
https://lore.kernel.org/all/[email protected]/

maintainer
#43 lore raw

Re: [PATCH v3 21/24] pmdomain: core: Leave powered-on genpds on until late_initcall_sync

On 15/07/2025 12:34, Ulf Hansson wrote:

...

Quoted 23 lines
Quoted 23 lines
Quoted 3 lines

Have you found any resolution for this? I have also noticed a boot regression on one of our Tegra210 boards and bisect is pointing to this commit. I don't see any particular crash, but a hang on boot.

Thanks for reporting!

For Exynos we opt-out from the behaviour by enforcing a sync_state of all PM domains upfront [1], which means before any devices get attached.

Even if that defeats the purpose of the $subject series, this was one way forward that solved the problem. When the boot-ordering problem (that's how I understood the issue) for Exynos gets resolved, we should be able to drop the hack, at least that's the idea.

Quoted 3 lines

If there is any debug we can enable to see which pmdomain is the problem let me know.

There aren't many debug prints in genpd that I think makes much sense to enable, but you can always give it a try. Since you are hanging, obviously you can't look at the genpd debugfs data...

Quoted 5 lines
Quoted 3 lines

Note that, the interesting PM domains are those that are powered-on when calling pm_genpd_init(). As a start, I would add some debug prints in () to see which PM domains that are relevant to track.

/s/()/tegra_powergate_add()

I have been able to track this down to a problem in the Tegra PMC driver where we are registering the power-domains and I have sent a fix [0]. Looks like we have been getting lucky up until now.

Cheers!
Jon

[0] https://lore.kernel.org/linux-tegra/[email protected]/T/#u

Signature · 1 line
nvpublic
#44 lore raw

PATCH v3 22/24 pmdomain: core: Leave powered-on genpds on until sync_state

In reply to Ulf Hansson

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.

---
 drivers/pmdomain/core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/pmdomain/core.c +4 -0
index 18951ed6295d..a86aeda1c955 100644
@@ -1324,6 +1324,7 @@ 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)
 {
@@ -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;
Signature · 1 line
2.43.0
#45 lore raw

PATCH v3 23/24 cpuidle: psci: Drop redundant sync_state support

In reply to Ulf Hansson

The recent updates to the genpd core, can entirely manage the sync_state support for the cpuidle-psci-domain. More precisely, genpd prevents our ->power_off() callback from being invoked, until all of our consumers are ready for it.

Let's therefore drop the sync_state support for the cpuidle-psci-domain as it has become redundant.

---
 drivers/cpuidle/cpuidle-psci-domain.c | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)
drivers/cpuidle/cpuidle-psci-domain.c +1 -21
index b880ce2df8b5..37c41209eaf9 100644
@@ -28,7 +28,6 @@ struct psci_pd_provider {
 };
 
 static LIST_HEAD(psci_pd_providers);
-static bool psci_pd_allow_domain_state;
 
 static int psci_pd_power_off(struct generic_pm_domain *pd)
 {
@@ -38,9 +37,6 @@ static int psci_pd_power_off(struct generic_pm_domain *pd)
 	if (!state->data)
 		return 0;
 
-	if (!psci_pd_allow_domain_state)
-		return -EBUSY;
-
 	/* OSI mode is enabled, set the corresponding domain state. */
 	pd_state = state->data;
 	psci_set_domain_state(pd, pd->state_idx, *pd_state);
@@ -63,8 +59,7 @@ static int psci_pd_init(struct device_node *np, bool use_osi)
 	if (!pd_provider)
 		goto free_pd;
 
-	pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN |
-		     GENPD_FLAG_NO_SYNC_STATE;
+	pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN;
 
 	/*
 	 * Allow power off when OSI has been successfully enabled.
@@ -127,20 +122,6 @@ static void psci_pd_remove(void)
 	}
 }
 
-static void psci_cpuidle_domain_sync_state(struct device *dev)
-{
-	struct psci_pd_provider *pd_provider;
-
-	/*
-	 * All devices have now been attached/probed to the PM domain topology,
-	 * hence it's fine to allow domain states to be picked.
-	 */
-	psci_pd_allow_domain_state = true;
-
-	list_for_each_entry(pd_provider, &psci_pd_providers, link)
-		of_genpd_sync_state(pd_provider->node);
-}
-
 static const struct of_device_id psci_of_match[] = {
 	{ .compatible = "arm,psci-1.0" },
 	{}
@@ -201,7 +182,6 @@ static struct platform_driver psci_cpuidle_domain_driver = {
 	.driver = {
 		.name = "psci-cpuidle-domain",
 		.of_match_table = psci_of_match,
-		.sync_state = psci_cpuidle_domain_sync_state,
 	},
 };
 
Signature · 1 line
2.43.0
#46 lore raw

PATCH v3 24/24 cpuidle: riscv-sbi: Drop redundant sync_state support

In reply to Ulf Hansson

The recent updates to the genpd core, can entirely manage the sync_state support for the cpuidle-riscv-sbi-domain. More precisely, genpd prevents our ->power_off() callback from being invoked, until all of our consumers are ready for it.

Let's therefore drop the sync_state support for the cpuidle-riscv-sbi-domain as it has become redundant.

---
 drivers/cpuidle/cpuidle-riscv-sbi.c | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)
drivers/cpuidle/cpuidle-riscv-sbi.c +1 -21
index 83d58d00872f..a360bc4d20b7 100644
@@ -44,7 +44,6 @@ static DEFINE_PER_CPU_READ_MOSTLY(struct sbi_cpuidle_data, sbi_cpuidle_data);
 static DEFINE_PER_CPU(struct sbi_domain_state, domain_state);
 static bool sbi_cpuidle_use_osi;
 static bool sbi_cpuidle_use_cpuhp;
-static bool sbi_cpuidle_pd_allow_domain_state;
 
 static inline void sbi_set_domain_state(u32 state)
 {
@@ -345,20 +344,6 @@ static int sbi_cpuidle_init_cpu(struct device *dev, int cpu)
 	return ret;
 }
 
-static void sbi_cpuidle_domain_sync_state(struct device *dev)
-{
-	struct sbi_pd_provider *pd_provider;
-
-	/*
-	 * All devices have now been attached/probed to the PM domain
-	 * topology, hence it's fine to allow domain states to be picked.
-	 */
-	sbi_cpuidle_pd_allow_domain_state = true;
-
-	list_for_each_entry(pd_provider, &sbi_pd_providers, link)
-		of_genpd_sync_state(pd_provider->node);
-}
-
 #ifdef CONFIG_DT_IDLE_GENPD
 
 static int sbi_cpuidle_pd_power_off(struct generic_pm_domain *pd)
@@ -369,9 +354,6 @@ static int sbi_cpuidle_pd_power_off(struct generic_pm_domain *pd)
 	if (!state->data)
 		return 0;
 
-	if (!sbi_cpuidle_pd_allow_domain_state)
-		return -EBUSY;
-
 	/* OSI mode is enabled, set the corresponding domain state. */
 	pd_state = state->data;
 	sbi_set_domain_state(*pd_state);
@@ -401,8 +383,7 @@ static int sbi_pd_init(struct device_node *np)
 	if (!pd_provider)
 		goto free_pd;
 
-	pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN |
-		     GENPD_FLAG_NO_SYNC_STATE;
+	pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN;
 
 	/* Allow power off when OSI is available. */
 	if (sbi_cpuidle_use_osi)
@@ -570,7 +551,6 @@ static struct platform_driver sbi_cpuidle_driver = {
 	.probe = sbi_cpuidle_probe,
 	.driver = {
 		.name = "sbi-cpuidle",
-		.sync_state = sbi_cpuidle_domain_sync_state,
 	},
 };
 
Signature · 1 line
2.43.0
Reviewed-by on v3 24/24
#47 lore raw

Re: [PATCH v3 24/24] cpuidle: riscv-sbi: Drop redundant sync_state support

Quoted 9 lines · Ulf Hansson

The recent updates to the genpd core, can entirely manage the sync_state support for the cpuidle-riscv-sbi-domain. More precisely, genpd prevents our ->power_off() callback from being invoked, until all of our consumers are ready for it.

Let's therefore drop the sync_state support for the cpuidle-riscv-sbi-domain as it has become redundant.

Quoted 9 lines
---
 drivers/cpuidle/cpuidle-riscv-sbi.c | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)

LGTM

maintainer Reviewed-by on v3 24/24
#48 lore raw

Re: [PATCH v3 24/24] cpuidle: riscv-sbi: Drop redundant sync_state support

In reply to Ulf Hansson
Quoted 6 lines · Ulf Hansson

The recent updates to the genpd core, can entirely manage the sync_state support for the cpuidle-riscv-sbi-domain. More precisely, genpd prevents our ->power_off() callback from being invoked, until all of our consumers are ready for it.

Quoted 8 lines

Let's therefore drop the sync_state support for the cpuidle-riscv-sbi-domain as it has become redundant.

LGTM.

Regards,
Anup

Quoted 68 lines
---
 drivers/cpuidle/cpuidle-riscv-sbi.c | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)
drivers/cpuidle/cpuidle-riscv-sbi.c +1 -22
index 83d58d00872f..a360bc4d20b7 100644
@@ -44,7 +44,6 @@ static DEFINE_PER_CPU_READ_MOSTLY(struct sbi_cpuidle_data, sbi_cpuidle_data);
 static DEFINE_PER_CPU(struct sbi_domain_state, domain_state);
 static bool sbi_cpuidle_use_osi;
 static bool sbi_cpuidle_use_cpuhp;
-static bool sbi_cpuidle_pd_allow_domain_state;
 
 static inline void sbi_set_domain_state(u32 state)
 {
@@ -345,20 +344,6 @@ static int sbi_cpuidle_init_cpu(struct device *dev, int cpu)
        return ret;
 }
 
-static void sbi_cpuidle_domain_sync_state(struct device *dev)
-{
-       struct sbi_pd_provider *pd_provider;
-
-       /*
-        * All devices have now been attached/probed to the PM domain
-        * topology, hence it's fine to allow domain states to be picked.
-        */
-       sbi_cpuidle_pd_allow_domain_state = true;
-
-       list_for_each_entry(pd_provider, &sbi_pd_providers, link)
-               of_genpd_sync_state(pd_provider->node);
-}
-
 #ifdef CONFIG_DT_IDLE_GENPD
 
 static int sbi_cpuidle_pd_power_off(struct generic_pm_domain *pd)
@@ -369,9 +354,6 @@ static int sbi_cpuidle_pd_power_off(struct generic_pm_domain *pd)
        if (!state->data)
                return 0;
 
-       if (!sbi_cpuidle_pd_allow_domain_state)
-               return -EBUSY;
-
        /* OSI mode is enabled, set the corresponding domain state. */
        pd_state = state->data;
        sbi_set_domain_state(*pd_state);
@@ -401,8 +383,7 @@ static int sbi_pd_init(struct device_node *np)
        if (!pd_provider)
                goto free_pd;
 
-       pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN |
-                    GENPD_FLAG_NO_SYNC_STATE;
+       pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN;
 
        /* Allow power off when OSI is available. */
        if (sbi_cpuidle_use_osi)
@@ -570,7 +551,6 @@ static struct platform_driver sbi_cpuidle_driver = {
        .probe = sbi_cpuidle_probe,
        .driver = {
                .name = "sbi-cpuidle",
-               .sync_state = sbi_cpuidle_domain_sync_state,
        },
 };
 
--

2.43.0

#49 lore raw
In reply to Ulf Hansson
Quoted 6 lines · Ulf Hansson

Changes in v3:
- Added a couple of patches to adress problems on some Renesas platforms. Thanks Geert and Tomi for helping out!
- Adressed a few comments from Saravanna and Konrad.
- Added some tested-by tags.

I decided it was time to give this a try, so I have queued this up for v6.17 via the next branch at my pmdomain tree.

If you encounter any issues, please let me know so I can help to fix them.

Kind regards
Uffe

Quoted 80 lines

Changes in v2:
- Well, quite a lot as I discovered various problems when doing additional testing of corner-case. I suggest re-review from scratch, even if I decided to keep some reviewed-by tags.
- Added patches to allow some drivers that needs to align or opt-out from the new common behaviour in genpd.

If a PM domain (genpd) is powered-on during boot, there is probably a good reason for it. Therefore it's known to be a bad idea to allow such genpd to be powered-off before all of its consumer devices have been probed. This series intends to fix this problem.

We have been discussing these issues at LKML and at various Linux-conferences in the past. I have therefore tried to include the people I can recall being involved, but I may have forgotten some (my apologies), feel free to loop them in.

I have tested this with QEMU with a bunch of local test-drivers and DT nodes. Let me know if you want me to share this code too.

Please help review and test!
Finally, a big thanks to Saravana for all the support!

Kind regards
Ulf Hansson

Saravana Kannan (1):
driver core: Add dev_set_drv_sync_state()

Ulf Hansson (23):
pmdomain: renesas: rcar-sysc: Add genpd OF provider at
postcore_initcall
pmdomain: renesas: rmobile-sysc: Move init to postcore_initcall
pmdomain: renesas: rcar-gen4-sysc: Move init to postcore_initcall
pmdomain: core: Prevent registering devices before the bus
pmdomain: core: Add a bus and a driver for genpd providers
pmdomain: core: Add the genpd->dev to the genpd provider bus
pmdomain: core: Export a common ->sync_state() helper for genpd
providers
pmdomain: core: Prepare to add the common ->sync_state() support soc/tegra: pmc: Opt-out from genpd's common ->sync_state() support
cpuidle: psci: Opt-out from genpd's common ->sync_state() support
cpuidle: riscv-sbi: Opt-out from genpd's common ->sync_state() support
pmdomain: qcom: rpmpd: Use of_genpd_sync_state()
pmdomain: qcom: rpmhpd: Use of_genpd_sync_state() firmware/pmdomain: xilinx: Move ->sync_state() support to firmware
driver
firmware: xilinx: Don't share zynqmp_pm_init_finalize()
firmware: xilinx: Use of_genpd_sync_state()
driver core: Export get_dev_from_fwnode()
pmdomain: core: Add common ->sync_state() support for genpd providers
pmdomain: core: Default to use of_genpd_sync_state() for genpd
providers
pmdomain: core: Leave powered-on genpds on until late_initcall_sync
pmdomain: core: Leave powered-on genpds on until sync_state
cpuidle: psci: Drop redundant sync_state support
cpuidle: riscv-sbi: Drop redundant sync_state support

 drivers/base/core.c                         |   8 +-
 drivers/cpuidle/cpuidle-psci-domain.c       |  14 --
 drivers/cpuidle/cpuidle-riscv-sbi.c         |  14 --
 drivers/firmware/xilinx/zynqmp.c            |  18 +-
 drivers/pmdomain/core.c                     | 211 ++++++++++++++++++--
 drivers/pmdomain/qcom/rpmhpd.c              |   2 +
 drivers/pmdomain/qcom/rpmpd.c               |   2 +
 drivers/pmdomain/renesas/rcar-gen4-sysc.c   |   2 +-
 drivers/pmdomain/renesas/rcar-sysc.c        |  19 +-
 drivers/pmdomain/renesas/rmobile-sysc.c     |   3 +-
 drivers/pmdomain/xilinx/zynqmp-pm-domains.c |  16 --
 drivers/soc/tegra/pmc.c                     |  26 ++-
 include/linux/device.h                      |  13 ++
 include/linux/firmware/xlnx-zynqmp.h        |   6 -
 include/linux/pm_domain.h                   |  17 ++
 15 files changed, 291 insertions(+), 80 deletions(-)

--
2.43.0

maintainer
#50 lore raw

Hi Ulf,

Quoted 4 lines · Ulf Hansson

I decided it was time to give this a try, so I have queued this up for v6.17 via the next branch at my pmdomain tree.

If you encounter any issues, please let me know so I can help to fix them.

Can you please address my concern in patch 17 ("driver core: Export get_dev_from_fwnode()")?

Since this has been applied already, a subsequent patch would be perfectly fine.

Thanks,
Danilo

#51 lore raw
Quoted 7 lines · Danilo Krummrich

Hi Ulf,

Quoted 3 lines · Ulf Hansson

I decided it was time to give this a try, so I have queued this up for v6.17 via the next branch at my pmdomain tree.

Quoted 6 lines
Quoted 1 line

If you encounter any issues, please let me know so I can help to fix them.

Can you please address my concern in patch 17 ("driver core: Export get_dev_from_fwnode()")?

Since this has been applied already, a subsequent patch would be perfectly fine.

Hi Danilo,

As Greg and Saravana were happy, I didn't want to hold back the whole series only because of a minor comment on some missing documentation.

But, yes, let me look into it. It may take a while though, as vacation is getting closer. If you want to send a patch yourself, please, feel free to do it.

Note that, while at it, we should probably also add some documentation of device_set_node() (next to get_dev_from_fwnode()) as it also lacks it.

Kind regards
Uffe

maintainer
#52 lore raw
Quoted 13 lines · Ulf Hansson
Quoted 12 lines · Danilo Krummrich

Hi Ulf,

Quoted 4 lines · Ulf Hansson

I decided it was time to give this a try, so I have queued this up for v6.17 via the next branch at my pmdomain tree.

If you encounter any issues, please let me know so I can help to fix them.

Can you please address my concern in patch 17 ("driver core: Export get_dev_from_fwnode()")?

Quoted 6 lines
Quoted 1 line

Since this has been applied already, a subsequent patch would be perfectly fine.

Hi Danilo,

As Greg and Saravana were happy, I didn't want to hold back the whole series only because of a minor comment on some missing documentation.

Fair enough -- yet, a brief reply asking if it can be done as a follow-up would have been appreciated.

I don't think it's that minor. The race may be unlikely to happen, but if it happens because someone isn't careful with this (now exported) API - and I'm absolutely sure it's only gonna be a matter of time until that happens -, it'll be painful. :(

Quoted 3 lines

But, yes, let me look into it. It may take a while though, as vacation is getting closer. If you want to send a patch yourself, please, feel free to do it.

Ok, let me see if I can get to it.

Quoted 3 lines

Note that, while at it, we should probably also add some documentation of device_set_node() (next to get_dev_from_fwnode()) as it also lacks it.

Agreed!

Have a nice vacation!

- Danilo

#53 lore raw
In reply to Ulf Hansson

Hi Ulf,

Quoted 11 lines · Ulf Hansson
Quoted 5 lines · Ulf Hansson

Changes in v3:
- Added a couple of patches to adress problems on some Renesas platforms. Thanks Geert and Tomi for helping out!
- Adressed a few comments from Saravanna and Konrad.
- Added some tested-by tags.

I decided it was time to give this a try, so I have queued this up for v6.17 via the next branch at my pmdomain tree.

If you encounter any issues, please let me know so I can help to fix them.

Thanks for your series! Due to holidays, I only managed to test this very recently.

Unfortunately I have an issue with unused PM Domains no longer being disabled on R-Car:
- On R-Car Gen1/2/3, using rcar-sysc.c, unused PM Domains are never disabled.
- On R-Car Gen4, using rcar-gen4-sysc.c, unused PM Domains are sometimes not disabled.
At first, I noticed the IOMMU driver was not enabled in my config, and enabling it did fix the issue. However, after that I still encountered the issue in a different config that does have the IOMMU driver enabled...

FTR, unused PM Domains are still disabled correctly on R/SH-Mobile (using rmobile-sysc.c) and on BeagleBone Black. Note that these use of_genpd_add_provider_simple(), while all R-Car drivers use of_genpd_add_provider_onecell(). Perhaps there is an issue with the latter? If you don't have a clue, I plan to do some more investigation later...

BTW, the "pending due to"-messages look weird to me. On R-Car M2-W (r8a7791.dtsi) I see e.g.:

genpd_provider ca15-cpu0: sync_state() pending due to e6020000.watchdog renesas-cpg-mssr e6150000.clock-controller: sync_state() pending
due to e6020000.watchdog

ca15-cpu0 is the PM Domain holding the first CPU core, while the watchdog resides in the always-on Clock Domain, and uses the clock-controller for PM_CLK handling.

Thanks!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
#54 lore raw
Quoted 30 lines · Geert Uytterhoeven

Hi Ulf,

Quoted 11 lines · Ulf Hansson
Quoted 5 lines · Ulf Hansson

Changes in v3:
- Added a couple of patches to adress problems on some Renesas platforms. Thanks Geert and Tomi for helping out!
- Adressed a few comments from Saravanna and Konrad.
- Added some tested-by tags.

I decided it was time to give this a try, so I have queued this up for v6.17 via the next branch at my pmdomain tree.

If you encounter any issues, please let me know so I can help to fix them.

Thanks for your series! Due to holidays, I only managed to test this very recently.

Unfortunately I have an issue with unused PM Domains no longer being disabled on R-Car:
- On R-Car Gen1/2/3, using rcar-sysc.c, unused PM Domains are never disabled.
- On R-Car Gen4, using rcar-gen4-sysc.c, unused PM Domains are sometimes not disabled.
At first, I noticed the IOMMU driver was not enabled in my config, and enabling it did fix the issue. However, after that I still encountered the issue in a different config that does have the IOMMU driver enabled...

Quoted 6 lines

FTR, unused PM Domains are still disabled correctly on R/SH-Mobile (using rmobile-sysc.c) and on BeagleBone Black. Note that these use of_genpd_add_provider_simple(), while all R-Car drivers use of_genpd_add_provider_onecell(). Perhaps there is an issue with the latter? If you don't have a clue, I plan to do some more investigation later...

Geert, thanks for reporting!

Quoted 11 lines

BTW, the "pending due to"-messages look weird to me. On R-Car M2-W (r8a7791.dtsi) I see e.g.:

genpd_provider ca15-cpu0: sync_state() pending due to e6020000.watchdog renesas-cpg-mssr e6150000.clock-controller: sync_state() pending
due to e6020000.watchdog

ca15-cpu0 is the PM Domain holding the first CPU core, while the watchdog resides in the always-on Clock Domain, and uses the clock-controller for PM_CLK handling.

I will have a closer look as soon as I can to see if I can find some potential problems.

Kind regards
Uffe

#55 lore raw

Hi Ulf,

Quoted 28 lines · Ulf Hansson
Quoted 27 lines · Geert Uytterhoeven
Quoted 11 lines · Ulf Hansson
Quoted 5 lines · Ulf Hansson

Changes in v3:
- Added a couple of patches to adress problems on some Renesas platforms. Thanks Geert and Tomi for helping out!
- Adressed a few comments from Saravanna and Konrad.
- Added some tested-by tags.

I decided it was time to give this a try, so I have queued this up for v6.17 via the next branch at my pmdomain tree.

If you encounter any issues, please let me know so I can help to fix them.

Thanks for your series! Due to holidays, I only managed to test this very recently.

Unfortunately I have an issue with unused PM Domains no longer being disabled on R-Car:
- On R-Car Gen1/2/3, using rcar-sysc.c, unused PM Domains are never disabled.
- On R-Car Gen4, using rcar-gen4-sysc.c, unused PM Domains are sometimes not disabled.
At first, I noticed the IOMMU driver was not enabled in my config, and enabling it did fix the issue. However, after that I still encountered the issue in a different config that does have the IOMMU driver enabled...

Quoted 6 lines
Quoted 6 lines

FTR, unused PM Domains are still disabled correctly on R/SH-Mobile (using rmobile-sysc.c) and on BeagleBone Black. Note that these use of_genpd_add_provider_simple(), while all R-Car drivers use of_genpd_add_provider_onecell(). Perhaps there is an issue with the latter? If you don't have a clue, I plan to do some more investigation later...

of_genpd_add_provider_onecell() has:

    if (!dev)
            sync_state = true;
    else
            dev_set_drv_sync_state(dev, genpd_sync_state);

    for (i = 0; i < data->num_domains; i++) {
            ...
            if (sync_state && !genpd_is_no_sync_state(genpd)) {
                    genpd->sync_state = GENPD_SYNC_STATE_ONECELL;
                    device_set_node(&genpd->dev, fwnode);
                    sync_state = false;
                    ^^^^^^^^^^^^^^^^^^^
            }
            ...
    }

As the R-Car SYSC drivers are not platform drivers, dev is NULL, and genpd->sync_state is set to GENPD_SYNC_STATE_ONECELL for the first PM Domain only. All other domains have the default value of sync_state (0 = GENPD_SYNC_STATE_OFF). Hence when genpd_provider_sync_state() is called later, it ignores all but the first domain. Apparently this is intentional, as of_genpd_sync_state() tries to power off all domains handled by the same controller anyway (see below)?

Quoted 10 lines
Quoted 10 lines

BTW, the "pending due to"-messages look weird to me. On R-Car M2-W (r8a7791.dtsi) I see e.g.:

genpd_provider ca15-cpu0: sync_state() pending due to e6020000.watchdog renesas-cpg-mssr e6150000.clock-controller: sync_state() pending
due to e6020000.watchdog

ca15-cpu0 is the PM Domain holding the first CPU core, while the watchdog resides in the always-on Clock Domain, and uses the clock-controller for PM_CLK handling.

Unfortunately the first PM Domain is "ca15-cpu0", which is blocked on these bogus pending states, and no PM Domain is powered off.

If I remove the "sync_state = false" above, genpd_provider_sync_state() considers all domains, and does power down all unused domains (even multiple times, as expected).

Upon closer look, all "pending due to" messages I see claim that the first (index 0) PM Domain is pending on some devices, while all of these devices are part of a different domain (usually the always-on domain, which is always the last (32 or 64) on R-Car).

So I think there are two issues:
1. Devices are not attributed to the correct PM Domain using fw_devlink sync_state,
2. One PM Domain of a multi-domain controller being blocked should not block all other domains handled by the same controller.

Does that make sense?
Thanks!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
#56 lore raw
Quoted 57 lines · Geert Uytterhoeven

Hi Ulf,

Quoted 28 lines · Ulf Hansson
Quoted 27 lines · Geert Uytterhoeven
Quoted 11 lines · Ulf Hansson
Quoted 5 lines · Ulf Hansson

Changes in v3:
- Added a couple of patches to adress problems on some Renesas platforms. Thanks Geert and Tomi for helping out!
- Adressed a few comments from Saravanna and Konrad.
- Added some tested-by tags.

I decided it was time to give this a try, so I have queued this up for v6.17 via the next branch at my pmdomain tree.

If you encounter any issues, please let me know so I can help to fix them.

Thanks for your series! Due to holidays, I only managed to test this very recently.

Unfortunately I have an issue with unused PM Domains no longer being disabled on R-Car:
- On R-Car Gen1/2/3, using rcar-sysc.c, unused PM Domains are never disabled.
- On R-Car Gen4, using rcar-gen4-sysc.c, unused PM Domains are sometimes not disabled.
At first, I noticed the IOMMU driver was not enabled in my config, and enabling it did fix the issue. However, after that I still encountered the issue in a different config that does have the IOMMU driver enabled...

Quoted 6 lines
Quoted 6 lines

FTR, unused PM Domains are still disabled correctly on R/SH-Mobile (using rmobile-sysc.c) and on BeagleBone Black. Note that these use of_genpd_add_provider_simple(), while all R-Car drivers use of_genpd_add_provider_onecell(). Perhaps there is an issue with the latter? If you don't have a clue, I plan to do some more investigation later...

of_genpd_add_provider_onecell() has:

    if (!dev)
            sync_state = true;
    else
            dev_set_drv_sync_state(dev, genpd_sync_state);

    for (i = 0; i < data->num_domains; i++) {
            ...
            if (sync_state && !genpd_is_no_sync_state(genpd)) {
                    genpd->sync_state = GENPD_SYNC_STATE_ONECELL;
                    device_set_node(&genpd->dev, fwnode);
                    sync_state = false;
                    ^^^^^^^^^^^^^^^^^^^
            }
            ...
    }
Quoted 7 lines

As the R-Car SYSC drivers are not platform drivers, dev is NULL, and genpd->sync_state is set to GENPD_SYNC_STATE_ONECELL for the first PM Domain only. All other domains have the default value of sync_state (0 = GENPD_SYNC_STATE_OFF). Hence when genpd_provider_sync_state() is called later, it ignores all but the first domain. Apparently this is intentional, as of_genpd_sync_state() tries to power off all domains handled by the same controller anyway (see below)?

Right, this is intentional and mainly because of how fw_devlink works.

fw_devlink is limited to use only the first device - if multiple devices share the same fwnode. In principle, we could have picked any of the devices in the array of genpds here - and reached the same result.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

BTW, the "pending due to"-messages look weird to me. On R-Car M2-W (r8a7791.dtsi) I see e.g.:

genpd_provider ca15-cpu0: sync_state() pending due to e6020000.watchdog renesas-cpg-mssr e6150000.clock-controller: sync_state() pending
due to e6020000.watchdog

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

ca15-cpu0 is the PM Domain holding the first CPU core, while the watchdog resides in the always-on Clock Domain, and uses the clock-controller for PM_CLK handling.

Unfortunately the first PM Domain is "ca15-cpu0", which is blocked on these bogus pending states, and no PM Domain is powered off.

I see, thanks for the details. I am looking closer at this.

In any case, this is the main issue, as it prevents the ->sync_state() callback to be called. Hence the "genpd->stay_on" will also *not* be cleared for any of the genpd's for the genpd-provider.

Quoted 4 lines

If I remove the "sync_state = false" above, genpd_provider_sync_state() considers all domains, and does power down all unused domains (even multiple times, as expected).

I think those are getting called because with the change above, there is no device_link being tracked. As stated above, fw_devlink is limited to use only one device - if multiple devices share the same fwnode.

In other words, the ->sync_state() callbacks are called even if the corresponding consumer devices have not been probed yet.

Quoted 11 lines

Upon closer look, all "pending due to" messages I see claim that the first (index 0) PM Domain is pending on some devices, while all of these devices are part of a different domain (usually the always-on domain, which is always the last (32 or 64) on R-Car).

So I think there are two issues:
1. Devices are not attributed to the correct PM Domain using fw_devlink sync_state,
2. One PM Domain of a multi-domain controller being blocked should not block all other domains handled by the same controller.

Right, that's a current limitation with fw_devlink. To cope with this, it's possible to enforce the ->sync_state() callback to be invoked from user-space (timeout or explicitly) for a device.

Another option would be to allow an opt-out behavior for some genpd's that are powered-on at initialization. Something along the lines of the below.

From: Ulf Hansson <[email protected]>
Date: Tue, 29 Jul 2025 14:27:22 +0200
Subject: [PATCH] pmdomain: core: Allow powered-on PM domains to be powered-off
during boot

---
 drivers/pmdomain/core.c   | 3 ++-
 include/linux/pm_domain.h | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/pmdomain/core.c +0 -0
index 0006ab3d0789..ef0760824c92 100644
@@ -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)
@@ -2392,7 +2393,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->stay_on = !genpd_is_no_stay_on(genpd) && !is_off;
        genpd->sync_state = GENPD_SYNC_STATE_OFF;
        genpd->device_count = 0;
        genpd->provider = NULL;
include/linux/pm_domain.h +7 -0
index b9d3c7d5c4f8..61b81574efc4 100644
@@ -109,6 +109,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:      A powered-on PM domain at initialization is
+ *                             prevented by genpd from being powered-off until
+ *                             we receive a ->sync_state() or runs the
+ *                             late_initcall_sync. Use this flag to allow
+ *                             power-off without waiting for these conditions.
  */
 #define GENPD_FLAG_PM_CLK       (1U << 0)
 #define GENPD_FLAG_IRQ_SAFE     (1U << 1)
@@ -120,6 +126,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 */
Signature · 4 lines
2.43.0

Kind regards
Uffe
#57 lore raw

Hi Ulf,

Quoted 63 lines · Ulf Hansson
Quoted 54 lines · Geert Uytterhoeven
Quoted 28 lines · Ulf Hansson
Quoted 27 lines · Geert Uytterhoeven
Quoted 11 lines · Ulf Hansson
Quoted 5 lines · Ulf Hansson

Changes in v3:
- Added a couple of patches to adress problems on some Renesas platforms. Thanks Geert and Tomi for helping out!
- Adressed a few comments from Saravanna and Konrad.
- Added some tested-by tags.

I decided it was time to give this a try, so I have queued this up for v6.17 via the next branch at my pmdomain tree.

If you encounter any issues, please let me know so I can help to fix them.

Thanks for your series! Due to holidays, I only managed to test this very recently.

Unfortunately I have an issue with unused PM Domains no longer being disabled on R-Car:
- On R-Car Gen1/2/3, using rcar-sysc.c, unused PM Domains are never disabled.
- On R-Car Gen4, using rcar-gen4-sysc.c, unused PM Domains are sometimes not disabled.
At first, I noticed the IOMMU driver was not enabled in my config, and enabling it did fix the issue. However, after that I still encountered the issue in a different config that does have the IOMMU driver enabled...

Quoted 6 lines
Quoted 6 lines

FTR, unused PM Domains are still disabled correctly on R/SH-Mobile (using rmobile-sysc.c) and on BeagleBone Black. Note that these use of_genpd_add_provider_simple(), while all R-Car drivers use of_genpd_add_provider_onecell(). Perhaps there is an issue with the latter? If you don't have a clue, I plan to do some more investigation later...

of_genpd_add_provider_onecell() has:

    if (!dev)
            sync_state = true;
    else
            dev_set_drv_sync_state(dev, genpd_sync_state);

    for (i = 0; i < data->num_domains; i++) {
            ...
            if (sync_state && !genpd_is_no_sync_state(genpd)) {
                    genpd->sync_state = GENPD_SYNC_STATE_ONECELL;
                    device_set_node(&genpd->dev, fwnode);
                    sync_state = false;
                    ^^^^^^^^^^^^^^^^^^^
            }
            ...
    }
Quoted 7 lines

As the R-Car SYSC drivers are not platform drivers, dev is NULL, and genpd->sync_state is set to GENPD_SYNC_STATE_ONECELL for the first PM Domain only. All other domains have the default value of sync_state (0 = GENPD_SYNC_STATE_OFF). Hence when genpd_provider_sync_state() is called later, it ignores all but the first domain. Apparently this is intentional, as of_genpd_sync_state() tries to power off all domains handled by the same controller anyway (see below)?

Quoted 6 lines

Right, this is intentional and mainly because of how fw_devlink works.

fw_devlink is limited to use only the first device - if multiple devices share the same fwnode. In principle, we could have picked any of the devices in the array of genpds here - and reached the same result.

OK, just like I already assumed...

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines

BTW, the "pending due to"-messages look weird to me. On R-Car M2-W (r8a7791.dtsi) I see e.g.:

genpd_provider ca15-cpu0: sync_state() pending due to e6020000.watchdog renesas-cpg-mssr e6150000.clock-controller: sync_state() pending
due to e6020000.watchdog

ca15-cpu0 is the PM Domain holding the first CPU core, while the watchdog resides in the always-on Clock Domain, and uses the clock-controller for PM_CLK handling.

Quoted 8 lines
Quoted 2 lines

Unfortunately the first PM Domain is "ca15-cpu0", which is blocked on these bogus pending states, and no PM Domain is powered off.

I see, thanks for the details. I am looking closer at this.

In any case, this is the main issue, as it prevents the ->sync_state() callback to be called. Hence the "genpd->stay_on" will also *not* be cleared for any of the genpd's for the genpd-provider.

I was under the impression there is a time-out, after which the .sync_state() callback would be called anyway, just like for probe deferral due to missing optional providers like DMACs and IOMMUs. Apparently that is not the case?

Quoted 8 lines
Quoted 3 lines

If I remove the "sync_state = false" above, genpd_provider_sync_state() considers all domains, and does power down all unused domains (even multiple times, as expected).

I think those are getting called because with the change above, there is no device_link being tracked. As stated above, fw_devlink is limited to use only one device - if multiple devices share the same fwnode.

Indeed.

Quoted 2 lines

In other words, the ->sync_state() callbacks are called even if the corresponding consumer devices have not been probed yet.

Hence shouldn't there be a timeout, as the kernel may not even have a driver for one or more consumer devices?

Quoted 15 lines
Quoted 10 lines

Upon closer look, all "pending due to" messages I see claim that the first (index 0) PM Domain is pending on some devices, while all of these devices are part of a different domain (usually the always-on domain, which is always the last (32 or 64) on R-Car).

So I think there are two issues:
1. Devices are not attributed to the correct PM Domain using fw_devlink sync_state,
2. One PM Domain of a multi-domain controller being blocked should not block all other domains handled by the same controller.

Right, that's a current limitation with fw_devlink. To cope with this, it's possible to enforce the ->sync_state() callback to be invoked from user-space (timeout or explicitly) for a device.

Quoted 8 lines

Another option would be to allow an opt-out behavior for some genpd's that are powered-on at initialization. Something along the lines of the below.

From: Ulf Hansson <[email protected]>
Date: Tue, 29 Jul 2025 14:27:22 +0200
Subject: [PATCH] pmdomain: core: Allow powered-on PM domains to be powered-off
during boot

[...]

I gave this a try (i.e. "| GENPD_FLAG_NO_STAY_ON" in rcar-sysc.c), but this doesn't make any difference. I assume this would only work when actively calling genpd_power_off() (i.e. not from of_genpd_sync_state() or genpd_provider_sync_state())?

Thanks!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
#58 lore raw
Quoted 92 lines · Geert Uytterhoeven

Hi Ulf,

Quoted 63 lines · Ulf Hansson
Quoted 54 lines · Geert Uytterhoeven
Quoted 28 lines · Ulf Hansson
Quoted 27 lines · Geert Uytterhoeven
Quoted 11 lines · Ulf Hansson
Quoted 5 lines · Ulf Hansson

Changes in v3:
- Added a couple of patches to adress problems on some Renesas platforms. Thanks Geert and Tomi for helping out!
- Adressed a few comments from Saravanna and Konrad.
- Added some tested-by tags.

I decided it was time to give this a try, so I have queued this up for v6.17 via the next branch at my pmdomain tree.

If you encounter any issues, please let me know so I can help to fix them.

Thanks for your series! Due to holidays, I only managed to test this very recently.

Unfortunately I have an issue with unused PM Domains no longer being disabled on R-Car:
- On R-Car Gen1/2/3, using rcar-sysc.c, unused PM Domains are never disabled.
- On R-Car Gen4, using rcar-gen4-sysc.c, unused PM Domains are sometimes not disabled.
At first, I noticed the IOMMU driver was not enabled in my config, and enabling it did fix the issue. However, after that I still encountered the issue in a different config that does have the IOMMU driver enabled...

Quoted 6 lines
Quoted 6 lines

FTR, unused PM Domains are still disabled correctly on R/SH-Mobile (using rmobile-sysc.c) and on BeagleBone Black. Note that these use of_genpd_add_provider_simple(), while all R-Car drivers use of_genpd_add_provider_onecell(). Perhaps there is an issue with the latter? If you don't have a clue, I plan to do some more investigation later...

of_genpd_add_provider_onecell() has:

    if (!dev)
            sync_state = true;
    else
            dev_set_drv_sync_state(dev, genpd_sync_state);

    for (i = 0; i < data->num_domains; i++) {
            ...
            if (sync_state && !genpd_is_no_sync_state(genpd)) {
                    genpd->sync_state = GENPD_SYNC_STATE_ONECELL;
                    device_set_node(&genpd->dev, fwnode);
                    sync_state = false;
                    ^^^^^^^^^^^^^^^^^^^
            }
            ...
    }
Quoted 7 lines

As the R-Car SYSC drivers are not platform drivers, dev is NULL, and genpd->sync_state is set to GENPD_SYNC_STATE_ONECELL for the first PM Domain only. All other domains have the default value of sync_state (0 = GENPD_SYNC_STATE_OFF). Hence when genpd_provider_sync_state() is called later, it ignores all but the first domain. Apparently this is intentional, as of_genpd_sync_state() tries to power off all domains handled by the same controller anyway (see below)?

Quoted 6 lines

Right, this is intentional and mainly because of how fw_devlink works.

fw_devlink is limited to use only the first device - if multiple devices share the same fwnode. In principle, we could have picked any of the devices in the array of genpds here - and reached the same result.

OK, just like I already assumed...

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

BTW, the "pending due to"-messages look weird to me. On R-Car M2-W (r8a7791.dtsi) I see e.g.:

genpd_provider ca15-cpu0: sync_state() pending due to e6020000.watchdog renesas-cpg-mssr e6150000.clock-controller: sync_state() pending
due to e6020000.watchdog

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

ca15-cpu0 is the PM Domain holding the first CPU core, while the watchdog resides in the always-on Clock Domain, and uses the clock-controller for PM_CLK handling.

Unfortunately the first PM Domain is "ca15-cpu0", which is blocked on these bogus pending states, and no PM Domain is powered off.

I see, thanks for the details. I am looking closer at this.

Quoted 8 lines
Quoted 3 lines

In any case, this is the main issue, as it prevents the ->sync_state() callback to be called. Hence the "genpd->stay_on" will also *not* be cleared for any of the genpd's for the genpd-provider.

I was under the impression there is a time-out, after which the .sync_state() callback would be called anyway, just like for probe deferral due to missing optional providers like DMACs and IOMMUs. Apparently that is not the case?

The behaviour is configurable, so it depends. The current default behaviour does *not* enforce the ->sync_state() callbacks to be called, even after a time-out.

You may set CONFIG_FW_DEVLINK_SYNC_STATE_TIMEOUT to achieve the above behavior or use the fw_devlink command line parameters to change it. Like setting "fw_devlink.sync_state=timeout".

I guess it can be debated what the default behaviour should be. Perhaps we should even allow the default behaviour to be dynamically tweaked on a per provider device/driver basis?

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

If I remove the "sync_state = false" above, genpd_provider_sync_state() considers all domains, and does power down all unused domains (even multiple times, as expected).

I think those are getting called because with the change above, there is no device_link being tracked. As stated above, fw_devlink is limited to use only one device - if multiple devices share the same fwnode.

Quoted 7 lines

Indeed.

Quoted 2 lines

In other words, the ->sync_state() callbacks are called even if the corresponding consumer devices have not been probed yet.

Hence shouldn't there be a timeout, as the kernel may not even have a driver for one or more consumer devices?

See above.

Quoted 25 lines
Quoted 16 lines
Quoted 11 lines

Upon closer look, all "pending due to" messages I see claim that the first (index 0) PM Domain is pending on some devices, while all of these devices are part of a different domain (usually the always-on domain, which is always the last (32 or 64) on R-Car).

So I think there are two issues:
1. Devices are not attributed to the correct PM Domain using fw_devlink sync_state,
2. One PM Domain of a multi-domain controller being blocked should not block all other domains handled by the same controller.

Right, that's a current limitation with fw_devlink. To cope with this, it's possible to enforce the ->sync_state() callback to be invoked from user-space (timeout or explicitly) for a device.

Quoted 8 lines

Another option would be to allow an opt-out behavior for some genpd's that are powered-on at initialization. Something along the lines of the below.

From: Ulf Hansson <[email protected]>
Date: Tue, 29 Jul 2025 14:27:22 +0200
Subject: [PATCH] pmdomain: core: Allow powered-on PM domains to be powered-off
during boot

Quoted 6 lines

[...]

I gave this a try (i.e. "| GENPD_FLAG_NO_STAY_ON" in rcar-sysc.c), but this doesn't make any difference. I assume this would only work when actively calling genpd_power_off() (i.e. not from of_genpd_sync_state() or genpd_provider_sync_state())?

Right. Thanks for testing!

So, we may need to restore some part of the genpd_power_off_unused() when CONFIG_PM_GENERIC_DOMAINS_OF is set. Without clearing "genpd->stay_on".

I can extend the patch, if you think it would make sense for you?

Kind regards
Uffe

#59 lore raw

Hi Ulf,

Quoted 103 lines · Ulf Hansson
Quoted 89 lines · Geert Uytterhoeven
Quoted 63 lines · Ulf Hansson
Quoted 54 lines · Geert Uytterhoeven
Quoted 28 lines · Ulf Hansson
Quoted 27 lines · Geert Uytterhoeven
Quoted 11 lines · Ulf Hansson
Quoted 5 lines · Ulf Hansson

Changes in v3:
- Added a couple of patches to adress problems on some Renesas platforms. Thanks Geert and Tomi for helping out!
- Adressed a few comments from Saravanna and Konrad.
- Added some tested-by tags.

I decided it was time to give this a try, so I have queued this up for v6.17 via the next branch at my pmdomain tree.

If you encounter any issues, please let me know so I can help to fix them.

Thanks for your series! Due to holidays, I only managed to test this very recently.

Unfortunately I have an issue with unused PM Domains no longer being disabled on R-Car:
- On R-Car Gen1/2/3, using rcar-sysc.c, unused PM Domains are never disabled.
- On R-Car Gen4, using rcar-gen4-sysc.c, unused PM Domains are sometimes not disabled.
At first, I noticed the IOMMU driver was not enabled in my config, and enabling it did fix the issue. However, after that I still encountered the issue in a different config that does have the IOMMU driver enabled...

Quoted 6 lines
Quoted 6 lines

FTR, unused PM Domains are still disabled correctly on R/SH-Mobile (using rmobile-sysc.c) and on BeagleBone Black. Note that these use of_genpd_add_provider_simple(), while all R-Car drivers use of_genpd_add_provider_onecell(). Perhaps there is an issue with the latter? If you don't have a clue, I plan to do some more investigation later...

of_genpd_add_provider_onecell() has:

    if (!dev)
            sync_state = true;
    else
            dev_set_drv_sync_state(dev, genpd_sync_state);

    for (i = 0; i < data->num_domains; i++) {
            ...
            if (sync_state && !genpd_is_no_sync_state(genpd)) {
                    genpd->sync_state = GENPD_SYNC_STATE_ONECELL;
                    device_set_node(&genpd->dev, fwnode);
                    sync_state = false;
                    ^^^^^^^^^^^^^^^^^^^
            }
            ...
    }
Quoted 7 lines

As the R-Car SYSC drivers are not platform drivers, dev is NULL, and genpd->sync_state is set to GENPD_SYNC_STATE_ONECELL for the first PM Domain only. All other domains have the default value of sync_state (0 = GENPD_SYNC_STATE_OFF). Hence when genpd_provider_sync_state() is called later, it ignores all but the first domain. Apparently this is intentional, as of_genpd_sync_state() tries to power off all domains handled by the same controller anyway (see below)?

Quoted 6 lines

Right, this is intentional and mainly because of how fw_devlink works.

fw_devlink is limited to use only the first device - if multiple devices share the same fwnode. In principle, we could have picked any of the devices in the array of genpds here - and reached the same result.

OK, just like I already assumed...

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

BTW, the "pending due to"-messages look weird to me. On R-Car M2-W (r8a7791.dtsi) I see e.g.:

genpd_provider ca15-cpu0: sync_state() pending due to e6020000.watchdog renesas-cpg-mssr e6150000.clock-controller: sync_state() pending
due to e6020000.watchdog

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

ca15-cpu0 is the PM Domain holding the first CPU core, while the watchdog resides in the always-on Clock Domain, and uses the clock-controller for PM_CLK handling.

Unfortunately the first PM Domain is "ca15-cpu0", which is blocked on these bogus pending states, and no PM Domain is powered off.

I see, thanks for the details. I am looking closer at this.

Quoted 8 lines
Quoted 3 lines

In any case, this is the main issue, as it prevents the ->sync_state() callback to be called. Hence the "genpd->stay_on" will also *not* be cleared for any of the genpd's for the genpd-provider.

I was under the impression there is a time-out, after which the .sync_state() callback would be called anyway, just like for probe deferral due to missing optional providers like DMACs and IOMMUs. Apparently that is not the case?

The behaviour is configurable, so it depends. The current default behaviour does *not* enforce the ->sync_state() callbacks to be called, even after a time-out.

Quoted 7 lines

You may set CONFIG_FW_DEVLINK_SYNC_STATE_TIMEOUT to achieve the above behavior or use the fw_devlink command line parameters to change it. Like setting "fw_devlink.sync_state=timeout".

I guess it can be debated what the default behaviour should be. Perhaps we should even allow the default behaviour to be dynamically tweaked on a per provider device/driver basis?

The domains are indeed powered off like before when passing "fw_devlink.sync_state=timeout", so that fixes the regression. But it was not needed before...

I could add "select FW_DEVLINK_SYNC_STATE_TIMEOUT" to the SYSC_RCAR and SYSC_RCAR_GEN4 Kconfig options, but that would play badly with multi-platform kernels. As the fw_devlink_sync_state flag is static, the R-Car SYSC drivers can't just auto-enable the flag at runtime.

Any other options? Perhaps a device-specific flag to be set by the PM Domain driver, and to be checked by fw_devlink_dev_sync_state()?

Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines

If I remove the "sync_state = false" above, genpd_provider_sync_state() considers all domains, and does power down all unused domains (even multiple times, as expected).

I think those are getting called because with the change above, there is no device_link being tracked. As stated above, fw_devlink is limited to use only one device - if multiple devices share the same fwnode.

Indeed.

Quoted 22 lines
Quoted 5 lines
Quoted 2 lines

In other words, the ->sync_state() callbacks are called even if the corresponding consumer devices have not been probed yet.

Hence shouldn't there be a timeout, as the kernel may not even have a driver for one or more consumer devices?

See above.

Quoted 14 lines
Quoted 14 lines
Quoted 10 lines

Upon closer look, all "pending due to" messages I see claim that the first (index 0) PM Domain is pending on some devices, while all of these devices are part of a different domain (usually the always-on domain, which is always the last (32 or 64) on R-Car).

So I think there are two issues:
1. Devices are not attributed to the correct PM Domain using fw_devlink sync_state,
2. One PM Domain of a multi-domain controller being blocked should not block all other domains handled by the same controller.

Right, that's a current limitation with fw_devlink. To cope with this, it's possible to enforce the ->sync_state() callback to be invoked from user-space (timeout or explicitly) for a device.

That needs explicit handling, which was not needed before.

Perhaps the fw_devlink creation should be removed again from of_genpd_add_provider_onecell(), as it is not correct, except for the first domain?

Quoted 16 lines
Quoted 9 lines
Quoted 8 lines

Another option would be to allow an opt-out behavior for some genpd's that are powered-on at initialization. Something along the lines of the below.

From: Ulf Hansson <[email protected]>
Date: Tue, 29 Jul 2025 14:27:22 +0200
Subject: [PATCH] pmdomain: core: Allow powered-on PM domains to be powered-off
during boot

Quoted 6 lines

[...]

I gave this a try (i.e. "| GENPD_FLAG_NO_STAY_ON" in rcar-sysc.c), but this doesn't make any difference. I assume this would only work when actively calling genpd_power_off() (i.e. not from of_genpd_sync_state() or genpd_provider_sync_state())?

Quoted 7 lines

Right. Thanks for testing!

So, we may need to restore some part of the genpd_power_off_unused() when CONFIG_PM_GENERIC_DOMAINS_OF is set. Without clearing "genpd->stay_on".

I can extend the patch, if you think it would make sense for you?

I would applaud anything that would fix these regressions. Thanks!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
#60 lore raw
Quoted 111 lines · Geert Uytterhoeven

Hi Ulf,

Quoted 107 lines · Ulf Hansson
Quoted 89 lines · Geert Uytterhoeven
Quoted 63 lines · Ulf Hansson
Quoted 54 lines · Geert Uytterhoeven
Quoted 28 lines · Ulf Hansson
Quoted 27 lines · Geert Uytterhoeven
Quoted 11 lines · Ulf Hansson
Quoted 5 lines · Ulf Hansson

Changes in v3:
- Added a couple of patches to adress problems on some Renesas platforms. Thanks Geert and Tomi for helping out!
- Adressed a few comments from Saravanna and Konrad.
- Added some tested-by tags.

I decided it was time to give this a try, so I have queued this up for v6.17 via the next branch at my pmdomain tree.

If you encounter any issues, please let me know so I can help to fix them.

Thanks for your series! Due to holidays, I only managed to test this very recently.

Unfortunately I have an issue with unused PM Domains no longer being disabled on R-Car:
- On R-Car Gen1/2/3, using rcar-sysc.c, unused PM Domains are never disabled.
- On R-Car Gen4, using rcar-gen4-sysc.c, unused PM Domains are sometimes not disabled.
At first, I noticed the IOMMU driver was not enabled in my config, and enabling it did fix the issue. However, after that I still encountered the issue in a different config that does have the IOMMU driver enabled...

Quoted 6 lines
Quoted 6 lines

FTR, unused PM Domains are still disabled correctly on R/SH-Mobile (using rmobile-sysc.c) and on BeagleBone Black. Note that these use of_genpd_add_provider_simple(), while all R-Car drivers use of_genpd_add_provider_onecell(). Perhaps there is an issue with the latter? If you don't have a clue, I plan to do some more investigation later...

of_genpd_add_provider_onecell() has:

    if (!dev)
            sync_state = true;
    else
            dev_set_drv_sync_state(dev, genpd_sync_state);

    for (i = 0; i < data->num_domains; i++) {
            ...
            if (sync_state && !genpd_is_no_sync_state(genpd)) {
                    genpd->sync_state = GENPD_SYNC_STATE_ONECELL;
                    device_set_node(&genpd->dev, fwnode);
                    sync_state = false;
                    ^^^^^^^^^^^^^^^^^^^
            }
            ...
    }
Quoted 7 lines

As the R-Car SYSC drivers are not platform drivers, dev is NULL, and genpd->sync_state is set to GENPD_SYNC_STATE_ONECELL for the first PM Domain only. All other domains have the default value of sync_state (0 = GENPD_SYNC_STATE_OFF). Hence when genpd_provider_sync_state() is called later, it ignores all but the first domain. Apparently this is intentional, as of_genpd_sync_state() tries to power off all domains handled by the same controller anyway (see below)?

Quoted 6 lines

Right, this is intentional and mainly because of how fw_devlink works.

fw_devlink is limited to use only the first device - if multiple devices share the same fwnode. In principle, we could have picked any of the devices in the array of genpds here - and reached the same result.

OK, just like I already assumed...

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

BTW, the "pending due to"-messages look weird to me. On R-Car M2-W (r8a7791.dtsi) I see e.g.:

genpd_provider ca15-cpu0: sync_state() pending due to e6020000.watchdog renesas-cpg-mssr e6150000.clock-controller: sync_state() pending
due to e6020000.watchdog

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

ca15-cpu0 is the PM Domain holding the first CPU core, while the watchdog resides in the always-on Clock Domain, and uses the clock-controller for PM_CLK handling.

Unfortunately the first PM Domain is "ca15-cpu0", which is blocked on these bogus pending states, and no PM Domain is powered off.

I see, thanks for the details. I am looking closer at this.

Quoted 8 lines
Quoted 3 lines

In any case, this is the main issue, as it prevents the ->sync_state() callback to be called. Hence the "genpd->stay_on" will also *not* be cleared for any of the genpd's for the genpd-provider.

I was under the impression there is a time-out, after which the .sync_state() callback would be called anyway, just like for probe deferral due to missing optional providers like DMACs and IOMMUs. Apparently that is not the case?

The behaviour is configurable, so it depends. The current default behaviour does *not* enforce the ->sync_state() callbacks to be called, even after a time-out.

You may set CONFIG_FW_DEVLINK_SYNC_STATE_TIMEOUT to achieve the above behavior or use the fw_devlink command line parameters to change it. Like setting "fw_devlink.sync_state=timeout".

Quoted 7 lines
Quoted 3 lines

I guess it can be debated what the default behaviour should be. Perhaps we should even allow the default behaviour to be dynamically tweaked on a per provider device/driver basis?

The domains are indeed powered off like before when passing "fw_devlink.sync_state=timeout", so that fixes the regression. But it was not needed before...

Right, the default behavior in genpd has changed. The approach was taken as we believed that original behavior was not correct.

Although, the current situation isn't good as it causes lot of churns for us.

Quoted 8 lines

I could add "select FW_DEVLINK_SYNC_STATE_TIMEOUT" to the SYSC_RCAR and SYSC_RCAR_GEN4 Kconfig options, but that would play badly with multi-platform kernels. As the fw_devlink_sync_state flag is static, the R-Car SYSC drivers can't just auto-enable the flag at runtime.

Any other options? Perhaps a device-specific flag to be set by the PM Domain driver, and to be checked by fw_devlink_dev_sync_state()?

Something along those lines seems reasonable to me too.

However, the remaining question though, is what should be the default behavior in genpd for this. Due to all the churns, we may want something that is closer to what we had *before*, which means to always use the timeout option, unless the genpd provider driver explicitly requests to not to (an opt-out genpd config flag).

Saravana, it would be nice to get some thoughts from you are around this? Does it make sense?

Quoted 35 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 4 lines

If I remove the "sync_state = false" above, genpd_provider_sync_state() considers all domains, and does power down all unused domains (even multiple times, as expected).

I think those are getting called because with the change above, there is no device_link being tracked. As stated above, fw_devlink is limited to use only one device - if multiple devices share the same fwnode.

Indeed.

Quoted 22 lines
Quoted 5 lines
Quoted 2 lines

In other words, the ->sync_state() callbacks are called even if the corresponding consumer devices have not been probed yet.

Hence shouldn't there be a timeout, as the kernel may not even have a driver for one or more consumer devices?

See above.

Quoted 14 lines
Quoted 14 lines
Quoted 10 lines

Upon closer look, all "pending due to" messages I see claim that the first (index 0) PM Domain is pending on some devices, while all of these devices are part of a different domain (usually the always-on domain, which is always the last (32 or 64) on R-Car).

So I think there are two issues:
1. Devices are not attributed to the correct PM Domain using fw_devlink sync_state,
2. One PM Domain of a multi-domain controller being blocked should not block all other domains handled by the same controller.

Right, that's a current limitation with fw_devlink. To cope with this, it's possible to enforce the ->sync_state() callback to be invoked from user-space (timeout or explicitly) for a device.

Quoted 5 lines

That needs explicit handling, which was not needed before.

Perhaps the fw_devlink creation should be removed again from of_genpd_add_provider_onecell(), as it is not correct, except for the first domain?

There is nothing wrong with it, the behavior is correct, unless I failed to understand your problem. To me the problem is that it is just less fine grained, compared to using of_genpd_add_provider_simple(). All PM domains that is provided by a single power-domain controller that uses #power-domain-cells = <1>, requires all consumers of them to be probed, to allow the sync_state callback to be invoked.

If we could teach fw_devlink to take into account the power-domain-*id* that is specified by the consumer node, when the provider is using #power-domain-cells = <1>, this could potentially become as fine-grained as of_genpd_add_provider_simple().

Saravana, do think we can extend fw_devlink to take this into account somehow?

Quoted 19 lines
Quoted 19 lines
Quoted 10 lines
Quoted 9 lines

Another option would be to allow an opt-out behavior for some genpd's that are powered-on at initialization. Something along the lines of the below.

From: Ulf Hansson <[email protected]>
Date: Tue, 29 Jul 2025 14:27:22 +0200
Subject: [PATCH] pmdomain: core: Allow powered-on PM domains to be powered-off
during boot

Quoted 6 lines

[...]

I gave this a try (i.e. "| GENPD_FLAG_NO_STAY_ON" in rcar-sysc.c), but this doesn't make any difference. I assume this would only work when actively calling genpd_power_off() (i.e. not from of_genpd_sync_state() or genpd_provider_sync_state())?

Right. Thanks for testing!

Quoted 8 lines
Quoted 5 lines

So, we may need to restore some part of the genpd_power_off_unused() when CONFIG_PM_GENERIC_DOMAINS_OF is set. Without clearing "genpd->stay_on".

I can extend the patch, if you think it would make sense for you?

I would applaud anything that would fix these regressions. Thanks!

While being mostly silent from my side for a while, I have been continuing to evolve my test suite for sync_state tests. Wanted to make sure I cover additional new corner cases that you have pointed out for Renesas platforms.

That said, I have not observed any issues on my side, so it looks like we are simply facing new behaviors that you have pointed out to be a problem. In this regards, I think it's important to note that we are currently only seeing problems for those genpds that are powered-on when the provider driver calls pm_genpd_init(). Another simple option is to power-off those PM domains that we know is not really needed to be powered-on. Also not perfect, but an option.

Another option is something along the lines of what I posted, but perhaps extending it to let the late_initcall_sync to try to power-off the unused PM domains.

I will work on updating the patch so we can try it out - or perhaps what you suggested above with a device-specific flag taken into account by fw_devlink_dev_sync_state() would be better/sufficient you think?

Kind regards
Uffe

#61 lore raw

Hi Ulf,

Quoted 113 lines · Ulf Hansson
Quoted 112 lines · Geert Uytterhoeven
Quoted 110 lines · Ulf Hansson
Quoted 89 lines · Geert Uytterhoeven
Quoted 63 lines · Ulf Hansson
Quoted 54 lines · Geert Uytterhoeven
Quoted 28 lines · Ulf Hansson
Quoted 27 lines · Geert Uytterhoeven
Quoted 11 lines · Ulf Hansson
Quoted 5 lines · Ulf Hansson

Changes in v3:
- Added a couple of patches to adress problems on some Renesas platforms. Thanks Geert and Tomi for helping out!
- Adressed a few comments from Saravanna and Konrad.
- Added some tested-by tags.

I decided it was time to give this a try, so I have queued this up for v6.17 via the next branch at my pmdomain tree.

If you encounter any issues, please let me know so I can help to fix them.

Thanks for your series! Due to holidays, I only managed to test this very recently.

Unfortunately I have an issue with unused PM Domains no longer being disabled on R-Car:
- On R-Car Gen1/2/3, using rcar-sysc.c, unused PM Domains are never disabled.
- On R-Car Gen4, using rcar-gen4-sysc.c, unused PM Domains are sometimes not disabled.
At first, I noticed the IOMMU driver was not enabled in my config, and enabling it did fix the issue. However, after that I still encountered the issue in a different config that does have the IOMMU driver enabled...

Quoted 6 lines
Quoted 6 lines

FTR, unused PM Domains are still disabled correctly on R/SH-Mobile (using rmobile-sysc.c) and on BeagleBone Black. Note that these use of_genpd_add_provider_simple(), while all R-Car drivers use of_genpd_add_provider_onecell(). Perhaps there is an issue with the latter? If you don't have a clue, I plan to do some more investigation later...

of_genpd_add_provider_onecell() has:

    if (!dev)
            sync_state = true;
    else
            dev_set_drv_sync_state(dev, genpd_sync_state);

    for (i = 0; i < data->num_domains; i++) {
            ...
            if (sync_state && !genpd_is_no_sync_state(genpd)) {
                    genpd->sync_state = GENPD_SYNC_STATE_ONECELL;
                    device_set_node(&genpd->dev, fwnode);
                    sync_state = false;
                    ^^^^^^^^^^^^^^^^^^^
            }
            ...
    }
Quoted 7 lines

As the R-Car SYSC drivers are not platform drivers, dev is NULL, and genpd->sync_state is set to GENPD_SYNC_STATE_ONECELL for the first PM Domain only. All other domains have the default value of sync_state (0 = GENPD_SYNC_STATE_OFF). Hence when genpd_provider_sync_state() is called later, it ignores all but the first domain. Apparently this is intentional, as of_genpd_sync_state() tries to power off all domains handled by the same controller anyway (see below)?

Quoted 6 lines

Right, this is intentional and mainly because of how fw_devlink works.

fw_devlink is limited to use only the first device - if multiple devices share the same fwnode. In principle, we could have picked any of the devices in the array of genpds here - and reached the same result.

OK, just like I already assumed...

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

BTW, the "pending due to"-messages look weird to me. On R-Car M2-W (r8a7791.dtsi) I see e.g.:

genpd_provider ca15-cpu0: sync_state() pending due to e6020000.watchdog renesas-cpg-mssr e6150000.clock-controller: sync_state() pending
due to e6020000.watchdog

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

ca15-cpu0 is the PM Domain holding the first CPU core, while the watchdog resides in the always-on Clock Domain, and uses the clock-controller for PM_CLK handling.

Unfortunately the first PM Domain is "ca15-cpu0", which is blocked on these bogus pending states, and no PM Domain is powered off.

I see, thanks for the details. I am looking closer at this.

Quoted 8 lines
Quoted 3 lines

In any case, this is the main issue, as it prevents the ->sync_state() callback to be called. Hence the "genpd->stay_on" will also *not* be cleared for any of the genpd's for the genpd-provider.

I was under the impression there is a time-out, after which the .sync_state() callback would be called anyway, just like for probe deferral due to missing optional providers like DMACs and IOMMUs. Apparently that is not the case?

The behaviour is configurable, so it depends. The current default behaviour does *not* enforce the ->sync_state() callbacks to be called, even after a time-out.

You may set CONFIG_FW_DEVLINK_SYNC_STATE_TIMEOUT to achieve the above behavior or use the fw_devlink command line parameters to change it. Like setting "fw_devlink.sync_state=timeout".

I guess it can be debated what the default behaviour should be. Perhaps we should even allow the default behaviour to be dynamically tweaked on a per provider device/driver basis?

Quoted 8 lines
Quoted 3 lines

The domains are indeed powered off like before when passing "fw_devlink.sync_state=timeout", so that fixes the regression. But it was not needed before...

Right, the default behavior in genpd has changed. The approach was taken as we believed that original behavior was not correct.

Although, the current situation isn't good as it causes lot of churns for us.

I did some more testing, and there seems to be a similar issue with DMA controllers, which I hadn't really noticed before, as I have DMAC drivers built-in in all my kernel configs. If the (optional) DMAC driver is not available, you need "fw_devlink=permissive" to make drivers probe devices that have (optional) DMA support. Interestingly, that is not the case with (optional) IOMMU support:
drivers do probe devices that have (optional) DMA support when the latter is not available.

Quoted 54 lines
Quoted 7 lines

I could add "select FW_DEVLINK_SYNC_STATE_TIMEOUT" to the SYSC_RCAR and SYSC_RCAR_GEN4 Kconfig options, but that would play badly with multi-platform kernels. As the fw_devlink_sync_state flag is static, the R-Car SYSC drivers can't just auto-enable the flag at runtime.

Any other options? Perhaps a device-specific flag to be set by the PM Domain driver, and to be checked by fw_devlink_dev_sync_state()?

Something along those lines seems reasonable to me too.

However, the remaining question though, is what should be the default behavior in genpd for this. Due to all the churns, we may want something that is closer to what we had *before*, which means to always use the timeout option, unless the genpd provider driver explicitly requests to not to (an opt-out genpd config flag).

Saravana, it would be nice to get some thoughts from you are around this? Does it make sense?

Quoted 35 lines
Quoted 34 lines
Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

If I remove the "sync_state = false" above, genpd_provider_sync_state() considers all domains, and does power down all unused domains (even multiple times, as expected).

I think those are getting called because with the change above, there is no device_link being tracked. As stated above, fw_devlink is limited to use only one device - if multiple devices share the same fwnode.

Quoted 7 lines

Indeed.

Quoted 2 lines

In other words, the ->sync_state() callbacks are called even if the corresponding consumer devices have not been probed yet.

Hence shouldn't there be a timeout, as the kernel may not even have a driver for one or more consumer devices?

See above.

Quoted 14 lines
Quoted 14 lines
Quoted 10 lines

Upon closer look, all "pending due to" messages I see claim that the first (index 0) PM Domain is pending on some devices, while all of these devices are part of a different domain (usually the always-on domain, which is always the last (32 or 64) on R-Car).

So I think there are two issues:
1. Devices are not attributed to the correct PM Domain using fw_devlink sync_state,
2. One PM Domain of a multi-domain controller being blocked should not block all other domains handled by the same controller.

Right, that's a current limitation with fw_devlink. To cope with this, it's possible to enforce the ->sync_state() callback to be invoked from user-space (timeout or explicitly) for a device.

Quoted 8 lines
Quoted 5 lines

That needs explicit handling, which was not needed before.

Perhaps the fw_devlink creation should be removed again from of_genpd_add_provider_onecell(), as it is not correct, except for the first domain?

There is nothing wrong with it, the behavior is correct, unless I failed to understand your problem. To me the problem is that it is

It does print wrong and confusing warnings indicating the problem:

genpd_provider ca57-cpu0: sync_state() pending due to fe000000.pcie

(no, the PCIe controller is not part of the CPU PM Domain)

Quoted 5 lines

just less fine grained, compared to using of_genpd_add_provider_simple(). All PM domains that is provided by a single power-domain controller that uses #power-domain-cells = <1>, requires all consumers of them to be probed, to allow the sync_state callback to be invoked.

if it would be just coarse-grained, the link should be created to a device representing the controller, not to the device representing the first PM domain.

Quoted 6 lines

If we could teach fw_devlink to take into account the power-domain-*id* that is specified by the consumer node, when the provider is using #power-domain-cells = <1>, this could potentially become as fine-grained as of_genpd_add_provider_simple().

Saravana, do think we can extend fw_devlink to take this into account somehow?

Doesn't the pmdomain core create a device for each PM domain, so the index could be used to link to the correct domain?

Quoted 40 lines
Quoted 18 lines
Quoted 18 lines
Quoted 9 lines
Quoted 8 lines

Another option would be to allow an opt-out behavior for some genpd's that are powered-on at initialization. Something along the lines of the below.

From: Ulf Hansson <[email protected]>
Date: Tue, 29 Jul 2025 14:27:22 +0200
Subject: [PATCH] pmdomain: core: Allow powered-on PM domains to be powered-off
during boot

Quoted 6 lines

[...]

I gave this a try (i.e. "| GENPD_FLAG_NO_STAY_ON" in rcar-sysc.c), but this doesn't make any difference. I assume this would only work when actively calling genpd_power_off() (i.e. not from of_genpd_sync_state() or genpd_provider_sync_state())?

Right. Thanks for testing!

Quoted 8 lines
Quoted 5 lines

So, we may need to restore some part of the genpd_power_off_unused() when CONFIG_PM_GENERIC_DOMAINS_OF is set. Without clearing "genpd->stay_on".

I can extend the patch, if you think it would make sense for you?

I would applaud anything that would fix these regressions. Thanks!

While being mostly silent from my side for a while, I have been continuing to evolve my test suite for sync_state tests. Wanted to make sure I cover additional new corner cases that you have pointed out for Renesas platforms.

That said, I have not observed any issues on my side, so it looks like we are simply facing new behaviors that you have pointed out to be a problem. In this regards, I think it's important to note that we are currently only seeing problems for those genpds that are powered-on when the provider driver calls pm_genpd_init(). Another simple option is to power-off those PM domains that we know is not really needed to be powered-on. Also not perfect, but an option.

Quoted 3 lines

Another option is something along the lines of what I posted, but perhaps extending it to let the late_initcall_sync to try to power-off the unused PM domains.

Yep, like before.

Quoted 4 lines

I will work on updating the patch so we can try it out - or perhaps what you suggested above with a device-specific flag taken into account by fw_devlink_dev_sync_state() would be better/sufficient you think?

I also had a closer look at the few pending sync_state() pending warnings I do see on SH/R-Mobile SoCs. Their PM Domain driver uses of_genpd_add_provider_simple() instead of of_genpd_add_provider_onecell(). E.g. on R-Mobile A1:

genpd_provider a3sm: sync_state() pending due to f0100000.cache-controller genpd_provider a4s: sync_state() pending due to fe400000.memory-controller genpd_provider d4: sync_state() pending due to ptm

All three domains were already handled specially in the PM Domain driver, as they must not be turned off, so these platforms didn't regress due to this series.

Thanks!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
#62 lore raw

[...]

Quoted 44 lines
Quoted 44 lines
Quoted 33 lines
Quoted 33 lines
Quoted 16 lines
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

BTW, the "pending due to"-messages look weird to me. On R-Car M2-W (r8a7791.dtsi) I see e.g.:

genpd_provider ca15-cpu0: sync_state() pending due to e6020000.watchdog renesas-cpg-mssr e6150000.clock-controller: sync_state() pending
due to e6020000.watchdog

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

ca15-cpu0 is the PM Domain holding the first CPU core, while the watchdog resides in the always-on Clock Domain, and uses the clock-controller for PM_CLK handling.

Unfortunately the first PM Domain is "ca15-cpu0", which is blocked on these bogus pending states, and no PM Domain is powered off.

I see, thanks for the details. I am looking closer at this.

Quoted 8 lines
Quoted 3 lines

In any case, this is the main issue, as it prevents the ->sync_state() callback to be called. Hence the "genpd->stay_on" will also *not* be cleared for any of the genpd's for the genpd-provider.

I was under the impression there is a time-out, after which the .sync_state() callback would be called anyway, just like for probe deferral due to missing optional providers like DMACs and IOMMUs. Apparently that is not the case?

The behaviour is configurable, so it depends. The current default behaviour does *not* enforce the ->sync_state() callbacks to be called, even after a time-out.

You may set CONFIG_FW_DEVLINK_SYNC_STATE_TIMEOUT to achieve the above behavior or use the fw_devlink command line parameters to change it. Like setting "fw_devlink.sync_state=timeout".

Quoted 7 lines
Quoted 3 lines

I guess it can be debated what the default behaviour should be. Perhaps we should even allow the default behaviour to be dynamically tweaked on a per provider device/driver basis?

The domains are indeed powered off like before when passing "fw_devlink.sync_state=timeout", so that fixes the regression. But it was not needed before...

Right, the default behavior in genpd has changed. The approach was taken as we believed that original behavior was not correct.

Quoted 7 lines
Quoted 1 line

Although, the current situation isn't good as it causes lot of churns for us.

I did some more testing, and there seems to be a similar issue with DMA controllers, which I hadn't really noticed before, as I have DMAC drivers built-in in all my kernel configs. If the (optional) DMAC driver is not available, you need "fw_devlink=permissive" to make drivers probe devices that have (optional) DMA support.

Well, after the deferred probe timeout, the missing supplier depency should be ignored even if you don't have "permissive".

Typically we get a print in the log that could say:
"pm-test-drv pm_test24: deferred probe timeout, ignoring dependency"

... and then the driver-core tries probing the device anyway. It's then up to the consumer driver to allow probing to succeed, even if the DMA setup procedure fails.

Quoted 3 lines

Interestingly, that is not the case with (optional) IOMMU support:
drivers do probe devices that have (optional) DMA support when the latter is not available.

Okay, so some special treatments are already in place for IOMMUs, to allow them to probe sooner, I guess. I don't know in detail how this works, maybe Saravana can help to fill in?

Although my guess is that, by allowing IOMMUs to probe like this, means that these drivers need to manage the DMA setup quite differently.

The DMA driver (supplier) may probe and become available *after* the IOMMU driver has probed. In other words, the IOMMU drivers then need to manage the DMA setup even beyond probing.

Quoted 61 lines
Quoted 61 lines
Quoted 8 lines

I could add "select FW_DEVLINK_SYNC_STATE_TIMEOUT" to the SYSC_RCAR and SYSC_RCAR_GEN4 Kconfig options, but that would play badly with multi-platform kernels. As the fw_devlink_sync_state flag is static, the R-Car SYSC drivers can't just auto-enable the flag at runtime.

Any other options? Perhaps a device-specific flag to be set by the PM Domain driver, and to be checked by fw_devlink_dev_sync_state()?

Something along those lines seems reasonable to me too.

However, the remaining question though, is what should be the default behavior in genpd for this. Due to all the churns, we may want something that is closer to what we had *before*, which means to always use the timeout option, unless the genpd provider driver explicitly requests to not to (an opt-out genpd config flag).

Saravana, it would be nice to get some thoughts from you are around this? Does it make sense?

Quoted 40 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 4 lines

If I remove the "sync_state = false" above, genpd_provider_sync_state() considers all domains, and does power down all unused domains (even multiple times, as expected).

I think those are getting called because with the change above, there is no device_link being tracked. As stated above, fw_devlink is limited to use only one device - if multiple devices share the same fwnode.

Indeed.

Quoted 22 lines
Quoted 5 lines
Quoted 2 lines

In other words, the ->sync_state() callbacks are called even if the corresponding consumer devices have not been probed yet.

Hence shouldn't there be a timeout, as the kernel may not even have a driver for one or more consumer devices?

See above.

Quoted 14 lines
Quoted 14 lines
Quoted 10 lines

Upon closer look, all "pending due to" messages I see claim that the first (index 0) PM Domain is pending on some devices, while all of these devices are part of a different domain (usually the always-on domain, which is always the last (32 or 64) on R-Car).

So I think there are two issues:
1. Devices are not attributed to the correct PM Domain using fw_devlink sync_state,
2. One PM Domain of a multi-domain controller being blocked should not block all other domains handled by the same controller.

Right, that's a current limitation with fw_devlink. To cope with this, it's possible to enforce the ->sync_state() callback to be invoked from user-space (timeout or explicitly) for a device.

That needs explicit handling, which was not needed before.

Perhaps the fw_devlink creation should be removed again from of_genpd_add_provider_onecell(), as it is not correct, except for the first domain?

Quoted 8 lines
Quoted 2 lines

There is nothing wrong with it, the behavior is correct, unless I failed to understand your problem. To me the problem is that it is

It does print wrong and confusing warnings indicating the problem:

genpd_provider ca57-cpu0: sync_state() pending due to fe000000.pcie

(no, the PCIe controller is not part of the CPU PM Domain)

That's a good point. We should fix this to avoid confusion.

Quoted 16 lines
Quoted 6 lines

just less fine grained, compared to using of_genpd_add_provider_simple(). All PM domains that is provided by a single power-domain controller that uses #power-domain-cells = <1>, requires all consumers of them to be probed, to allow the sync_state callback to be invoked.

if it would be just coarse-grained, the link should be created to a device representing the controller, not to the device representing the first PM domain.

Quoted 5 lines

If we could teach fw_devlink to take into account the power-domain-*id* that is specified by the consumer node, when the provider is using #power-domain-cells = <1>, this could potentially become as fine-grained as of_genpd_add_provider_simple().

Quoted 4 lines
Quoted 1 line

Saravana, do think we can extend fw_devlink to take this into account somehow?

Doesn't the pmdomain core create a device for each PM domain, so the index could be used to link to the correct domain?

Correct, we have a device associated for each PM domain - and when of_genpd_add_provider_onecell() is called, we get the index associated for each of them.

If I understand your proposal, you are suggesting that genpd itself creates the device_link between its corresponding device (supplier) and the upcoming consumer device(s), at the point when of_genpd_add_provider_onecell() is called, right?

It's an interesting idea, but I am not sure it will work. To create the device_link at this point, assumes that all the consumer OF-nodes have been populated (to have devices available for them). Maybe there is an intermediate step we can take to instruct fw_devlink to treat these "links" differently?

Saravana, any thoughts around this?

Quoted 41 lines
Quoted 41 lines
Quoted 19 lines
Quoted 19 lines
Quoted 10 lines
Quoted 9 lines

Another option would be to allow an opt-out behavior for some genpd's that are powered-on at initialization. Something along the lines of the below.

From: Ulf Hansson <[email protected]>
Date: Tue, 29 Jul 2025 14:27:22 +0200
Subject: [PATCH] pmdomain: core: Allow powered-on PM domains to be powered-off
during boot

Quoted 6 lines

[...]

I gave this a try (i.e. "| GENPD_FLAG_NO_STAY_ON" in rcar-sysc.c), but this doesn't make any difference. I assume this would only work when actively calling genpd_power_off() (i.e. not from of_genpd_sync_state() or genpd_provider_sync_state())?

Right. Thanks for testing!

Quoted 8 lines
Quoted 5 lines

So, we may need to restore some part of the genpd_power_off_unused() when CONFIG_PM_GENERIC_DOMAINS_OF is set. Without clearing "genpd->stay_on".

I can extend the patch, if you think it would make sense for you?

I would applaud anything that would fix these regressions. Thanks!

While being mostly silent from my side for a while, I have been continuing to evolve my test suite for sync_state tests. Wanted to make sure I cover additional new corner cases that you have pointed out for Renesas platforms.

That said, I have not observed any issues on my side, so it looks like we are simply facing new behaviors that you have pointed out to be a problem. In this regards, I think it's important to note that we are currently only seeing problems for those genpds that are powered-on when the provider driver calls pm_genpd_init(). Another simple option is to power-off those PM domains that we know is not really needed to be powered-on. Also not perfect, but an option.

Quoted 5 lines
Quoted 3 lines

Another option is something along the lines of what I posted, but perhaps extending it to let the late_initcall_sync to try to power-off the unused PM domains.

Yep, like before.

Okay!

Quoted 11 lines
Quoted 5 lines

I will work on updating the patch so we can try it out - or perhaps what you suggested above with a device-specific flag taken into account by fw_devlink_dev_sync_state() would be better/sufficient you think?

I also had a closer look at the few pending sync_state() pending warnings I do see on SH/R-Mobile SoCs. Their PM Domain driver uses of_genpd_add_provider_simple() instead of of_genpd_add_provider_onecell(). E.g. on R-Mobile A1:

Quoted 7 lines

genpd_provider a3sm: sync_state() pending due to f0100000.cache-controller genpd_provider a4s: sync_state() pending due to fe400000.memory-controller genpd_provider d4: sync_state() pending due to ptm

All three domains were already handled specially in the PM Domain driver, as they must not be turned off, so these platforms didn't regress due to this series.

Okay!

Again the prints are confusing and annoying, but in principle we are fine. Thanks for clarifying!

This also makes me wonder if we should skip enabling the fw_devlink support for those genpds with "simple" providers that are special (GENPD_FLAG_ALWAYS_ON and GENPD_FLAG_RPM_ALWAYS_ON). It doesn't make sense to track consumers for them, I think.

[...]

Kind regards
Uffe

#63 lore raw

Hi Ulf,

Quoted 55 lines · Ulf Hansson
Quoted 44 lines
Quoted 44 lines
Quoted 33 lines
Quoted 33 lines
Quoted 16 lines
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

BTW, the "pending due to"-messages look weird to me. On R-Car M2-W (r8a7791.dtsi) I see e.g.:

genpd_provider ca15-cpu0: sync_state() pending due to e6020000.watchdog renesas-cpg-mssr e6150000.clock-controller: sync_state() pending
due to e6020000.watchdog

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

ca15-cpu0 is the PM Domain holding the first CPU core, while the watchdog resides in the always-on Clock Domain, and uses the clock-controller for PM_CLK handling.

Unfortunately the first PM Domain is "ca15-cpu0", which is blocked on these bogus pending states, and no PM Domain is powered off.

I see, thanks for the details. I am looking closer at this.

Quoted 8 lines
Quoted 3 lines

In any case, this is the main issue, as it prevents the ->sync_state() callback to be called. Hence the "genpd->stay_on" will also *not* be cleared for any of the genpd's for the genpd-provider.

I was under the impression there is a time-out, after which the .sync_state() callback would be called anyway, just like for probe deferral due to missing optional providers like DMACs and IOMMUs. Apparently that is not the case?

The behaviour is configurable, so it depends. The current default behaviour does *not* enforce the ->sync_state() callbacks to be called, even after a time-out.

You may set CONFIG_FW_DEVLINK_SYNC_STATE_TIMEOUT to achieve the above behavior or use the fw_devlink command line parameters to change it. Like setting "fw_devlink.sync_state=timeout".

Quoted 7 lines
Quoted 3 lines

I guess it can be debated what the default behaviour should be. Perhaps we should even allow the default behaviour to be dynamically tweaked on a per provider device/driver basis?

The domains are indeed powered off like before when passing "fw_devlink.sync_state=timeout", so that fixes the regression. But it was not needed before...

Right, the default behavior in genpd has changed. The approach was taken as we believed that original behavior was not correct.

Quoted 7 lines
Quoted 1 line

Although, the current situation isn't good as it causes lot of churns for us.

I did some more testing, and there seems to be a similar issue with DMA controllers, which I hadn't really noticed before, as I have DMAC drivers built-in in all my kernel configs. If the (optional) DMAC driver is not available, you need "fw_devlink=permissive" to make drivers probe devices that have (optional) DMA support.

Well, after the deferred probe timeout, the missing supplier depency should be ignored even if you don't have "permissive".

Quoted 6 lines

Typically we get a print in the log that could say:
"pm-test-drv pm_test24: deferred probe timeout, ignoring dependency"

... and then the driver-core tries probing the device anyway. It's then up to the consumer driver to allow probing to succeed, even if the DMA setup procedure fails.

Well, that didn't seem to work. Perhaps we still have some drivers that do not handle -EPROBE_DEFER correctly. Will check...

Quoted 61 lines
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

Upon closer look, all "pending due to" messages I see claim that the first (index 0) PM Domain is pending on some devices, while all of these devices are part of a different domain (usually the always-on domain, which is always the last (32 or 64) on R-Car).

So I think there are two issues:
1. Devices are not attributed to the correct PM Domain using fw_devlink sync_state,
2. One PM Domain of a multi-domain controller being blocked should not block all other domains handled by the same controller.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Right, that's a current limitation with fw_devlink. To cope with this, it's possible to enforce the ->sync_state() callback to be invoked from user-space (timeout or explicitly) for a device.

That needs explicit handling, which was not needed before.

Perhaps the fw_devlink creation should be removed again from of_genpd_add_provider_onecell(), as it is not correct, except for the first domain?

Quoted 8 lines
Quoted 2 lines

There is nothing wrong with it, the behavior is correct, unless I failed to understand your problem. To me the problem is that it is

It does print wrong and confusing warnings indicating the problem:

genpd_provider ca57-cpu0: sync_state() pending due to fe000000.pcie

(no, the PCIe controller is not part of the CPU PM Domain)

That's a good point. We should fix this to avoid confusion.

Quoted 15 lines
Quoted 5 lines

just less fine grained, compared to using of_genpd_add_provider_simple(). All PM domains that is provided by a single power-domain controller that uses #power-domain-cells = <1>, requires all consumers of them to be probed, to allow the sync_state callback to be invoked.

if it would be just coarse-grained, the link should be created to a device representing the controller, not to the device representing the first PM domain.

Quoted 5 lines

If we could teach fw_devlink to take into account the power-domain-*id* that is specified by the consumer node, when the provider is using #power-domain-cells = <1>, this could potentially become as fine-grained as of_genpd_add_provider_simple().

Quoted 4 lines
Quoted 1 line

Saravana, do think we can extend fw_devlink to take this into account somehow?

Doesn't the pmdomain core create a device for each PM domain, so the index could be used to link to the correct domain?

Correct, we have a device associated for each PM domain - and when of_genpd_add_provider_onecell() is called, we get the index associated for each of them.

If I understand your proposal, you are suggesting that genpd itself creates the device_link between its corresponding device (supplier) and the upcoming consumer device(s), at the point when of_genpd_add_provider_onecell() is called, right?

Quoted 5 lines

It's an interesting idea, but I am not sure it will work. To create the device_link at this point, assumes that all the consumer OF-nodes have been populated (to have devices available for them). Maybe there is an intermediate step we can take to instruct fw_devlink to treat these "links" differently?

I am not sure where these links are created. In the example above "ca57-cpu0" is the device name of the supplier, but that is not the name of a platform device. Doesn't the core create devlinks between platform devices? If yes, who creates this link to a non-platform device, and can that code be updated easily to take into account the index cell?

Quoted 15 lines
Quoted 5 lines

I also had a closer look at the few pending sync_state() pending warnings I do see on SH/R-Mobile SoCs. Their PM Domain driver uses of_genpd_add_provider_simple() instead of of_genpd_add_provider_onecell(). E.g. on R-Mobile A1:

Quoted 7 lines

genpd_provider a3sm: sync_state() pending due to f0100000.cache-controller genpd_provider a4s: sync_state() pending due to fe400000.memory-controller genpd_provider d4: sync_state() pending due to ptm

All three domains were already handled specially in the PM Domain driver, as they must not be turned off, so these platforms didn't regress due to this series.

Okay!

Quoted 7 lines

Again the prints are confusing and annoying, but in principle we are fine. Thanks for clarifying!

This also makes me wonder if we should skip enabling the fw_devlink support for those genpds with "simple" providers that are special (GENPD_FLAG_ALWAYS_ON and GENPD_FLAG_RPM_ALWAYS_ON). It doesn't make sense to track consumers for them, I think.

Makes sense.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
#64 lore raw
In reply to Geert Uytterhoeven
Quoted 72 lines · Geert Uytterhoeven

Hi Ulf,

Quoted 28 lines · Ulf Hansson
Quoted 27 lines · Geert Uytterhoeven
Quoted 11 lines · Ulf Hansson
Quoted 5 lines · Ulf Hansson

Changes in v3:
- Added a couple of patches to adress problems on some Renesas platforms. Thanks Geert and Tomi for helping out!
- Adressed a few comments from Saravanna and Konrad.
- Added some tested-by tags.

I decided it was time to give this a try, so I have queued this up for v6.17 via the next branch at my pmdomain tree.

If you encounter any issues, please let me know so I can help to fix them.

Thanks for your series! Due to holidays, I only managed to test this very recently.

Unfortunately I have an issue with unused PM Domains no longer being disabled on R-Car:
- On R-Car Gen1/2/3, using rcar-sysc.c, unused PM Domains are never disabled.
- On R-Car Gen4, using rcar-gen4-sysc.c, unused PM Domains are sometimes not disabled.
At first, I noticed the IOMMU driver was not enabled in my config, and enabling it did fix the issue. However, after that I still encountered the issue in a different config that does have the IOMMU driver enabled...

Quoted 6 lines
Quoted 6 lines

FTR, unused PM Domains are still disabled correctly on R/SH-Mobile (using rmobile-sysc.c) and on BeagleBone Black. Note that these use of_genpd_add_provider_simple(), while all R-Car drivers use of_genpd_add_provider_onecell(). Perhaps there is an issue with the latter? If you don't have a clue, I plan to do some more investigation later...

of_genpd_add_provider_onecell() has:

    if (!dev)
            sync_state = true;
    else
            dev_set_drv_sync_state(dev, genpd_sync_state);

    for (i = 0; i < data->num_domains; i++) {
            ...
            if (sync_state && !genpd_is_no_sync_state(genpd)) {
                    genpd->sync_state = GENPD_SYNC_STATE_ONECELL;
                    device_set_node(&genpd->dev, fwnode);
                    sync_state = false;
                    ^^^^^^^^^^^^^^^^^^^
            }
            ...
    }

As the R-Car SYSC drivers are not platform drivers, dev is NULL, and genpd->sync_state is set to GENPD_SYNC_STATE_ONECELL for the first PM Domain only. All other domains have the default value of sync_state (0 = GENPD_SYNC_STATE_OFF). Hence when genpd_provider_sync_state() is called later, it ignores all but the first domain. Apparently this is intentional, as of_genpd_sync_state() tries to power off all domains handled by the same controller anyway (see below)?

Quoted 7 lines
Quoted 7 lines

BTW, the "pending due to"-messages look weird to me. On R-Car M2-W (r8a7791.dtsi) I see e.g.:

genpd_provider ca15-cpu0: sync_state() pending due to e6020000.watchdog renesas-cpg-mssr e6150000.clock-controller: sync_state() pending
due to e6020000.watchdog

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

ca15-cpu0 is the PM Domain holding the first CPU core, while the watchdog resides in the always-on Clock Domain, and uses the clock-controller for PM_CLK handling.

Unfortunately the first PM Domain is "ca15-cpu0", which is blocked on these bogus pending states, and no PM Domain is powered off.

Hi Geert,

Thanks for all the reports as ever!

Can you explain why you call these as bogus? Sorry if you already explained it. But the reason I'm asking is to see if you can set a flag for the watchdog device so fw_devlink will completely ignore it.

It looks like there's a driver for this watchdog node? Why is it not probing then?

Quoted 5 lines

If I remove the "sync_state = false" above, genpd_provider_sync_state() considers all domains, and does power down all unused domains (even multiple times, as expected).

Quoted 8 lines

Upon closer look, all "pending due to" messages I see claim that the first (index 0) PM Domain is pending on some devices, while all of these devices are part of a different domain (usually the always-on domain, which is always the last (32 or 64) on R-Car).

So I think there are two issues:
1. Devices are not attributed to the correct PM Domain using fw_devlink sync_state,

Is it a fw_devlink issue? Or is this a multi-domain controller?

Quoted 2 lines

2. One PM Domain of a multi-domain controller being blocked should not block all other domains handled by the same controller.

This is going to take a while to sort out. But the current behavior is the safest. How grumpy will you be if we don't fix this :)

Thanks,
Saravana

#65 lore raw

Hi Saravana,

Quoted 14 lines · Saravana Kannan
Quoted 13 lines · Geert Uytterhoeven
Quoted 11 lines · Ulf Hansson
Quoted 10 lines · Geert Uytterhoeven

BTW, the "pending due to"-messages look weird to me. On R-Car M2-W (r8a7791.dtsi) I see e.g.:

genpd_provider ca15-cpu0: sync_state() pending due to e6020000.watchdog renesas-cpg-mssr e6150000.clock-controller: sync_state() pending
due to e6020000.watchdog

ca15-cpu0 is the PM Domain holding the first CPU core, while the watchdog resides in the always-on Clock Domain, and uses the clock-controller for PM_CLK handling.

Quoted 6 lines
Quoted 2 lines

Unfortunately the first PM Domain is "ca15-cpu0", which is blocked on these bogus pending states, and no PM Domain is powered off.

Can you explain why you call these as bogus? Sorry if you already explained it. But the reason I'm asking is to see if you can set a flag for the watchdog device so fw_devlink will completely ignore it.

"bogus" refers to "1." below.

Furthermore, devices that are located in an alway-on domain should not block the sync state.

Quoted 2 lines

It looks like there's a driver for this watchdog node? Why is it not probing then?

Because this particular revision of the SoC has a hardware bug that prevents the watchdog timer from rebooting the system, and the driver detects that.

Anyway, if the driver is not available, unused power domains should still be powered down, like before.

Quoted 9 lines
Quoted 9 lines

If I remove the "sync_state = false" above, genpd_provider_sync_state() considers all domains, and does power down all unused domains (even multiple times, as expected).

Upon closer look, all "pending due to" messages I see claim that the first (index 0) PM Domain is pending on some devices, while all of these devices are part of a different domain (usually the always-on domain, which is always the last (32 or 64) on R-Car).

Quoted 5 lines
Quoted 3 lines

So I think there are two issues:
1. Devices are not attributed to the correct PM Domain using fw_devlink sync_state,

Is it a fw_devlink issue? Or is this a multi-domain controller?

This is a multi-domain controller.

Quoted 5 lines
Quoted 2 lines

2. One PM Domain of a multi-domain controller being blocked should not block all other domains handled by the same controller.

This is going to take a while to sort out. But the current behavior is the safest. How grumpy will you be if we don't fix this :)

Depending on your definition of "safe". Keeping all power domains on increases power consumption and heat generation, and may cause e.g. CPU frequency throttling to kick in, slowing down operation of the system.

Thanks!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
#66 lore raw
Quoted 60 lines · Geert Uytterhoeven

Hi Saravana,

Quoted 14 lines · Saravana Kannan
Quoted 13 lines · Geert Uytterhoeven
Quoted 11 lines · Ulf Hansson
Quoted 10 lines · Geert Uytterhoeven

BTW, the "pending due to"-messages look weird to me. On R-Car M2-W (r8a7791.dtsi) I see e.g.:

genpd_provider ca15-cpu0: sync_state() pending due to e6020000.watchdog renesas-cpg-mssr e6150000.clock-controller: sync_state() pending
due to e6020000.watchdog

ca15-cpu0 is the PM Domain holding the first CPU core, while the watchdog resides in the always-on Clock Domain, and uses the clock-controller for PM_CLK handling.

Quoted 6 lines
Quoted 2 lines

Unfortunately the first PM Domain is "ca15-cpu0", which is blocked on these bogus pending states, and no PM Domain is powered off.

Can you explain why you call these as bogus? Sorry if you already explained it. But the reason I'm asking is to see if you can set a flag for the watchdog device so fw_devlink will completely ignore it.

"bogus" refers to "1." below.

Furthermore, devices that are located in an alway-on domain should not block the sync state.

Quoted 2 lines

It looks like there's a driver for this watchdog node? Why is it not probing then?

Because this particular revision of the SoC has a hardware bug that prevents the watchdog timer from rebooting the system, and the driver detects that.

Anyway, if the driver is not available, unused power domains should still be powered down, like before.

Quoted 9 lines
Quoted 9 lines

If I remove the "sync_state = false" above, genpd_provider_sync_state() considers all domains, and does power down all unused domains (even multiple times, as expected).

Upon closer look, all "pending due to" messages I see claim that the first (index 0) PM Domain is pending on some devices, while all of these devices are part of a different domain (usually the always-on domain, which is always the last (32 or 64) on R-Car).

Quoted 5 lines
Quoted 3 lines

So I think there are two issues:
1. Devices are not attributed to the correct PM Domain using fw_devlink sync_state,

Is it a fw_devlink issue? Or is this a multi-domain controller?

This is a multi-domain controller.

Quoted 3 lines
Quoted 2 lines

2. One PM Domain of a multi-domain controller being blocked should not block all other domains handled by the same controller.

Quoted 6 lines
Quoted 2 lines

This is going to take a while to sort out. But the current behavior is the safest. How grumpy will you be if we don't fix this :)

Depending on your definition of "safe". Keeping all power domains on increases power consumption and heat generation, and may cause e.g. CPU frequency throttling to kick in, slowing down operation of the system.

FYI, I agree that we need to address these problems, in one way or the other. I am trying to summarize them and have also proposed a CFP for LPC (power/thermal MC) to discuss and try to solve them.

Now, as I also proposed in the other thread [1] just now. How about changing the default behaviour from FW_DEVLINK_SYNC_STATE_STRICT to FW_DEVLINK_SYNC_STATE_TIMEOUT? I think that would solve a lot of problems for us, as it would provide a more similar behaviour to what we had in genpd originally, hence it would be a smoother transition.

I think this would be true when trying to add ->sync_state() support for other subsystems too, like clocks and regulators.

In the end, when platforms are ready to move to the "strict" mode, they can do that via the command-line parameter, for example.

Kind regards
Uffe

[1]
https://lore.kernel.org/all/[email protected]/

#67 lore raw

Hi Ulf,

Quoted 61 lines · Ulf Hansson
Quoted 60 lines · Geert Uytterhoeven
Quoted 14 lines · Saravana Kannan
Quoted 13 lines · Geert Uytterhoeven
Quoted 11 lines · Ulf Hansson
Quoted 10 lines · Geert Uytterhoeven

BTW, the "pending due to"-messages look weird to me. On R-Car M2-W (r8a7791.dtsi) I see e.g.:

genpd_provider ca15-cpu0: sync_state() pending due to e6020000.watchdog renesas-cpg-mssr e6150000.clock-controller: sync_state() pending
due to e6020000.watchdog

ca15-cpu0 is the PM Domain holding the first CPU core, while the watchdog resides in the always-on Clock Domain, and uses the clock-controller for PM_CLK handling.

Quoted 6 lines
Quoted 2 lines

Unfortunately the first PM Domain is "ca15-cpu0", which is blocked on these bogus pending states, and no PM Domain is powered off.

Can you explain why you call these as bogus? Sorry if you already explained it. But the reason I'm asking is to see if you can set a flag for the watchdog device so fw_devlink will completely ignore it.

"bogus" refers to "1." below.

Furthermore, devices that are located in an alway-on domain should not block the sync state.

Quoted 2 lines

It looks like there's a driver for this watchdog node? Why is it not probing then?

Because this particular revision of the SoC has a hardware bug that prevents the watchdog timer from rebooting the system, and the driver detects that.

Anyway, if the driver is not available, unused power domains should still be powered down, like before.

Quoted 9 lines
Quoted 9 lines

If I remove the "sync_state = false" above, genpd_provider_sync_state() considers all domains, and does power down all unused domains (even multiple times, as expected).

Upon closer look, all "pending due to" messages I see claim that the first (index 0) PM Domain is pending on some devices, while all of these devices are part of a different domain (usually the always-on domain, which is always the last (32 or 64) on R-Car).

Quoted 5 lines
Quoted 3 lines

So I think there are two issues:
1. Devices are not attributed to the correct PM Domain using fw_devlink sync_state,

Is it a fw_devlink issue? Or is this a multi-domain controller?

This is a multi-domain controller.

Quoted 5 lines
Quoted 2 lines

2. One PM Domain of a multi-domain controller being blocked should not block all other domains handled by the same controller.

This is going to take a while to sort out. But the current behavior is the safest. How grumpy will you be if we don't fix this :)

Quoted 7 lines
Quoted 3 lines

Depending on your definition of "safe". Keeping all power domains on increases power consumption and heat generation, and may cause e.g. CPU frequency throttling to kick in, slowing down operation of the system.

FYI, I agree that we need to address these problems, in one way or the other. I am trying to summarize them and have also proposed a CFP for LPC (power/thermal MC) to discuss and try to solve them.

OK, CU there! ;-)

Quoted 11 lines

Now, as I also proposed in the other thread [1] just now. How about changing the default behaviour from FW_DEVLINK_SYNC_STATE_STRICT to FW_DEVLINK_SYNC_STATE_TIMEOUT? I think that would solve a lot of problems for us, as it would provide a more similar behaviour to what we had in genpd originally, hence it would be a smoother transition.

I think this would be true when trying to add ->sync_state() support for other subsystems too, like clocks and regulators.

In the end, when platforms are ready to move to the "strict" mode, they can do that via the command-line parameter, for example.

Thanks, changing the default to timeout sounds good to me!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
#68 lore raw
In reply to Ulf Hansson

Hi Ulf,

Quoted 11 lines · Ulf Hansson
Quoted 5 lines · Ulf Hansson

Changes in v3:
- Added a couple of patches to adress problems on some Renesas platforms. Thanks Geert and Tomi for helping out!
- Adressed a few comments from Saravanna and Konrad.
- Added some tested-by tags.

I decided it was time to give this a try, so I have queued this up for v6.17 via the next branch at my pmdomain tree.

If you encounter any issues, please let me know so I can help to fix them.

FTR, I discovered two more issues with clock drivers registering a genpd OF provider from CLK_OF_DECLARE(), which is now too early:
1. drivers/clk/mmp/clk-of-mmp2.c,
2. drivers/clk/renesas/clk-mstp.c.

I have submitted a fix for the second driver: "[PATCH] clk: renesas:
mstp: Add genpd OF provider at postcore_initcall()"
https://lore.kernel.org/all/81ef5f8d5d31374b7852b05453c52d2f735062a2.1755073087.git.geert+renesas@glider.be

I don't have MMP2 hardware, I guess it needs a similar fix.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
#69 lore raw
In reply to Ulf Hansson

Hi Ulf,

Quoted 18 lines · Ulf Hansson

Changes in v3:
- Added a couple of patches to adress problems on some Renesas platforms. Thanks Geert and Tomi for helping out!
- Adressed a few comments from Saravanna and Konrad.
- Added some tested-by tags.

Changes in v2:
- Well, quite a lot as I discovered various problems when doing additional testing of corner-case. I suggest re-review from scratch, even if I decided to keep some reviewed-by tags.
- Added patches to allow some drivers that needs to align or opt-out from the new common behaviour in genpd.

If a PM domain (genpd) is powered-on during boot, there is probably a good reason for it. Therefore it's known to be a bad idea to allow such genpd to be powered-off before all of its consumer devices have been probed. This series intends to fix this problem.

Quoted 5 lines

We have been discussing these issues at LKML and at various Linux-conferences in the past. I have therefore tried to include the people I can recall being involved, but I may have forgotten some (my apologies), feel free to loop them in.

Quoted 1 line

I have tested this with QEMU with a bunch of local test-drivers and

DT nodes.

Quoted 3 lines

Let me know if you want me to share this code too.

Please help review and test!

During testing on a TI platform, I observed new kernel warnings after applying this patch series:

ti_sci_pm_domains 44043000.system-controller:power-controller: sync_state() pending due to fd00000.gpu

These warnings occur when a device (in this case, the GPU) has no driver bound to it. The fw_devlink_dev_sync_state[0] in the core has a check before printing this warning. It checks whether the device driver has a sync_state handler OR the device bus has a sync_state handler in the dev_has_sync_state[1]. If both conditions are false, fw_devlink_dev_sync_state[0] performs an early return before printing the warning.

Before this patch series, both handlers were absent for device driver ti_sci_pm_domains and the device bus, so both conditions failed and no warnings were printed.

This patch series adds a sync_state handler for the bus, which now satisfies the second condition. So it doesn't do an early return and proceeds to print the warning.

[0]: https://elixir.bootlin.com/linux/v6.16/source/drivers/base/core.c#L1777
[1]: https://elixir.bootlin.com/linux/v6.16/source/include/linux/device.h#L909

Thanks
Sebin

Quoted 55 lines

Finally, a big thanks to Saravana for all the support!

Kind regards
Ulf Hansson

Saravana Kannan (1):
driver core: Add dev_set_drv_sync_state()

Ulf Hansson (23):
pmdomain: renesas: rcar-sysc: Add genpd OF provider at
postcore_initcall
pmdomain: renesas: rmobile-sysc: Move init to postcore_initcall
pmdomain: renesas: rcar-gen4-sysc: Move init to postcore_initcall
pmdomain: core: Prevent registering devices before the bus
pmdomain: core: Add a bus and a driver for genpd providers
pmdomain: core: Add the genpd->dev to the genpd provider bus
pmdomain: core: Export a common ->sync_state() helper for genpd
providers
pmdomain: core: Prepare to add the common ->sync_state() support soc/tegra: pmc: Opt-out from genpd's common ->sync_state() support
cpuidle: psci: Opt-out from genpd's common ->sync_state() support
cpuidle: riscv-sbi: Opt-out from genpd's common ->sync_state() support
pmdomain: qcom: rpmpd: Use of_genpd_sync_state()
pmdomain: qcom: rpmhpd: Use of_genpd_sync_state() firmware/pmdomain: xilinx: Move ->sync_state() support to firmware
driver
firmware: xilinx: Don't share zynqmp_pm_init_finalize()
firmware: xilinx: Use of_genpd_sync_state()
driver core: Export get_dev_from_fwnode()
pmdomain: core: Add common ->sync_state() support for genpd providers
pmdomain: core: Default to use of_genpd_sync_state() for genpd
providers
pmdomain: core: Leave powered-on genpds on until late_initcall_sync
pmdomain: core: Leave powered-on genpds on until sync_state
cpuidle: psci: Drop redundant sync_state support
cpuidle: riscv-sbi: Drop redundant sync_state support

  drivers/base/core.c                         |   8 +-
  drivers/cpuidle/cpuidle-psci-domain.c       |  14 --
  drivers/cpuidle/cpuidle-riscv-sbi.c         |  14 --
  drivers/firmware/xilinx/zynqmp.c            |  18 +-
  drivers/pmdomain/core.c                     | 211 ++++++++++++++++++--
  drivers/pmdomain/qcom/rpmhpd.c              |   2 +
  drivers/pmdomain/qcom/rpmpd.c               |   2 +
  drivers/pmdomain/renesas/rcar-gen4-sysc.c   |   2 +-
  drivers/pmdomain/renesas/rcar-sysc.c        |  19 +-
  drivers/pmdomain/renesas/rmobile-sysc.c     |   3 +-
  drivers/pmdomain/xilinx/zynqmp-pm-domains.c |  16 --
  drivers/soc/tegra/pmc.c                     |  26 ++-
  include/linux/device.h                      |  13 ++
  include/linux/firmware/xlnx-zynqmp.h        |   6 -
  include/linux/pm_domain.h                   |  17 ++
  15 files changed, 291 insertions(+), 80 deletions(-)
#70 lore raw
Quoted 46 lines · Sebin Francis

Hi Ulf,

Quoted 18 lines · Ulf Hansson

Changes in v3:
- Added a couple of patches to adress problems on some Renesas platforms. Thanks Geert and Tomi for helping out!
- Adressed a few comments from Saravanna and Konrad.
- Added some tested-by tags.

Changes in v2:
- Well, quite a lot as I discovered various problems when doing additional testing of corner-case. I suggest re-review from scratch, even if I decided to keep some reviewed-by tags.
- Added patches to allow some drivers that needs to align or opt-out from the new common behaviour in genpd.

If a PM domain (genpd) is powered-on during boot, there is probably a good reason for it. Therefore it's known to be a bad idea to allow such genpd to be powered-off before all of its consumer devices have been probed. This series intends to fix this problem.

Quoted 5 lines

We have been discussing these issues at LKML and at various Linux-conferences in the past. I have therefore tried to include the people I can recall being involved, but I may have forgotten some (my apologies), feel free to loop them in.

Quoted 1 line

I have tested this with QEMU with a bunch of local test-drivers and

DT nodes.

Quoted 3 lines

Let me know if you want me to share this code too.

Please help review and test!

During testing on a TI platform, I observed new kernel warnings after applying this patch series:

ti_sci_pm_domains 44043000.system-controller:power-controller:
sync_state() pending due to fd00000.gpu

These warnings occur when a device (in this case, the GPU) has no driver bound to it. The fw_devlink_dev_sync_state[0] in the core has a check before printing this warning. It checks whether the device driver has a sync_state handler OR the device bus has a sync_state handler in the dev_has_sync_state[1]. If both conditions are false, fw_devlink_dev_sync_state[0] performs an early return before printing the warning.

Quoted 7 lines

Before this patch series, both handlers were absent for device driver ti_sci_pm_domains and the device bus, so both conditions failed and no warnings were printed.

This patch series adds a sync_state handler for the bus, which now satisfies the second condition. So it doesn't do an early return and proceeds to print the warning.

Thanks for the report and testing!

Indeed this is the new and expected behaviour. I agree that it's certainly questionable if those prints should be at the warning level.

We should probably downgrade those to dev_info(), at least. Let me send a patch to see what Saravana and others are thinking about it!

Quoted 7 lines

[0]: https://elixir.bootlin.com/linux/v6.16/source/drivers/base/core.c#L1777
[1]:
https://elixir.bootlin.com/linux/v6.16/source/include/linux/device.h#L909

Thanks
Sebin

[...]

Kind regards
Uffe

#71 lore raw

Hi,

Quoted 37 lines · Ulf Hansson
Quoted 28 lines · Sebin Francis
Quoted 6 lines · Ulf Hansson

If a PM domain (genpd) is powered-on during boot, there is probably a good reason for it. Therefore it's known to be a bad idea to allow such genpd to be powered-off before all of its consumer devices have been probed. This series intends to fix this problem.

Quoted 6 lines

We have been discussing these issues at LKML and at various Linux-conferences in the past. I have therefore tried to include the people I can recall being involved, but I may have forgotten some (my apologies), feel free to loop them in.

Please help review and test!

During testing on a TI platform, I observed new kernel warnings after applying this patch series:

ti_sci_pm_domains 44043000.system-controller:power-controller:
sync_state() pending due to fd00000.gpu

These warnings occur when a device (in this case, the GPU) has no driver bound to it. The fw_devlink_dev_sync_state[0] in the core has a check before printing this warning. It checks whether the device driver has a sync_state handler OR the device bus has a sync_state handler in the dev_has_sync_state[1]. If both conditions are false, fw_devlink_dev_sync_state[0] performs an early return before printing the warning.

Quoted 7 lines

Before this patch series, both handlers were absent for device driver ti_sci_pm_domains and the device bus, so both conditions failed and no warnings were printed.

This patch series adds a sync_state handler for the bus, which now satisfies the second condition. So it doesn't do an early return and proceeds to print the warning.

Quoted 7 lines

Thanks for the report and testing!

Indeed this is the new and expected behaviour. I agree that it's certainly questionable if those prints should be at the warning level.

We should probably downgrade those to dev_info(), at least. Let me send a patch to see what Saravana and others are thinking about it!

I want to report that I see similar warnings on Rock64 (rk3328):

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

This is with a 6.17-rc3 kernel with various rkvdec patches and in dmesg I later see msgs wrt ff300000.gpu (lima) and ff350000.video-codec (hantro-vpu), but not ff360000.video-codec (rkvdec). Full dmesg:
https://paste.sr.ht/~diederik/951b54ea8422756e5efaa61d6bcefb575cfe28a4

But there were also USB issues (not sure why), so I rebooted and then I did see msgs wrt rkvdec. Full dmesg:
https://paste.sr.ht/~diederik/156f65fc6be05d02484568dfd303c46ba76b3a8e

I also have a 6.17-rc4 kernel which is clean upstream, thus without any media patches. This time no USB issues (also no USB device plugged in) and I see msgs wrt lima and hantro-vpu, but not rkvdec. Full dmesg:
https://paste.sr.ht/~diederik/4affea034b0c9fb522a8ad5b90e8b59b4bd856ec

What's possibly relevant is that the 6.17-rc3+unreleased kernel also has this patch added, which adds 'power-domain@RK3328_PD_GPU' to rk3328.dtsi
https://lore.kernel.org/linux-rockchip/[email protected]/

I actually found this thread because I too couldn't find the commit ID Nicolas referenced in this post:
https://lore.kernel.org/linux-rockchip/20250902-rk3576-lockup-regression-v1-1-c4a0c9daeb00@collabora.com/

I have no idea whether it's related though (I have no rk3576 device).

I haven't tried (yet) whether the sync_state() msg is also present on other Rockchip based devices.

Cheers,
Diederik