Skip to contentSkip to conversation

pmdomain: imx: Keep the domains left on by the bootloader

PATCH In review Dario Binacchi 3 participants 11 messages Nov 22 – Nov 25

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

v4 cover pmdomain: imx: Keep the domains left on by the bootloader

The i.MX8M power domain drivers register all their domains as off. A domain left on by the bootloader, e.g. to show a splash screen, is then powered up again by its first consumer, which on the i.MX8MN turns the display off and hangs the system.

This series reads the state of the domains from the hardware, so that the ones left on are kept on until their consumers have probed.

The first patch fixes an error path of the blk-ctrl probe. The clocks held by the last patch are released at sync_state, so they stay on until all the consumers of the blk-ctrl have probed.

Tested on i.MX8MN (BSH SMM S2 PRO).

Changes in v4:
- Register the power notifier before powering up the bus domain

Changes in v3:
- Add Reported-by and Closes tags
- Drop the runtime PM reference synchronously in the probe error path
- Keep the bus domain on while the state of the domains is read
- Remove the domains before releasing their boot-on references

Changes in v2:
- New patch
- Release the resources of the domains left on when the driver is removed
- Take the references once the probe can no longer be deferred
- Clear the boot-on state when the domain is powered off
- Release the references when the driver is removed
- Rebase on the changes of the previous patch

Dario Binacchi (4):
pmdomain: imx8m-blk-ctrl: Remove the power notifier on probe failure
pmdomain: imx: gpcv2: Keep the domains left on by the bootloader
pmdomain: imx8m-blk-ctrl: Keep the domains left on by the bootloader
pmdomain: imx8m-blk-ctrl: Hold boot-on domain clocks until sync_state

 drivers/pmdomain/imx/gpcv2.c          |  77 ++++++++++++-
 drivers/pmdomain/imx/imx8m-blk-ctrl.c | 156 ++++++++++++++++++++++++--
 2 files changed, 223 insertions(+), 10 deletions(-)

---
base-commit: d0f871bfb831705d9f55479f5b2b40f636ea7b16
branch: imx-pmdomain-boot-on-v4

Signature · 1 line
2.43.0
#1 lore raw

PATCH v4 1/4 pmdomain: imx8m-blk-ctrl: Remove the power notifier on probe failure

If devm_of_platform_populate() fails, the probe returns leaving the power notifier registered on the bus power domain, while the memory holding it is released. Remove it.

Fixes 9cb6d1b39a8f ("soc: imx: imx8m-blk-ctrl: Scan subnodes and bind drivers to them")

---

(no changes since v3)

Changes in v3:
- Add Reported-by and Closes tags

Changes in v2:
- New patch

 drivers/pmdomain/imx/imx8m-blk-ctrl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pmdomain/imx/imx8m-blk-ctrl.c +3 -1
index 9df933a7a238..7d6735728d8c 100644
@@ -345,10 +345,12 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 
 	ret = devm_of_platform_populate(dev);
 	if (ret)
-		goto cleanup_provider;
+		goto cleanup_notifier;
 
 	return 0;
 
+cleanup_notifier:
+	dev_pm_genpd_remove_notifier(bc->bus_power_dev);
 cleanup_provider:
 	of_genpd_del_provider(dev->of_node);
 cleanup_pds:
Signature · 1 line
2.43.0
Reviewed-by on v4 1/4
#2 lore raw

Re: [PATCH v4 1/4] pmdomain: imx8m-blk-ctrl: Remove the power notifier on probe failure

Quoted 10 lines · Dario Binacchi

If devm_of_platform_populate() fails, the probe returns leaving the power notifier registered on the bus power domain, while the memory holding it is released. Remove it.

Fixes 9cb6d1b39a8f ("soc: imx: imx8m-blk-ctrl: Scan subnodes and bind drivers to them")

---

Quoted 34 lines

(no changes since v3)

Changes in v3:
- Add Reported-by and Closes tags

Changes in v2:
- New patch

 drivers/pmdomain/imx/imx8m-blk-ctrl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pmdomain/imx/imx8m-blk-ctrl.c +3 -2
index 9df933a7a238..7d6735728d8c 100644
@@ -345,10 +345,12 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 
 	ret = devm_of_platform_populate(dev);
 	if (ret)
-		goto cleanup_provider;
+		goto cleanup_notifier;
 
 	return 0;
 
+cleanup_notifier:
+	dev_pm_genpd_remove_notifier(bc->bus_power_dev);
 cleanup_provider:
 	of_genpd_del_provider(dev->of_node);
 cleanup_pds:
--

2.43.0

Reviewed-by Peng Fan on v4 1/4
#3 lore raw

Re: [PATCH v4 1/4] pmdomain: imx8m-blk-ctrl: Remove the power notifier on probe failure

In reply to Dario Binacchi
Quoted 9 lines · On Sun, 22 Nov 2026 21:51:10 +0100 Dario Binacchi…

If devm_of_platform_populate() fails, the probe returns leaving the power notifier registered on the bus power domain, while the memory holding it is released. Remove it.

Fixes 9cb6d1b39a8f ("soc: imx: imx8m-blk-ctrl: Scan subnodes and bind drivers to them")
#4 lore raw

PATCH v4 2/4 pmdomain: imx: gpcv2: Keep the domains left on by the bootloader

In reply to Dario Binacchi

The PGC domains are all registered as off, so a domain left on by the bootloader, e.g. DISPMIX to show a splash screen, is powered up again by its first consumer. On the i.MX8MN this turns the display off and hangs the system.

The GPC does not report the power state of a domain, but the ADB400 bridge acknowledges the power-up handshake only while the domain is powered. Use it to register as on the domains left on by the bootloader.

---

(no changes since v3)

Changes in v3:
- Drop the runtime PM reference synchronously in the probe error path

Changes in v2:
- Release the resources of the domains left on when the driver is removed

 drivers/pmdomain/imx/gpcv2.c | 77 +++++++++++++++++++++++++++++++++++-
 1 file changed, 75 insertions(+), 2 deletions(-)
