mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] pmdomain: imx: fix suspend/resume order of the blk-ctrl virtual devices
@ 2026-11-26 16:40 Vitor Soares
  2026-11-26 16:40 ` [PATCH v2 1/2] pmdomain: imx8m-blk-ctrl: fix suspend/resume order Vitor Soares
  2026-11-26 16:40 ` [PATCH v2 2/2] pmdomain: imx8mp-blk-ctrl: " Vitor Soares
  0 siblings, 2 replies; 3+ messages in thread
From: Vitor Soares @ 2026-11-26 16:40 UTC (permalink / raw)
  To: Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam
  Cc: Vitor Soares, linux-pm, imx, linux-arm-kernel, linux-kernel,
	Lucas Stach, Advait Dhamorikar, Marek Vasut, Peng Fan, Adam Ford

From: Vitor Soares <vitor.soares@toradex.com>

The i.MX8M blk-ctrl drivers drive the GPC domains through the virtual
devices from dev_pm_domain_attach_by_name(). These devices have no
parent and no device link, so their position in dpm_list relative to the
blk-ctrl consumers depends on probe order. When a consumer ends up
before them, the system hangs in the noirq phase.

Patch 1 fixes imx8m-blk-ctrl. It is v1 [2], now also linking the bus
domain virtual device:

- i.MX8MM, VPU: the codecs resume before the virtual devices and the CPU
  hangs in genpd_resume_noirq() of 38310000.video-codec. On Verdin
  iMX8MM this happens on the first suspend to mem.

- i.MX8MP, media: reported by Advait [1], the CPU hangs in
  genpd_resume_noirq() of 32e40000.csi. His debug prints in
  imx8m_blk_ctrl_power_on() show the stall at the first BLK_SFT_RSTN
  read, after pm_runtime_get_sync() on the bus device returned 1.

- i.MX8MP, VPU: a normal boot works only because the Hantro codecs defer
  their probe until the blk-ctrl is bound (the blk-ctrl waits for the
  imx8mp interconnect module), and the deferred retry moves them to the
  end of dpm_list. Loading hantro-vpu after the blk-ctrl has probed
  reproduces the hang on resume.

Patch 2 does the same for imx8mp-blk-ctrl (HSIO and HDMI) and is new in
v2:

- i.MX8MP, HSIO: loading phy-fsl-imx8m-pcie after the blk-ctrl has
  probed puts the PCIe PHY before the virtual devices. On suspend the
  HSIO bus domain is powered off first, and genpd_suspend_noirq() of
  32f00000.pcie-phy never returns. With the module loaded at boot, the
  PHY defers, ends up after the virtual devices, and suspend works.

On Ulf's question in v1 [3]: the GPC domains cannot be genpd parents of
the blk-ctrl domains, because their power-up is interleaved with the
blk-ctrl reset and clocks (see 25e252bcf159), so the blk-ctrl drives
them with runtime PM on the virtual devices. The consumer drivers only
see the blk-ctrl domains. Runtime PM is disabled in the noirq phase, so
->suspend() keeps the virtual devices runtime active, and the runtime PM
calls of the blk-ctrl do not fail in the noirq phase, while the genpd
core powers the GPC domains off and on through the virtual devices. That
requires the virtual devices to be suspended after and resumed before
the consumers, which is what this series adds.

Lucas pointed to v1 as the correct fix in the original report [4].

Tested on top of ulfh/linux-pm fixes:
- Verdin iMX8MM: 20/20 suspend-to-mem cycles. Without the series, the
  first suspend hangs and the watchdog resets the board.
- Verdin iMX8MP, hantro-vpu and phy-fsl-imx8m-pcie loaded after boot:
  20/20 cycles. Without the series, the board hangs.

