Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
* [PATCH v2] pmdomain: imx: gpc: remove all initialized power domains
@ 2026-09-24 14:25 Guangshuo Li
  2026-09-24 14:31 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Guangshuo Li @ 2026-09-24 14:25 UTC (permalink / raw)
  To: Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Bartosz Golaszewski, Greg Kroah-Hartman,
	Miaoqian Lin, Guangshuo Li, Wentao Liang, Shawn Guo, Dong Aisheng,
	Lucas Stach, linux-pm, imx, linux-arm-kernel, linux-kernel
  Cc: stable

imx_gpc_old_dt_init() initializes all power domains described by
of_id_data->num_domains, while imx_gpc_remove() only removes the PU and
ARM domains.

Use the match data to remove all initialized power domains in reverse
order. Release the PU clocks after the PU domain is removed.

This issue was found by manual code inspection.

Fixes: 5a42d1198901 ("soc: imx: gpc: fix imx6sl gpc power domain regression")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
v2:
  - Check the result of device_get_match_data() before using it.
  - Use an unsigned num_domains variable and a decrementing while loop,
    as suggested by Andy Shevchenko.

 drivers/pmdomain/imx/gpc.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/pmdomain/imx/gpc.c b/drivers/pmdomain/imx/gpc.c
index abca5f449a22..d83fb37e2297 100644
--- a/drivers/pmdomain/imx/gpc.c
+++ b/drivers/pmdomain/imx/gpc.c
@@ -502,7 +502,9 @@ static int imx_gpc_probe(struct platform_device *pdev)
 
 static void imx_gpc_remove(struct platform_device *pdev)
 {
+	const struct imx_gpc_dt_data *of_id_data;
 	struct device_node *pgc_node;
+	unsigned int num_domains;
 	int ret;
 
 	pgc_node = of_get_child_by_name(pdev->dev.of_node, "pgc");
@@ -519,20 +521,23 @@ static void imx_gpc_remove(struct platform_device *pdev)
 	if (!pgc_node) {
 		of_genpd_del_provider(pdev->dev.of_node);
 
-		ret = pm_genpd_remove(&imx_gpc_domains[GPC_PGC_DOMAIN_PU].base);
-		if (ret) {
-			dev_err(&pdev->dev, "Failed to remove PU power domain (%pe)\n",
-				ERR_PTR(ret));
+		of_id_data = device_get_match_data(&pdev->dev);
+		if (!of_id_data)
 			return;
-		}
-		imx_pgc_put_clocks(&imx_gpc_domains[GPC_PGC_DOMAIN_PU]);
 
-		ret = pm_genpd_remove(&imx_gpc_domains[GPC_PGC_DOMAIN_ARM].base);
-		if (ret) {
-			dev_err(&pdev->dev, "Failed to remove ARM power domain (%pe)\n",
-				ERR_PTR(ret));
-			return;
-		}
+		num_domains = of_id_data->num_domains;
+		while (num_domains--) {
+			ret = pm_genpd_remove(&imx_gpc_domains[num_domains].base);
+			if (ret) {
+				dev_err(&pdev->dev,
+					"Failed to remove %s power domain (%pe)\n",
+					imx_gpc_domains[num_domains].base.name,
+					ERR_PTR(ret));
+				return;
+			}
+
+		if (num_domains == GPC_PGC_DOMAIN_PU)
+			imx_pgc_put_clocks(&imx_gpc_domains[num_domains]);
 	}
 
 	of_node_put(pgc_node);
-- 
2.43.0


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

* Re: [PATCH v2] pmdomain: imx: gpc: remove all initialized power domains
  2026-09-24 14:25 [PATCH v2] pmdomain: imx: gpc: remove all initialized power domains Guangshuo Li
@ 2026-09-24 14:31 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-09-24 14:31 UTC (permalink / raw)
  To: Guangshuo Li; +Cc: imx, Frank.Li

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] imx_gpc_remove: syntax error due to missing closing brace
--

commit 8c74b27165f06b794b40a774855d31374a0b317d
Author: Guangshuo Li <lgs201920130244@gmail.com>

pmdomain: imx: gpc: remove all initialized power domains

This commit updates imx_gpc_remove() to use match data to iterate
and remove all initialized power domains in reverse order. It also
ensures the PU clocks are released when the PU domain is removed.

> diff --git a/drivers/pmdomain/imx/gpc.c b/drivers/pmdomain/imx/gpc.c
> index abca5f449a226..d83fb37e22974 100644
> --- a/drivers/pmdomain/imx/gpc.c
> +++ b/drivers/pmdomain/imx/gpc.c

[ ... ]

> @@ -519,20 +521,23 @@ static void imx_gpc_remove(struct platform_device *pdev)
>  	if (!pgc_node) {
>  		of_genpd_del_provider(pdev->dev.of_node);

[ ... ]

> +		num_domains = of_id_data->num_domains;
> +		while (num_domains--) {
> +			ret = pm_genpd_remove(&imx_gpc_domains[num_domains].base);
> +			if (ret) {
> +				dev_err(&pdev->dev,
> +					"Failed to remove %s power domain (%pe)\n",
> +					imx_gpc_domains[num_domains].base.name,
> +					ERR_PTR(ret));
> +				return;
> +			}
> +
> +		if (num_domains == GPC_PGC_DOMAIN_PU)
> +			imx_pgc_put_clocks(&imx_gpc_domains[num_domains]);
>  	}

[Severity: Low]
Is this while loop missing a closing brace?

Because there is no closing brace added for the new while loop, it appears
the closing brace at the end of this block will close the while loop instead
of the outer if (!pgc_node) statement. Will this cause unbalanced braces
and a build failure?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260924142520.1594149-1-lgs201920130244@gmail.com?part=1

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

end of thread, other threads:[~2026-09-24 14:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-24 14:25 [PATCH v2] pmdomain: imx: gpc: remove all initialized power domains Guangshuo Li
2026-09-24 14:31 ` sashiko-bot

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