drivers/pmdomain/imx/gpcv2.c +75 -2
index 6a54ee734514..f8f2d38c1b2a 100644
@@ -292,6 +292,7 @@ struct imx_pgc_domain {
 
 	const int voltage;
 	const bool keep_clocks;
+	bool boot_on;	/* Left on by the bootloader */
 	struct device *dev;
 
 	unsigned int pgc_sw_pup_reg;
@@ -488,6 +489,8 @@ static int imx_pgc_power_down(struct generic_pm_domain *genpd)
 
 	pm_runtime_put_sync_suspend(domain->dev);
 
+	domain->boot_on = false;
+
 	return 0;
 
 out_clk_disable:
@@ -1315,9 +1318,27 @@ static const struct imx_pgc_domain_data imx8mn_pgc_domain_data = {
 	.pgc_regs = &imx7_pgc_regs,
 };
 
+/*
+ * The GPC does not report the power state of a domain, but the ADB400
+ * acknowledges the power-up handshake only while the domain is powered.
+ */
+static bool imx_pgc_domain_is_on(struct imx_pgc_domain *domain)
+{
+	u32 val;
+
+	if (!domain->bits.hskack)
+		return false;
+
+	if (regmap_read(domain->regmap, domain->regs->hsk, &val))
+		return false;
+
+	return (val & domain->bits.hskack) == domain->bits.hskack;
+}
+
 static int imx_pgc_domain_probe(struct platform_device *pdev)
 {
 	struct imx_pgc_domain *domain = pdev->dev.platform_data;
+	bool init_off;
 	int ret;
 
 	domain->dev = &pdev->dev;
@@ -1348,12 +1369,44 @@ static int imx_pgc_domain_probe(struct platform_device *pdev)
 		regmap_update_bits(domain->regmap, domain->regs->map,
 				   domain->bits.map, domain->bits.map);
 
-	ret = pm_genpd_init(&domain->genpd, NULL, true);
+	init_off = !imx_pgc_domain_is_on(domain);
+	ret = pm_genpd_init(&domain->genpd, NULL, init_off);
 	if (ret) {
 		dev_err_probe(domain->dev, ret, "Failed to init power domain\n");
 		goto out_domain_unmap;
 	}
 
+	/* Balance the first imx_pgc_power_down() */
+	if (!init_off) {
+		ret = pm_runtime_resume_and_get(domain->dev);
+		if (ret < 0) {
+			dev_err_probe(domain->dev, ret,
+				      "Failed to resume domain\n");
+			goto out_genpd_remove;
+		}
+
+		if (!IS_ERR(domain->regulator)) {
+			ret = regulator_enable(domain->regulator);
+			if (ret) {
+				dev_err_probe(domain->dev, ret,
+					      "Failed to enable domain's regulator\n");
+				goto out_put_pm;
+			}
+		}
+
+		if (domain->keep_clocks) {
+			ret = clk_bulk_prepare_enable(domain->num_clks,
+						      domain->clks);
+			if (ret) {
+				dev_err_probe(domain->dev, ret,
+					      "Failed to enable domain's clocks\n");
+				goto out_regulator_disable;
+			}
+		}
+
+		domain->boot_on = true;
+	}
+
 	if (IS_ENABLED(CONFIG_LOCKDEP) &&
 	    of_property_present(domain->dev->of_node, "power-domains"))
 		lockdep_set_subclass(&domain->genpd.mlock, 1);
@@ -1362,11 +1415,20 @@ static int imx_pgc_domain_probe(struct platform_device *pdev)
 					   &domain->genpd);
 	if (ret) {
 		dev_err_probe(domain->dev, ret, "Failed to add genpd provider\n");
-		goto out_genpd_remove;
+		goto out_clk_disable;
 	}
 
 	return 0;
 
+out_clk_disable:
+	if (!init_off && domain->keep_clocks)
+		clk_bulk_disable_unprepare(domain->num_clks, domain->clks);
+out_regulator_disable:
+	if (!init_off && !IS_ERR(domain->regulator))
+		regulator_disable(domain->regulator);
+out_put_pm:
+	if (!init_off)
+		pm_runtime_put_sync(domain->dev);
 out_genpd_remove:
 	pm_genpd_remove(&domain->genpd);
 out_domain_unmap:
@@ -1385,6 +1447,17 @@ static void imx_pgc_domain_remove(struct platform_device *pdev)
 	of_genpd_del_provider(domain->dev->of_node);
 	pm_genpd_remove(&domain->genpd);
 
+	if (domain->boot_on) {
+		if (domain->keep_clocks)
+			clk_bulk_disable_unprepare(domain->num_clks,
+						   domain->clks);
+
+		if (!IS_ERR(domain->regulator))
+			regulator_disable(domain->regulator);
+
+		pm_runtime_put_sync(domain->dev);
+	}
+
 	if (domain->bits.map)
 		regmap_update_bits(domain->regmap, domain->regs->map,
 				   domain->bits.map, 0);
Signature · 1 line
2.43.0
Reviewed-by Peng Fan on v4 2/4
#5 lore raw

Re: [PATCH v4 2/4] pmdomain: imx: gpcv2: Keep the domains left on by the bootloader

Quoted 5 lines · On Sun, 22 Nov 2026 21:51:11 +0100 Dario Binacchi…

The PGC domains are all registered as off, so a domain left on by the bootloader, e.g. DISPMIX to show a splash screen, is powered up again by its first consumer. On the i.MX8MN this turns the display off and hangs the system.

Quoted 9 lines

The GPC does not report the power state of a domain, but the ADB400 bridge acknowledges the power-up handshake only while the domain is powered. Use it to register as on the domains left on by the bootloader.

#6 lore raw

PATCH v4 3/4 pmdomain: imx8m-blk-ctrl: Keep the domains left on by the bootloader

In reply to Dario Binacchi

The blk-ctrl domains are all registered as off, so a domain left on by the bootloader is powered up again by its first consumer. On the i.MX8MN this resets the display pipeline set up by U-Boot to show a splash screen.

Read the state of the domains from the blk-ctrl registers and register as on the ones left on by the bootloader.

Enable this only for the i.MX8MN DISP blk-ctrl, as on other blk-ctrls (e.g. the i.MX8MP VPUMIX) the registers do not reset to 0.

---

Changes in v4:
- Register the power notifier before powering up the bus domain

Changes in v3:
- Keep the bus domain on while the state of the domains is read
- Remove the domains before releasing their boot-on references

Changes in v2:
- Take the references once the probe can no longer be deferred
- Clear the boot-on state when the domain is powered off
- Release the references when the driver is removed

 drivers/pmdomain/imx/imx8m-blk-ctrl.c | 128 +++++++++++++++++++++++---
 1 file changed, 117 insertions(+), 11 deletions(-)
drivers/pmdomain/imx/imx8m-blk-ctrl.c +117 -11
index 7d6735728d8c..04383d7e40cb 100644
@@ -83,10 +83,13 @@ struct imx8m_blk_ctrl_domain {
 	struct device *power_dev;
 	struct imx8m_blk_ctrl *bc;
 	int num_paths;
+	bool boot_on;	/* Left on by the bootloader */
 };
 
 struct imx8m_blk_ctrl_data {
 	int max_reg;
+	/* SFT_RSTN and CLK_EN reset to 0, so a domain left on can be detected */
+	bool boot_state_readable;
 	notifier_fn_t power_notifier_fn;
 	const struct imx8m_blk_ctrl_domain_data *domains;
 	int num_domains;
@@ -187,18 +190,87 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
 	/* allow bus domain to suspend */
 	pm_runtime_put(bc->bus_power_dev);
 
+	domain->boot_on = false;
+
 	return 0;
 }
 
 static struct lock_class_key blk_ctrl_genpd_lock_class;
 
+/*
+ * A domain left on by the bootloader has its resets deasserted and its
+ * clocks enabled. The registers can only be read if the bus domain is
+ * on, so a domain is considered off whenever the bus domain is off.
+ */
+static bool imx8m_blk_ctrl_is_off(struct imx8m_blk_ctrl *bc,
+				  const struct imx8m_blk_ctrl_data *bc_data,
+				  const struct imx8m_blk_ctrl_domain_data *data)
+{
+	u32 rst, clk, mipi = 0;
+
+	if (!bc_data->boot_state_readable)
+		return true;
+
+	if (regmap_read(bc->regmap, BLK_SFT_RSTN, &rst) ||
+	    regmap_read(bc->regmap, BLK_CLK_EN, &clk))
+		return true;
+
+	if (data->mipi_phy_rst_mask &&
+	    regmap_read(bc->regmap, BLK_MIPI_RESET_DIV, &mipi))
+		return true;
+
+	return (rst & data->rst_mask) != data->rst_mask ||
+	       (clk & data->clk_mask) != data->clk_mask ||
+	       (mipi & data->mipi_phy_rst_mask) != data->mipi_phy_rst_mask;
+}
+
+/* Take the references of imx8m_blk_ctrl_power_on() for a domain left on */
+static int imx8m_blk_ctrl_get_boot_on(struct imx8m_blk_ctrl_domain *domain)
+{
+	struct imx8m_blk_ctrl *bc = domain->bc;
+	int ret;
+
+	ret = pm_runtime_resume_and_get(bc->bus_power_dev);
+	if (ret < 0) {
+		dev_err(bc->dev, "failed to power up bus domain\n");
+		return ret;
+	}
+
+	ret = pm_runtime_resume_and_get(domain->power_dev);
+	if (ret < 0) {
+		dev_err(bc->dev, "failed to power up peripheral domain\n");
+		pm_runtime_put(bc->bus_power_dev);
+		return ret;
+	}
+
+	if (icc_bulk_set_bw(domain->num_paths, domain->paths))
+		dev_err(bc->dev, "failed to set icc bw\n");
+
+	domain->boot_on = true;
+
+	return 0;
+}
+
+static void imx8m_blk_ctrl_put_boot_on(struct imx8m_blk_ctrl_domain *domain)
+{
+	if (!domain->boot_on)
+		return;
+
+	/* Sync, to power down the bus domain before its notifier is removed */
+	pm_runtime_put_sync(domain->power_dev);
+	pm_runtime_put_sync(domain->bc->bus_power_dev);
+	domain->boot_on = false;
+}
+
 static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 {
 	const struct imx8m_blk_ctrl_data *bc_data;
 	struct device *dev = &pdev->dev;
 	struct imx8m_blk_ctrl *bc;
 	void __iomem *base;
+	unsigned long boot_on = 0, bit;
 	int i, ret;
+	bool init_off;
 
 	struct regmap_config regmap_config = {
 		.reg_bits	= 32,
@@ -250,6 +322,23 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 					     "failed to attach power domain \"bus\"\n");
 	}
 
+	bc->power_nb.notifier_call = bc_data->power_notifier_fn;
+	ret = dev_pm_genpd_add_notifier(bc->bus_power_dev, &bc->power_nb);
+	if (ret) {
+		dev_err_probe(dev, ret, "failed to add power notifier\n");
+		goto cleanup_bus;
+	}
+
+	if (bc_data->boot_state_readable) {
+		/* Keep the bus domain on while the state is read */
+		ret = pm_runtime_resume_and_get(bc->bus_power_dev);
+		if (ret < 0) {
+			dev_err_probe(dev, ret,
+				      "failed to power up bus domain\n");
+			goto cleanup_notifier;
+		}
+	}
+
 	for (i = 0; i < bc_data->num_domains; i++) {
 		const struct imx8m_blk_ctrl_domain_data *data = &bc_data->domains[i];
 		struct imx8m_blk_ctrl_domain *domain = &bc->domains[i];
@@ -303,7 +392,8 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 		domain->genpd.power_off = imx8m_blk_ctrl_power_off;
 		domain->bc = bc;
 
-		ret = pm_genpd_init(&domain->genpd, NULL, true);
+		init_off = imx8m_blk_ctrl_is_off(bc, bc_data, data);
+		ret = pm_genpd_init(&domain->genpd, NULL, init_off);
 		if (ret) {
 			dev_err_probe(dev, ret,
 				      "failed to init power domain \"%s\"\n",
@@ -312,6 +402,9 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 			goto cleanup_pds;
 		}
 
+		if (!init_off)
+			boot_on |= BIT(i);
+
 		/*
 		 * We use runtime PM to trigger power on/off of the upstream GPC
 		 * domain, as a strict hierarchical parent/child power domain
@@ -328,37 +421,48 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 		bc->onecell_data.domains[i] = &domain->genpd;
 	}
 
+	/*
+	 * The probe can no longer be deferred. Releasing these references
+	 * would power down the domains left on by the bootloader.
+	 */
+	for_each_set_bit(bit, &boot_on, bc_data->num_domains) {
+		ret = imx8m_blk_ctrl_get_boot_on(&bc->domains[bit]);
+		if (ret)
+			goto cleanup_pds;
+	}
+
 	ret = of_genpd_add_provider_onecell(dev->of_node, &bc->onecell_data);
 	if (ret) {
 		dev_err_probe(dev, ret, "failed to add power domain provider\n");
 		goto cleanup_pds;
 	}
 
-	bc->power_nb.notifier_call = bc_data->power_notifier_fn;
-	ret = dev_pm_genpd_add_notifier(bc->bus_power_dev, &bc->power_nb);
-	if (ret) {
-		dev_err_probe(dev, ret, "failed to add power notifier\n");
-		goto cleanup_provider;
-	}
-
 	dev_set_drvdata(dev, bc);
 
 	ret = devm_of_platform_populate(dev);
 	if (ret)
-		goto cleanup_notifier;
+		goto cleanup_provider;
+
+	if (bc_data->boot_state_readable)
+		pm_runtime_put(bc->bus_power_dev);
 
 	return 0;
 
-cleanup_notifier:
-	dev_pm_genpd_remove_notifier(bc->bus_power_dev);
 cleanup_provider:
 	of_genpd_del_provider(dev->of_node);
 cleanup_pds:
 	for (i--; i >= 0; i--) {
 		pm_genpd_remove(&bc->domains[i].genpd);
+		imx8m_blk_ctrl_put_boot_on(&bc->domains[i]);
 		dev_pm_domain_detach(bc->domains[i].power_dev, true);
 	}
 
+	if (bc_data->boot_state_readable)
+		pm_runtime_put_sync(bc->bus_power_dev);
+
+cleanup_notifier:
+	dev_pm_genpd_remove_notifier(bc->bus_power_dev);
+cleanup_bus:
 	dev_pm_domain_detach(bc->bus_power_dev, true);
 
 	return ret;
@@ -375,6 +479,7 @@ static void imx8m_blk_ctrl_remove(struct platform_device *pdev)
 		struct imx8m_blk_ctrl_domain *domain = &bc->domains[i];
 
 		pm_genpd_remove(&domain->genpd);
+		imx8m_blk_ctrl_put_boot_on(domain);
 		dev_pm_domain_detach(domain->power_dev, true);
 	}
 
@@ -709,6 +814,7 @@ static const struct imx8m_blk_ctrl_domain_data imx8mn_disp_blk_ctl_domain_data[]
 
 static const struct imx8m_blk_ctrl_data imx8mn_disp_blk_ctl_dev_data = {
 	.max_reg = 0x84,
+	.boot_state_readable = true,
 	.power_notifier_fn = imx8mn_disp_power_notifier,
 	.domains = imx8mn_disp_blk_ctl_domain_data,
 	.num_domains = ARRAY_SIZE(imx8mn_disp_blk_ctl_domain_data),
Signature · 1 line
2.43.0
#7 lore raw

Re: [PATCH v4 3/4] pmdomain: imx8m-blk-ctrl: Keep the domains left on by the bootloader

Quoted 4 lines · On Sun, 22 Nov 2026 21:51:12 +0100 Dario Binacchi…

The blk-ctrl domains are all registered as off, so a domain left on by the bootloader is powered up again by its first consumer. On the i.MX8MN this resets the display pipeline set up by U-Boot to show a splash screen.

Linux will finally take over display. so is there any issue here that resets the display pipeline here? Any I think U-Boot has driver_remove to make it in the initial safe state.

Regards
Peng

Quoted 255 lines

Read the state of the domains from the blk-ctrl registers and register as on the ones left on by the bootloader.

Enable this only for the i.MX8MN DISP blk-ctrl, as on other blk-ctrls (e.g. the i.MX8MP VPUMIX) the registers do not reset to 0.

---

Changes in v4:
- Register the power notifier before powering up the bus domain

Changes in v3:
- Keep the bus domain on while the state of the domains is read
- Remove the domains before releasing their boot-on references

Changes in v2:
- Take the references once the probe can no longer be deferred
- Clear the boot-on state when the domain is powered off
- Release the references when the driver is removed

 drivers/pmdomain/imx/imx8m-blk-ctrl.c | 128 +++++++++++++++++++++++---
 1 file changed, 117 insertions(+), 11 deletions(-)
drivers/pmdomain/imx/imx8m-blk-ctrl.c +117 -11
index 7d6735728d8c..04383d7e40cb 100644
@@ -83,10 +83,13 @@ struct imx8m_blk_ctrl_domain {
 	struct device *power_dev;
 	struct imx8m_blk_ctrl *bc;
 	int num_paths;
+	bool boot_on;	/* Left on by the bootloader */
 };
 
 struct imx8m_blk_ctrl_data {
 	int max_reg;
+	/* SFT_RSTN and CLK_EN reset to 0, so a domain left on can be detected */
+	bool boot_state_readable;
 	notifier_fn_t power_notifier_fn;
 	const struct imx8m_blk_ctrl_domain_data *domains;
 	int num_domains;
@@ -187,18 +190,87 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
 	/* allow bus domain to suspend */
 	pm_runtime_put(bc->bus_power_dev);
 
+	domain->boot_on = false;
+
 	return 0;
 }
 
 static struct lock_class_key blk_ctrl_genpd_lock_class;
 
+/*
+ * A domain left on by the bootloader has its resets deasserted and its
+ * clocks enabled. The registers can only be read if the bus domain is
+ * on, so a domain is considered off whenever the bus domain is off.
+ */
+static bool imx8m_blk_ctrl_is_off(struct imx8m_blk_ctrl *bc,
+				  const struct imx8m_blk_ctrl_data *bc_data,
+				  const struct imx8m_blk_ctrl_domain_data *data)
+{
+	u32 rst, clk, mipi = 0;
+
+	if (!bc_data->boot_state_readable)
+		return true;
+
+	if (regmap_read(bc->regmap, BLK_SFT_RSTN, &rst) ||
+	    regmap_read(bc->regmap, BLK_CLK_EN, &clk))
+		return true;
+
+	if (data->mipi_phy_rst_mask &&
+	    regmap_read(bc->regmap, BLK_MIPI_RESET_DIV, &mipi))
+		return true;
+
+	return (rst & data->rst_mask) != data->rst_mask ||
+	       (clk & data->clk_mask) != data->clk_mask ||
+	       (mipi & data->mipi_phy_rst_mask) != data->mipi_phy_rst_mask;
+}
+
+/* Take the references of imx8m_blk_ctrl_power_on() for a domain left on */
+static int imx8m_blk_ctrl_get_boot_on(struct imx8m_blk_ctrl_domain *domain)
+{
+	struct imx8m_blk_ctrl *bc = domain->bc;
+	int ret;
+
+	ret = pm_runtime_resume_and_get(bc->bus_power_dev);
+	if (ret < 0) {
+		dev_err(bc->dev, "failed to power up bus domain\n");
+		return ret;
+	}
+
+	ret = pm_runtime_resume_and_get(domain->power_dev);
+	if (ret < 0) {
+		dev_err(bc->dev, "failed to power up peripheral domain\n");
+		pm_runtime_put(bc->bus_power_dev);
+		return ret;
+	}
+
+	if (icc_bulk_set_bw(domain->num_paths, domain->paths))
+		dev_err(bc->dev, "failed to set icc bw\n");
+
+	domain->boot_on = true;
+
+	return 0;
+}
+
+static void imx8m_blk_ctrl_put_boot_on(struct imx8m_blk_ctrl_domain *domain)
+{
+	if (!domain->boot_on)
+		return;
+
+	/* Sync, to power down the bus domain before its notifier is removed */
+	pm_runtime_put_sync(domain->power_dev);
+	pm_runtime_put_sync(domain->bc->bus_power_dev);
+	domain->boot_on = false;
+}
+
 static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 {
 	const struct imx8m_blk_ctrl_data *bc_data;
 	struct device *dev = &pdev->dev;
 	struct imx8m_blk_ctrl *bc;
 	void __iomem *base;
+	unsigned long boot_on = 0, bit;
 	int i, ret;
+	bool init_off;
 
 	struct regmap_config regmap_config = {
 		.reg_bits	= 32,
@@ -250,6 +322,23 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 					     "failed to attach power domain \"bus\"\n");
 	}
 
+	bc->power_nb.notifier_call = bc_data->power_notifier_fn;
+	ret = dev_pm_genpd_add_notifier(bc->bus_power_dev, &bc->power_nb);
+	if (ret) {
+		dev_err_probe(dev, ret, "failed to add power notifier\n");
+		goto cleanup_bus;
+	}
+
+	if (bc_data->boot_state_readable) {
+		/* Keep the bus domain on while the state is read */
+		ret = pm_runtime_resume_and_get(bc->bus_power_dev);
+		if (ret < 0) {
+			dev_err_probe(dev, ret,
+				      "failed to power up bus domain\n");
+			goto cleanup_notifier;
+		}
+	}
+
 	for (i = 0; i < bc_data->num_domains; i++) {
 		const struct imx8m_blk_ctrl_domain_data *data = &bc_data->domains[i];
 		struct imx8m_blk_ctrl_domain *domain = &bc->domains[i];
@@ -303,7 +392,8 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 		domain->genpd.power_off = imx8m_blk_ctrl_power_off;
 		domain->bc = bc;
 
-		ret = pm_genpd_init(&domain->genpd, NULL, true);
+		init_off = imx8m_blk_ctrl_is_off(bc, bc_data, data);
+		ret = pm_genpd_init(&domain->genpd, NULL, init_off);
 		if (ret) {
 			dev_err_probe(dev, ret,
 				      "failed to init power domain \"%s\"\n",
@@ -312,6 +402,9 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 			goto cleanup_pds;
 		}
 
+		if (!init_off)
+			boot_on |= BIT(i);
+
 		/*
 		 * We use runtime PM to trigger power on/off of the upstream GPC
 		 * domain, as a strict hierarchical parent/child power domain
@@ -328,37 +421,48 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 		bc->onecell_data.domains[i] = &domain->genpd;
 	}
 
+	/*
+	 * The probe can no longer be deferred. Releasing these references
+	 * would power down the domains left on by the bootloader.
+	 */
+	for_each_set_bit(bit, &boot_on, bc_data->num_domains) {
+		ret = imx8m_blk_ctrl_get_boot_on(&bc->domains[bit]);
+		if (ret)
+			goto cleanup_pds;
+	}
+
 	ret = of_genpd_add_provider_onecell(dev->of_node, &bc->onecell_data);
 	if (ret) {
 		dev_err_probe(dev, ret, "failed to add power domain provider\n");
 		goto cleanup_pds;
 	}
 
-	bc->power_nb.notifier_call = bc_data->power_notifier_fn;
-	ret = dev_pm_genpd_add_notifier(bc->bus_power_dev, &bc->power_nb);
-	if (ret) {
-		dev_err_probe(dev, ret, "failed to add power notifier\n");
-		goto cleanup_provider;
-	}
-
 	dev_set_drvdata(dev, bc);
 
 	ret = devm_of_platform_populate(dev);
 	if (ret)
-		goto cleanup_notifier;
+		goto cleanup_provider;
+
+	if (bc_data->boot_state_readable)
+		pm_runtime_put(bc->bus_power_dev);
 
 	return 0;
 
-cleanup_notifier:
-	dev_pm_genpd_remove_notifier(bc->bus_power_dev);
 cleanup_provider:
 	of_genpd_del_provider(dev->of_node);
 cleanup_pds:
 	for (i--; i >= 0; i--) {
 		pm_genpd_remove(&bc->domains[i].genpd);
+		imx8m_blk_ctrl_put_boot_on(&bc->domains[i]);
 		dev_pm_domain_detach(bc->domains[i].power_dev, true);
 	}
 
+	if (bc_data->boot_state_readable)
+		pm_runtime_put_sync(bc->bus_power_dev);
+
+cleanup_notifier:
+	dev_pm_genpd_remove_notifier(bc->bus_power_dev);
+cleanup_bus:
 	dev_pm_domain_detach(bc->bus_power_dev, true);
 
 	return ret;
@@ -375,6 +479,7 @@ static void imx8m_blk_ctrl_remove(struct platform_device *pdev)
 		struct imx8m_blk_ctrl_domain *domain = &bc->domains[i];
 
 		pm_genpd_remove(&domain->genpd);
+		imx8m_blk_ctrl_put_boot_on(domain);
 		dev_pm_domain_detach(domain->power_dev, true);
 	}
 
@@ -709,6 +814,7 @@ static const struct imx8m_blk_ctrl_domain_data imx8mn_disp_blk_ctl_domain_data[]
 
 static const struct imx8m_blk_ctrl_data imx8mn_disp_blk_ctl_dev_data = {
 	.max_reg = 0x84,
+	.boot_state_readable = true,
 	.power_notifier_fn = imx8mn_disp_power_notifier,
 	.domains = imx8mn_disp_blk_ctl_domain_data,
 	.num_domains = ARRAY_SIZE(imx8mn_disp_blk_ctl_domain_data),
Signature · 1 line
2.43.0

Sent using hkml (https://github.com/sjp38/hackermail)

#8 lore raw

Re: [PATCH v4 3/4] pmdomain: imx8m-blk-ctrl: Keep the domains left on by the bootloader

Quoted 11 lines · Peng Fan (OSS)
Quoted 4 lines · On Sun, 22 Nov 2026 21:51:12 +0100 Dario Binacchi…

The blk-ctrl domains are all registered as off, so a domain left on by the bootloader is powered up again by its first consumer. On the i.MX8MN this resets the display pipeline set up by U-Boot to show a splash screen.

Linux will finally take over display. so is there any issue here that resets the display pipeline here? Any I think U-Boot has driver_remove to make it in the initial safe state.

The bootloader leaves the display on to show a splash screen and hands it over as a simple-framebuffer, so its drivers are not removed on purpose.

With patch 2 the DISPMIX domain is kept on, but the blk-ctrl domains are still registered as off. Their first consumer runs imx8m_blk_ctrl_power_on(),
which puts the LCDIF and the DSIM into reset, so the image of the bootloader is lost before Linux has anything to show.

Keeping the pipeline running is also what the DRM state readout [1] needs to take it over without a modeset. I have an RFC for the i.MX8MN on top of it [2].

Thanks and regards,
Dario

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

Quoted 261 lines

Regards
Peng

Quoted 254 lines

Read the state of the domains from the blk-ctrl registers and register as on the ones left on by the bootloader.

Enable this only for the i.MX8MN DISP blk-ctrl, as on other blk-ctrls (e.g. the i.MX8MP VPUMIX) the registers do not reset to 0.

---

Changes in v4:
- Register the power notifier before powering up the bus domain

Changes in v3:
- Keep the bus domain on while the state of the domains is read
- Remove the domains before releasing their boot-on references

Changes in v2:
- Take the references once the probe can no longer be deferred
- Clear the boot-on state when the domain is powered off
- Release the references when the driver is removed

 drivers/pmdomain/imx/imx8m-blk-ctrl.c | 128 +++++++++++++++++++++++---
 1 file changed, 117 insertions(+), 11 deletions(-)
drivers/pmdomain/imx/imx8m-blk-ctrl.c +117 -12
index 7d6735728d8c..04383d7e40cb 100644
@@ -83,10 +83,13 @@ struct imx8m_blk_ctrl_domain {
      struct device *power_dev;
      struct imx8m_blk_ctrl *bc;
      int num_paths;
+     bool boot_on;   /* Left on by the bootloader */
 };
 
 struct imx8m_blk_ctrl_data {
      int max_reg;
+     /* SFT_RSTN and CLK_EN reset to 0, so a domain left on can be detected */
+     bool boot_state_readable;
      notifier_fn_t power_notifier_fn;
      const struct imx8m_blk_ctrl_domain_data *domains;
      int num_domains;
@@ -187,18 +190,87 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
      /* allow bus domain to suspend */
      pm_runtime_put(bc->bus_power_dev);
 
+     domain->boot_on = false;
+
      return 0;
 }
 
 static struct lock_class_key blk_ctrl_genpd_lock_class;
 
+/*
+ * A domain left on by the bootloader has its resets deasserted and its
+ * clocks enabled. The registers can only be read if the bus domain is
+ * on, so a domain is considered off whenever the bus domain is off.
+ */
+static bool imx8m_blk_ctrl_is_off(struct imx8m_blk_ctrl *bc,
+                               const struct imx8m_blk_ctrl_data *bc_data,
+                               const struct imx8m_blk_ctrl_domain_data *data)
+{
+     u32 rst, clk, mipi = 0;
+
+     if (!bc_data->boot_state_readable)
+             return true;
+
+     if (regmap_read(bc->regmap, BLK_SFT_RSTN, &rst) ||
+         regmap_read(bc->regmap, BLK_CLK_EN, &clk))
+             return true;
+
+     if (data->mipi_phy_rst_mask &&
+         regmap_read(bc->regmap, BLK_MIPI_RESET_DIV, &mipi))
+             return true;
+
+     return (rst & data->rst_mask) != data->rst_mask ||
+            (clk & data->clk_mask) != data->clk_mask ||
+            (mipi & data->mipi_phy_rst_mask) != data->mipi_phy_rst_mask;
+}
+
+/* Take the references of imx8m_blk_ctrl_power_on() for a domain left on */
+static int imx8m_blk_ctrl_get_boot_on(struct imx8m_blk_ctrl_domain *domain)
+{
+     struct imx8m_blk_ctrl *bc = domain->bc;
+     int ret;
+
+     ret = pm_runtime_resume_and_get(bc->bus_power_dev);
+     if (ret < 0) {
+             dev_err(bc->dev, "failed to power up bus domain\n");
+             return ret;
+     }
+
+     ret = pm_runtime_resume_and_get(domain->power_dev);
+     if (ret < 0) {
+             dev_err(bc->dev, "failed to power up peripheral domain\n");
+             pm_runtime_put(bc->bus_power_dev);
+             return ret;
+     }
+
+     if (icc_bulk_set_bw(domain->num_paths, domain->paths))
+             dev_err(bc->dev, "failed to set icc bw\n");
+
+     domain->boot_on = true;
+
+     return 0;
+}
+
+static void imx8m_blk_ctrl_put_boot_on(struct imx8m_blk_ctrl_domain *domain)
+{
+     if (!domain->boot_on)
+             return;
+
+     /* Sync, to power down the bus domain before its notifier is removed */
+     pm_runtime_put_sync(domain->power_dev);
+     pm_runtime_put_sync(domain->bc->bus_power_dev);
+     domain->boot_on = false;
+}
+
 static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 {
      const struct imx8m_blk_ctrl_data *bc_data;
      struct device *dev = &pdev->dev;
      struct imx8m_blk_ctrl *bc;
      void __iomem *base;
+     unsigned long boot_on = 0, bit;
      int i, ret;
+     bool init_off;
 
      struct regmap_config regmap_config = {
              .reg_bits       = 32,
@@ -250,6 +322,23 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
                                           "failed to attach power domain \"bus\"\n");
      }
 
+     bc->power_nb.notifier_call = bc_data->power_notifier_fn;
+     ret = dev_pm_genpd_add_notifier(bc->bus_power_dev, &bc->power_nb);
+     if (ret) {
+             dev_err_probe(dev, ret, "failed to add power notifier\n");
+             goto cleanup_bus;
+     }
+
+     if (bc_data->boot_state_readable) {
+             /* Keep the bus domain on while the state is read */
+             ret = pm_runtime_resume_and_get(bc->bus_power_dev);
+             if (ret < 0) {
+                     dev_err_probe(dev, ret,
+                                   "failed to power up bus domain\n");
+                     goto cleanup_notifier;
+             }
+     }
+
      for (i = 0; i < bc_data->num_domains; i++) {
              const struct imx8m_blk_ctrl_domain_data *data = &bc_data->domains[i];
              struct imx8m_blk_ctrl_domain *domain = &bc->domains[i];
@@ -303,7 +392,8 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
              domain->genpd.power_off = imx8m_blk_ctrl_power_off;
              domain->bc = bc;
 
-             ret = pm_genpd_init(&domain->genpd, NULL, true);
+             init_off = imx8m_blk_ctrl_is_off(bc, bc_data, data);
+             ret = pm_genpd_init(&domain->genpd, NULL, init_off);
              if (ret) {
                      dev_err_probe(dev, ret,
                                    "failed to init power domain \"%s\"\n",
@@ -312,6 +402,9 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
                      goto cleanup_pds;
              }
 
+             if (!init_off)
+                     boot_on |= BIT(i);
+
              /*
               * We use runtime PM to trigger power on/off of the upstream GPC
               * domain, as a strict hierarchical parent/child power domain
@@ -328,37 +421,48 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
              bc->onecell_data.domains[i] = &domain->genpd;
      }
 
+     /*
+      * The probe can no longer be deferred. Releasing these references
+      * would power down the domains left on by the bootloader.
+      */
+     for_each_set_bit(bit, &boot_on, bc_data->num_domains) {
+             ret = imx8m_blk_ctrl_get_boot_on(&bc->domains[bit]);
+             if (ret)
+                     goto cleanup_pds;
+     }
+
      ret = of_genpd_add_provider_onecell(dev->of_node, &bc->onecell_data);
      if (ret) {
              dev_err_probe(dev, ret, "failed to add power domain provider\n");
              goto cleanup_pds;
      }
 
-     bc->power_nb.notifier_call = bc_data->power_notifier_fn;
-     ret = dev_pm_genpd_add_notifier(bc->bus_power_dev, &bc->power_nb);
-     if (ret) {
-             dev_err_probe(dev, ret, "failed to add power notifier\n");
-             goto cleanup_provider;
-     }
-
      dev_set_drvdata(dev, bc);
 
      ret = devm_of_platform_populate(dev);
      if (ret)
-             goto cleanup_notifier;
+             goto cleanup_provider;
+
+     if (bc_data->boot_state_readable)
+             pm_runtime_put(bc->bus_power_dev);
 
      return 0;
 
-cleanup_notifier:
-     dev_pm_genpd_remove_notifier(bc->bus_power_dev);
 cleanup_provider:
      of_genpd_del_provider(dev->of_node);
 cleanup_pds:
      for (i--; i >= 0; i--) {
              pm_genpd_remove(&bc->domains[i].genpd);
+             imx8m_blk_ctrl_put_boot_on(&bc->domains[i]);
              dev_pm_domain_detach(bc->domains[i].power_dev, true);
      }
 
+     if (bc_data->boot_state_readable)
+             pm_runtime_put_sync(bc->bus_power_dev);
+
+cleanup_notifier:
+     dev_pm_genpd_remove_notifier(bc->bus_power_dev);
+cleanup_bus:
      dev_pm_domain_detach(bc->bus_power_dev, true);
 
      return ret;
@@ -375,6 +479,7 @@ static void imx8m_blk_ctrl_remove(struct platform_device *pdev)
              struct imx8m_blk_ctrl_domain *domain = &bc->domains[i];
 
              pm_genpd_remove(&domain->genpd);
+             imx8m_blk_ctrl_put_boot_on(domain);
              dev_pm_domain_detach(domain->power_dev, true);
      }
 
@@ -709,6 +814,7 @@ static const struct imx8m_blk_ctrl_domain_data imx8mn_disp_blk_ctl_domain_data[]
 
 static const struct imx8m_blk_ctrl_data imx8mn_disp_blk_ctl_dev_data = {
      .max_reg = 0x84,
+     .boot_state_readable = true,
      .power_notifier_fn = imx8mn_disp_power_notifier,
      .domains = imx8mn_disp_blk_ctl_domain_data,
      .num_domains = ARRAY_SIZE(imx8mn_disp_blk_ctl_domain_data),
--
Quoted 1 line

2.43.0

Sent using hkml (https://github.com/sjp38/hackermail)

Signature · 9 lines
Dario Binacchi
Senior Embedded Software Engineer
M. +39 328 0625246
[email protected]
―――――――――――――――
Amarula Solutions SRL
 Via Felice Cavallotti 25D, 41012 Carpi, MO, IT
[email protected]
www.amarulasolutions.com
#9 lore raw

PATCH v4 4/4 pmdomain: imx8m-blk-ctrl: Hold boot-on domain clocks until sync_state

In reply to Dario Binacchi

The clocks of a domain left on by the bootloader have no user until its consumers probe, so they are gated when the unused clocks are disabled. On the i.MX8MN, with the LCDIF driver built as a module, this stops the pixel clock of the U-Boot splash screen long before the DRM driver probes.

Keep the clocks of these domains enabled until sync_state, i.e. until all the consumers of the blk-ctrl have probed.

---

(no changes since v2)

Changes in v2:
- Rebase on the changes of the previous patch

 drivers/pmdomain/imx/imx8m-blk-ctrl.c | 32 +++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
drivers/pmdomain/imx/imx8m-blk-ctrl.c +32 -0
index 04383d7e40cb..680a76b49ac4 100644
@@ -84,6 +84,7 @@ struct imx8m_blk_ctrl_domain {
 	struct imx8m_blk_ctrl *bc;
 	int num_paths;
 	bool boot_on;	/* Left on by the bootloader */
+	bool boot_clks_held;	/* Until sync_state */
 };
 
 struct imx8m_blk_ctrl_data {
@@ -246,13 +247,31 @@ static int imx8m_blk_ctrl_get_boot_on(struct imx8m_blk_ctrl_domain *domain)
 	if (icc_bulk_set_bw(domain->num_paths, domain->paths))
 		dev_err(bc->dev, "failed to set icc bw\n");
 
+	/* Nobody else holds the clocks until the consumers probe */
+	if (clk_bulk_prepare_enable(domain->data->num_clks, domain->clks))
+		dev_warn(bc->dev, "failed to enable clocks of \"%s\"\n",
+			 domain->data->name);
+	else
+		domain->boot_clks_held = true;
+
 	domain->boot_on = true;
 
 	return 0;
 }
 
+static void imx8m_blk_ctrl_put_boot_clks(struct imx8m_blk_ctrl_domain *domain)
+{
+	if (!domain->boot_clks_held)
+		return;
+
+	clk_bulk_disable_unprepare(domain->data->num_clks, domain->clks);
+	domain->boot_clks_held = false;
+}
+
 static void imx8m_blk_ctrl_put_boot_on(struct imx8m_blk_ctrl_domain *domain)
 {
+	imx8m_blk_ctrl_put_boot_clks(domain);
+
 	if (!domain->boot_on)
 		return;
 
@@ -1059,11 +1078,24 @@ static const struct of_device_id imx8m_blk_ctrl_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, imx8m_blk_ctrl_of_match);
 
+static void imx8m_blk_ctrl_sync_state(struct device *dev)
+{
+	struct imx8m_blk_ctrl *bc = dev_get_drvdata(dev);
+	int i;
+
+	/* This replaces the genpd provider sync_state */
+	of_genpd_sync_state(dev->of_node);
+
+	for (i = 0; i < bc->onecell_data.num_domains; i++)
+		imx8m_blk_ctrl_put_boot_clks(&bc->domains[i]);
+}
+
 static struct platform_driver imx8m_blk_ctrl_driver = {
 	.probe = imx8m_blk_ctrl_probe,
 	.remove = imx8m_blk_ctrl_remove,
 	.driver = {
 		.name = "imx8m-blk-ctrl",
+		.sync_state = imx8m_blk_ctrl_sync_state,
 		.pm = &imx8m_blk_ctrl_pm_ops,
 		.of_match_table = imx8m_blk_ctrl_of_match,
 		.suppress_bind_attrs = true,
Signature · 1 line
2.43.0
Reviewed-by Peng Fan on v4 4/4
#10 lore raw

Re: [PATCH v4 4/4] pmdomain: imx8m-blk-ctrl: Hold boot-on domain clocks until sync_state

Quoted 11 lines · On Sun, 22 Nov 2026 21:51:13 +0100 Dario Binacchi…

The clocks of a domain left on by the bootloader have no user until its consumers probe, so they are gated when the unused clocks are disabled. On the i.MX8MN, with the LCDIF driver built as a module, this stops the pixel clock of the U-Boot splash screen long before the DRM driver probes.

Keep the clocks of these domains enabled until sync_state, i.e. until all the consumers of the blk-ctrl have probed.