[1] https://lore.kernel.org/all/CAAPs2HTo=4+AEw1+vcU6c9vt_O2BfF+gv3FFvx9G3KLLzCOsHw@mail.gmail.com/
[2] https://lore.kernel.org/all/20240418155151.355133-1-ivitro@gmail.com/
[3] https://lore.kernel.org/all/CAPDyKFr9Vzgm2C6Z57Bg5mUQxg5LK6goN2og3+RC3BkTZjiqJw@mail.gmail.com/
[4] https://lore.kernel.org/all/8636fb8d9809aaafbd8274ec0dbfc250e1113c73.camel@pengutronix.de/

Vitor Soares (2):
  pmdomain: imx8m-blk-ctrl: fix suspend/resume order
  pmdomain: imx8mp-blk-ctrl: fix suspend/resume order

 drivers/pmdomain/imx/imx8m-blk-ctrl.c  | 29 ++++++++++++++++++++++++--
 drivers/pmdomain/imx/imx8mp-blk-ctrl.c | 29 ++++++++++++++++++++++++--
 2 files changed, 54 insertions(+), 4 deletions(-)


base-commit: 458777762756acfc7d2c20067cca6cc817cc8dec
-- 
2.53.0


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

* [PATCH v2 1/2] pmdomain: imx8m-blk-ctrl: fix suspend/resume order
  2026-11-26 16:40 [PATCH v2 0/2] pmdomain: imx: fix suspend/resume order of the blk-ctrl virtual devices Vitor Soares
@ 2026-11-26 16:40 ` Vitor Soares
  2026-11-26 16:40 ` [PATCH v2 2/2] pmdomain: imx8mp-blk-ctrl: " Vitor Soares
  1 sibling, 0 replies; 3+ messages in thread
From: Vitor Soares @ 2026-11-26 16:40 UTC (permalink / raw)
  To: Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Marek Vasut
  Cc: Vitor Soares, linux-pm, imx, linux-arm-kernel, linux-kernel,
	Lucas Stach, Advait Dhamorikar, Peng Fan, Adam Ford, stable,
	Francesco Dolcini

From: Vitor Soares <vitor.soares@toradex.com>

The GPC domains behind a blk-ctrl are driven with runtime PM on the
virtual devices from dev_pm_domain_attach_by_name(). Runtime PM is
disabled in the noirq phase, this is why the ->suspend callback exists:
it keeps the virtual devices runtime active, so the runtime PM calls in
imx8m_blk_ctrl_power_on() and imx8m_blk_ctrl_power_off() do not fail in
the noirq phase, while the genpd core powers the GPC domains off and on
through the virtual devices. This requires the virtual devices to resume
before the consumers of the blk-ctrl domains: genpd_resume_noirq() of a
consumer calls imx8m_blk_ctrl_power_on(), which accesses the blk-ctrl
registers expecting the bus domain to be on.

Nothing orders the virtual devices in dpm_list: they have no parent and
no device link to the blk-ctrl or its consumers. On i.MX8MM the VPU
codecs resume before the virtual devices and the CPU hangs in
genpd_resume_noirq() of 38310000.video-codec. The system never resumes
from suspend to mem; with a watchdog running, the board is eventually
reset. The same happens on i.MX8MP with the media blk-ctrl, where the
CPU hangs in genpd_resume_noirq() of the MIPI CSI-2 receiver, and with
the VPU blk-ctrl when the hantro-vpu module is loaded after the blk-ctrl
has probed.

Add a stateless device link from the blk-ctrl to each virtual device,
bus domain included, so they are suspended after and resumed before the
blk-ctrl and its consumers.

Fixes: 2684ac05a8c4 ("soc: imx: add i.MX8M blk-ctrl driver")
Cc: stable@vger.kernel.org
Reported-by: Advait Dhamorikar <advaitd@mechasystems.com>
Closes: https://lore.kernel.org/all/CAAPs2HTo=4+AEw1+vcU6c9vt_O2BfF+gv3FFvx9G3KLLzCOsHw@mail.gmail.com/
Closes: https://lore.kernel.org/all/fccbb040330a706a4f7b34875db1d896a0bf81c8.camel@gmail.com/
Suggested-by: Lucas Stach <l.stach@pengutronix.de>
Co-developed-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Signed-off-by: Vitor Soares <vitor.soares@toradex.com>
---
Changes in v2:
- Link the bus domain virtual device too (Francesco)
- Add the per-domain links right after attaching, before pm_genpd_init(),
  so the error paths stay symmetric (Francesco)
