Linux Power Management development
 help / color / mirror / Atom feed
From: Jiawen Liu <liu1298662399@gmail.com>
To: Ulf Hansson <ulfh@kernel.org>, Frank Li <Frank.Li@nxp.com>,
	Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	linux-pm@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH] pmdomain: imx: gpc: Abort power-on on reset clock failure
Date: Sun, 29 Nov 2026 19:25:33 +0000	[thread overview]
Message-ID: <179598034233.2.15063208684049946861.pattern-ext-127.22@gmail.com> (raw)

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

                 reply	other threads:[~2026-11-29 19:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179598034233.2.15063208684049946861.pattern-ext-127.22@gmail.com \
    --to=liu1298662399@gmail.com \
    --cc=Frank.Li@nxp.com \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=ulfh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox