Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH] pmdomain: imx: gpc: Abort power-on on reset clock failure
@ 2026-11-29 19:25 Jiawen Liu
  0 siblings, 0 replies; only message in thread
From: Jiawen Liu @ 2026-11-29 19:25 UTC (permalink / raw)
  To: Ulf Hansson, Frank Li, Sascha Hauer
  Cc: Pengutronix Kernel Team, Fabio Estevam, linux-pm, imx,
	linux-arm-kernel

The i.MX6 GPC needs the domain's reset clocks running during power-up
so reset can propagate to its peripherals. On i.MX6SX, the PU domain's
GPU clock can fail to prepare when it uses a PLL3-derived parent and
PLL3 times out waiting for lock on first prepare. The driver still
requests power-up, disables and unprepares the failed clock, and reports
success. The unmatched cleanup can trigger clock framework warnings.

Abort before issuing the GPC request if clk_prepare_enable() fails.
Unwind the previously enabled clocks in reverse order, call
regulator_disable() if the domain supply was enabled, and return the
original error. Have both DT initialization paths release their clock
handles and return the error before initializing or registering the
domain.

The tool traced the error paths,
ran git diff --check and checkpatch, and built the ARM i.MX6 GPC object
with generic PM domains enabled and with PM disabled. Runtime and
hardware reproduction were not performed.

Fixes: 00eb60a8b4f7 ("ARM: imx6: gpc: Add PU power domain for GPU/VPU")
Signed-off-by: Jiawen Liu <liu1298662399@gmail.com>
---
 drivers/pmdomain/imx/gpc.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/pmdomain/imx/gpc.c b/drivers/pmdomain/imx/gpc.c
index abca5f449a226..d881e4d61a40f 100644
--- a/drivers/pmdomain/imx/gpc.c
+++ b/drivers/pmdomain/imx/gpc.c
@@ -101,8 +101,11 @@ static int imx6_pm_domain_power_on(struct generic_pm_domain *genpd)
 	}
 
 	/* Enable reset clocks for all devices in the domain */
-	for (i = 0; i < pd->num_clks; i++)
-		clk_prepare_enable(pd->clk[i]);
+	for (i = 0; i < pd->num_clks; i++) {
+		ret = clk_prepare_enable(pd->clk[i]);
+		if (ret)
+			goto disable_clks;
+	}
 
 	/* Gate off domain when powered down */
 	regmap_update_bits(pd->regmap, pd->reg_offs + GPC_PGC_CTRL_OFFS,
@@ -126,6 +129,14 @@ static int imx6_pm_domain_power_on(struct generic_pm_domain *genpd)
 		clk_disable_unprepare(pd->clk[i]);
 
 	return 0;
+
+disable_clks:
+	while (i--)
+		clk_disable_unprepare(pd->clk[i]);
+	if (pd->supply)
+		regulator_disable(pd->supply);
+
+	return ret;
 }
 
 static int imx_pgc_get_clocks(struct device *dev, struct imx_pm_domain *domain)
@@ -191,8 +202,11 @@ static int imx_pgc_power_domain_probe(struct platform_device *pdev)
 	}
 
 	/* initially power on the domain */
-	if (domain->base.power_on)
-		domain->base.power_on(&domain->base);
+	if (domain->base.power_on) {
+		ret = domain->base.power_on(&domain->base);
+		if (ret)
+			goto put_clocks;
+	}
 
 	if (IS_ENABLED(CONFIG_PM_GENERIC_DOMAINS)) {
 		pm_genpd_init(&domain->base, NULL, false);
@@ -207,6 +221,7 @@ static int imx_pgc_power_domain_probe(struct platform_device *pdev)
 
 genpd_err:
 	pm_genpd_remove(&domain->base);
+put_clocks:
 	imx_pgc_put_clocks(domain);
 
 	return ret;
@@ -375,7 +390,9 @@ static int imx_gpc_old_dt_init(struct device *dev, struct regmap *regmap,
 			if (ret)
 				goto clk_err;
 
-			domain->base.power_on(&domain->base);
+			ret = domain->base.power_on(&domain->base);
+			if (ret)
+				goto put_clocks;
 		}
 	}
 
@@ -394,6 +411,7 @@ static int imx_gpc_old_dt_init(struct device *dev, struct regmap *regmap,
 genpd_err:
 	for (i = 0; i < num_domains; i++)
 		pm_genpd_remove(&imx_gpc_domains[i].base);
+put_clocks:
 	imx_pgc_put_clocks(&imx_gpc_domains[GPC_PGC_DOMAIN_PU]);
 clk_err:
 	return ret;
-- 
2.34.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-29 19:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 19:25 [PATCH] pmdomain: imx: gpc: Abort power-on on reset clock failure Jiawen Liu

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