- Rewrite the commit message: v1 described the ordering as a
  parent/child effect, but the virtual devices have no parent; their
  dpm_list position relative to the consumers depends on probe order
- Explain why the ->suspend callback is needed, as asked by Ulf on v1
- Add the i.MX8MP media blk-ctrl report from Advait
- Drop Lucas' Reviewed-by, the diff changed
- Update the ->suspend comment, the order now comes from the device
  links
- Rebase on ulfh/linux-pm fixes

v1: https://lore.kernel.org/all/20240418155151.355133-1-ivitro@gmail.com/
---
 drivers/pmdomain/imx/imx8m-blk-ctrl.c | 29 +++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/pmdomain/imx/imx8m-blk-ctrl.c b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
index 9df933a7a238..ba44cad02351 100644
--- a/drivers/pmdomain/imx/imx8m-blk-ctrl.c
+++ b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
@@ -250,6 +250,17 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 					     "failed to attach power domain \"bus\"\n");
 	}
 
+	/*
+	 * Make the genpd virtual devices suppliers of the blk-ctrl so that
+	 * they are suspended after and resumed before the blk-ctrl and all
+	 * its consumers.
+	 */
+	if (!device_link_add(dev, bc->bus_power_dev, DL_FLAG_STATELESS)) {
+		ret = dev_err_probe(dev, -EINVAL, "failed to link to \"bus\"\n");
+		dev_pm_domain_detach(bc->bus_power_dev, true);
+		return ret;
+	}
+
 	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];
@@ -298,6 +309,15 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 			goto cleanup_pds;
 		}
 
+		if (!device_link_add(dev, domain->power_dev, DL_FLAG_STATELESS)) {
+			ret = -EINVAL;
+			dev_err_probe(dev, ret,
+				      "failed to link to \"%s\"\n",
+				      data->gpc_name);
+			dev_pm_domain_detach(domain->power_dev, true);
+			goto cleanup_pds;
+		}
+
 		domain->genpd.name = data->name;
 		domain->genpd.power_on = imx8m_blk_ctrl_power_on;
 		domain->genpd.power_off = imx8m_blk_ctrl_power_off;
@@ -308,6 +328,7 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 			dev_err_probe(dev, ret,
 				      "failed to init power domain \"%s\"\n",
 				      data->gpc_name);
+			device_link_remove(dev, domain->power_dev);
 			dev_pm_domain_detach(domain->power_dev, true);
 			goto cleanup_pds;
 		}
@@ -354,9 +375,11 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
 cleanup_pds:
 	for (i--; i >= 0; i--) {
 		pm_genpd_remove(&bc->domains[i].genpd);
+		device_link_remove(dev, bc->domains[i].power_dev);
 		dev_pm_domain_detach(bc->domains[i].power_dev, true);
 	}
 
+	device_link_remove(dev, bc->bus_power_dev);
 	dev_pm_domain_detach(bc->bus_power_dev, true);
 
 	return ret;
@@ -373,11 +396,13 @@ static void imx8m_blk_ctrl_remove(struct platform_device *pdev)
 		struct imx8m_blk_ctrl_domain *domain = &bc->domains[i];
 
 		pm_genpd_remove(&domain->genpd);
+		device_link_remove(&pdev->dev, domain->power_dev);
 		dev_pm_domain_detach(domain->power_dev, true);
 	}
 
 	dev_pm_genpd_remove_notifier(bc->bus_power_dev);
 
