From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: 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>,
Wentao Liang <vulab@iscas.ac.cn>,
Miaoqian Lin <linmq006@gmail.com>,
Shawn Guo <shawnguo@kernel.org>,
Lucas Stach <l.stach@pengutronix.de>,
Dong Aisheng <aisheng.dong@nxp.com>,
linux-pm@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] pmdomain: imx: gpc: remove all initialized power domains
Date: Fri, 18 Sep 2026 10:39:41 +0300 [thread overview]
Message-ID: <aqzqvfbeh653jUce@ashevche-desk.local> (raw)
In-Reply-To: <20260918031323.3376849-1-lgs201920130244@gmail.com>
On Fri, Sep 18, 2026 at 11:13:22AM +0800, Guangshuo Li wrote:
> imx_gpc_old_dt_init() initializes all power domains described by
> of_id_data->num_domains. Its probe failure path removes all of these
> domains, but imx_gpc_remove() only removes the PU and ARM domains.
>
> On SoCs with more than two domains, such as i.MX6SL and i.MX6SX, the
> additional DISPLAY and PCI generic power domains can remain registered
> after the GPC driver is removed.
>
> Remove all initialized power domains in reverse order. Keep releasing
> the PU clocks immediately after the PU domain has been successfully
> removed.
>
> This issue was found by manual code inspection.
...
> static void imx_gpc_remove(struct platform_device *pdev)
> {
> + const struct imx_gpc_dt_data *of_id_data =
> + device_get_match_data(&pdev->dev);
No...
> struct device_node *pgc_node;
> - int ret;
> + int i, ret;
...and no.
The result of the device_get_match_data() better to be checked, in some cases
it might lead to NULL dereference.
It's better to split semantically different variables, also naming 'i' is not
good, num_domains is better. Besides that, why is it signed?
...
> + for (i = of_id_data->num_domains - 1; i >= 0; i--) {
What you are doing here can be written in a shorter form
num_domains = of_id_data->num_domains;
while (num_domains--) {
> + ret = pm_genpd_remove(&imx_gpc_domains[i].base);
> + if (ret) {
> + dev_err(&pdev->dev,
> + "Failed to remove %s power domain (%pe)\n",
> + imx_gpc_domains[i].base.name,
> + ERR_PTR(ret));
> + return;
> + }
>
> + if (i == GPC_PGC_DOMAIN_PU)
> + imx_pgc_put_clocks(&imx_gpc_domains[i]);
> }
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-09-18 7:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 3:13 Guangshuo Li
2026-09-18 7:39 ` Andy Shevchenko [this message]
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=aqzqvfbeh653jUce@ashevche-desk.local \
--to=andriy.shevchenko@linux.intel.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=lgs201920130244@gmail.com \
--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
all inboxes | Powered by JetHome®