From: Guangshuo Li <lgs201920130244@gmail.com>
To: Ulf Hansson <ulfh@kernel.org>, Frank Li <Frank.Li@nxp.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Miaoqian Lin <linmq006@gmail.com>,
Guangshuo Li <lgs201920130244@gmail.com>,
Wentao Liang <vulab@iscas.ac.cn>, Shawn Guo <shawnguo@kernel.org>,
Dong Aisheng <aisheng.dong@nxp.com>,
Lucas Stach <l.stach@pengutronix.de>,
linux-pm@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH v2] pmdomain: imx: gpc: remove all initialized power domains
Date: Thu, 24 Sep 2026 22:25:20 +0800 [thread overview]
Message-ID: <20260924142520.1594149-1-lgs201920130244@gmail.com> (raw)
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
reply other threads:[~2026-09-24 14:25 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=20260924142520.1594149-1-lgs201920130244@gmail.com \
--to=lgs201920130244@gmail.com \
--cc=Frank.Li@nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=l.stach@pengutronix.de \
--cc=linmq006@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=stable@vger.kernel.org \
--cc=ulfh@kernel.org \
--cc=vulab@iscas.ac.cn \
/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