+	device_link_remove(&pdev->dev, bc->bus_power_dev);
 	dev_pm_domain_detach(bc->bus_power_dev, true);
 }
 
@@ -392,8 +417,8 @@ static int imx8m_blk_ctrl_suspend(struct device *dev)
 	 * can power down our domains and more importantly power them up again
 	 * after resume, without tripping over our usage of runtime PM to
 	 * control the upstream GPC domains. Things happen in the right order
-	 * in the system suspend/resume paths due to the device parent/child
-	 * hierarchy.
+	 * in the system suspend/resume paths due to the device links to the
+	 * genpd virtual devices added in probe.
 	 */
 	ret = pm_runtime_resume_and_get(bc->bus_power_dev);
 	if (ret < 0)
-- 
2.53.0


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

* [PATCH v2 2/2] pmdomain: imx8mp-blk-ctrl: fix suspend/resume order
  2026-11-26 16:40 [PATCH v2 0/2] pmdomain: imx: fix suspend/resume order of the blk-ctrl virtual devices Vitor Soares
  2026-11-26 16:40 ` [PATCH v2 1/2] pmdomain: imx8m-blk-ctrl: fix suspend/resume order Vitor Soares
@ 2026-11-26 16:40 ` Vitor Soares
  1 sibling, 0 replies; 3+ messages in thread
From: Vitor Soares @ 2026-11-26 16:40 UTC (permalink / raw)
  To: Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam
  Cc: Vitor Soares, linux-pm, imx, linux-arm-kernel, linux-kernel,
	Lucas Stach, Advait Dhamorikar, Marek Vasut, Peng Fan, Adam Ford,
	stable, Francesco Dolcini

From: Vitor Soares <vitor.soares@toradex.com>

As in imx8m-blk-ctrl, the GPC domains behind the HSIO and HDMI blk-ctrl
are driven through the virtual devices from
dev_pm_domain_attach_by_name(), which have no parent and no device link
to the blk-ctrl or its consumers, so nothing orders them in dpm_list.

On Verdin iMX8MP, with the phy-fsl-imx8m-pcie module loaded after the
HSIO blk-ctrl has probed, the virtual devices are suspended before the
PCIe PHY, and the CPU hangs in genpd_suspend_noirq() of
32f00000.pcie-phy with the HSIO bus domain already off. The system
never completes suspend to mem.

Add a stateless device link from the blk-ctrl to each virtual device,
bus domain included, so they are suspended after and resumed before the
blk-ctrl and its consumers.

Fixes: 556f5cf9568a ("soc: imx: add i.MX8MP HSIO blk-ctrl")
Cc: stable@vger.kernel.org
Co-developed-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Signed-off-by: Vitor Soares <vitor.soares@toradex.com>
---
 drivers/pmdomain/imx/imx8mp-blk-ctrl.c | 29 ++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/pmdomain/imx/imx8mp-blk-ctrl.c b/drivers/pmdomain/imx/imx8mp-blk-ctrl.c
index 212d491c75e4..e967ae7eda30 100644
--- a/drivers/pmdomain/imx/imx8mp-blk-ctrl.c
+++ b/drivers/pmdomain/imx/imx8mp-blk-ctrl.c
@@ -657,6 +657,17 @@ static int imx8mp_blk_ctrl_probe(struct platform_device *pdev)
 		return dev_err_probe(dev, PTR_ERR(bc->bus_power_dev),
 				     "failed to attach bus power domain\n");
 
+	/*
+	 * Make the genpd virtual devices suppliers of the blk-ctrl so that
+	 * they are suspended after and resumed before the blk-ctrl and all
+	 * its consumers.
+	 */
+	if (!device_link_add(dev, bc->bus_power_dev, DL_FLAG_STATELESS)) {
+		ret = dev_err_probe(dev, -EINVAL, "failed to link to bus\n");
+		dev_pm_domain_detach(bc->bus_power_dev, true);
+		return ret;
+	}
+
 	bc->power_off = bc_data->power_off;
 	bc->power_on = bc_data->power_on;
 
@@ -716,6 +727,15 @@ static int imx8mp_blk_ctrl_probe(struct platform_device *pdev)
 			goto cleanup_pds;
 		}
 
+		if (!device_link_add(dev, domain->power_dev, DL_FLAG_STATELESS)) {
+			ret = -EINVAL;
+			dev_err_probe(dev, ret, "failed to link to %s\n",
+				      data->gpc_name);
+			dev_pm_genpd_remove_notifier(domain->power_dev);
+			dev_pm_domain_detach(domain->power_dev, true);
+			goto cleanup_pds;
+		}
+
 		domain->genpd.name = data->name;
 		domain->genpd.power_on = imx8mp_blk_ctrl_power_on;
 		domain->genpd.power_off = imx8mp_blk_ctrl_power_off;
@@ -726,6 +746,7 @@ static int imx8mp_blk_ctrl_probe(struct platform_device *pdev)
 		ret = pm_genpd_init(&domain->genpd, NULL, true);
 		if (ret) {
 			dev_err_probe(dev, ret, "failed to init power domain\n");
+			device_link_remove(dev, domain->power_dev);
 			dev_pm_genpd_remove_notifier(domain->power_dev);
 			dev_pm_domain_detach(domain->power_dev, true);
 			goto cleanup_pds;
@@ -775,10 +796,12 @@ static int imx8mp_blk_ctrl_probe(struct platform_device *pdev)
 cleanup_pds:
 	for (i--; i >= 0; i--) {
 		pm_genpd_remove(&bc->domains[i].genpd);
+		device_link_remove(dev, bc->domains[i].power_dev);
 		dev_pm_genpd_remove_notifier(bc->domains[i].power_dev);
 		dev_pm_domain_detach(bc->domains[i].power_dev, true);
 	}
 
+	device_link_remove(dev, bc->bus_power_dev);
 	dev_pm_domain_detach(bc->bus_power_dev, true);
 
 	return ret;
@@ -795,12 +818,14 @@ static void imx8mp_blk_ctrl_remove(struct platform_device *pdev)
 		struct imx8mp_blk_ctrl_domain *domain = &bc->domains[i];
 
 		pm_genpd_remove(&domain->genpd);
+		device_link_remove(&pdev->dev, domain->power_dev);
 		dev_pm_genpd_remove_notifier(domain->power_dev);
 		dev_pm_domain_detach(domain->power_dev, true);
 	}
 
 	dev_pm_genpd_remove_notifier(bc->bus_power_dev);
 
+	device_link_remove(&pdev->dev, bc->bus_power_dev);
 	dev_pm_domain_detach(bc->bus_power_dev, true);
 }
 
@@ -815,8 +840,8 @@ static int imx8mp_blk_ctrl_suspend(struct device *dev)
 	 * can power down our domains and more importantly power them up again
 	 * after resume, without tripping over our usage of runtime PM to
 	 * control the upstream GPC domains. Things happen in the right order
-	 * in the system suspend/resume paths due to the device parent/child
-	 * hierarchy.
+	 * in the system suspend/resume paths due to the device links to the
+	 * genpd virtual devices added in probe.
 	 */
 	ret = pm_runtime_get_sync(bc->bus_power_dev);
 	if (ret < 0) {
-- 
2.53.0


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

end of thread, other threads:[~2026-11-26 16:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 16:40 [PATCH v2 0/2] pmdomain: imx: fix suspend/resume order of the blk-ctrl virtual devices Vitor Soares
2026-11-26 16:40 ` [PATCH v2 1/2] pmdomain: imx8m-blk-ctrl: fix suspend/resume order Vitor Soares
2026-11-26 16:40 ` [PATCH v2 2/2] pmdomain: imx8mp-blk-ctrl: " Vitor Soares

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®