From: sashiko-bot@kernel.org
To: "Dario Binacchi" <dario.binacchi@amarulasolutions.com>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH 2/3] pmdomain: imx8m-blk-ctrl: Keep the domains left on by the bootloader
Date: Sat, 21 Nov 2026 13:29:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-227073@kernel.org> (raw)
In-Reply-To: <20261121130614.2482656-3-dario.binacchi@amarulasolutions.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] pmdomain: imx8m-blk-ctrl: unbalanced boot_on state in remove
and probe unwind
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [Critical] pmdomain: imx: imx8m-blk-ctrl: use-after-free in
imx8m_blk_ctrl_probe() [1]
--
commit 68404e36f0b266cabfa06ab2dfb79d11fc9d8d3f
Author: Dario Binacchi <dario.binacchi@amarulasolutions.com>
pmdomain: imx8m-blk-ctrl: Keep the domains left on by the bootloader
This commit reads the blk-ctrl registers during probe on i.MX8MN DISP
blk-ctrl to detect domains left on by the bootloader, initializes those
domains as powered on, and takes the corresponding runtime PM and
interconnect references.
> diff --git a/drivers/pmdomain/imx/imx8m-blk-ctrl.c b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
> index 9df933a7a2380..35087da43dd72 100644
> --- a/drivers/pmdomain/imx/imx8m-blk-ctrl.c
> +++ b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
[ ... ]
> @@ -192,6 +195,71 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
[ ... ]
> +/* Take the references of imx8m_blk_ctrl_power_on() for a domain left on */
> +static int imx8m_blk_ctrl_get_boot_on(struct imx8m_blk_ctrl_domain *domain)
> +{
> + struct imx8m_blk_ctrl *bc = domain->bc;
> + int ret;
> +
> + ret = pm_runtime_resume_and_get(bc->bus_power_dev);
> + if (ret < 0) {
> + dev_err(bc->dev, "failed to power up bus domain\n");
> + return ret;
> + }
> +
> + ret = pm_runtime_resume_and_get(domain->power_dev);
> + if (ret < 0) {
> + dev_err(bc->dev, "failed to power up peripheral domain\n");
> + pm_runtime_put(bc->bus_power_dev);
> + return ret;
> + }
> +
> + if (icc_bulk_set_bw(domain->num_paths, domain->paths))
> + dev_err(bc->dev, "failed to set icc bw\n");
> +
> + domain->boot_on = true;
> +
> + return 0;
> +}
> +
> +static void imx8m_blk_ctrl_put_boot_on(struct imx8m_blk_ctrl_domain *domain)
> +{
> + if (!domain->boot_on)
> + return;
> +
> + pm_runtime_put(domain->power_dev);
> + pm_runtime_put(domain->bc->bus_power_dev);
> + domain->boot_on = false;
> +}
[Severity: Medium]
Can this power down the MIPI PHY domain on probe deferral or leave
domain->boot_on stale across power-off and driver removal?
On i.MX8MN DISP blk-ctrl, domain 0 (IMX8MN_DISPBLK_PD_MIPI_DSI) attaches
domain->power_dev to pgc_mipi, which has no hskack bit in gpcv2.c and is
therefore initialized as GENPD_STATE_OFF with stay_on = false. Calling
pm_runtime_resume_and_get(domain->power_dev) in
imx8m_blk_ctrl_get_boot_on() transitions pgc_mipi to GENPD_STATE_ON. If a
later domain in the probe loop returns -EPROBE_DEFER, cleanup_pds calls
imx8m_blk_ctrl_put_boot_on() and dev_pm_domain_detach(), which queues
power_off_work on pgc_mipi and shuts down the MIPI PHY domain in hardware
while the bootloader splash screen is running.
In addition, imx8m_blk_ctrl_power_off() drops the runtime PM references
taken by imx8m_blk_ctrl_get_boot_on() without clearing domain->boot_on,
and imx8m_blk_ctrl_remove() never releases active boot_on references
before dev_pm_genpd_remove_notifier(bc->bus_power_dev). If
imx8m_blk_ctrl_remove() runs while a boot-on domain is still on without
attached consumers, pm_genpd_remove() does not invoke
imx8m_blk_ctrl_power_off(), so bc->bus_power_dev stays active until
dev_pm_domain_detach(bc->bus_power_dev, true) powers down pgc_dispmix
after imx8mn_disp_power_notifier() has already been unregistered.
[ ... ]
> @@ -353,6 +432,7 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
> of_genpd_del_provider(dev->of_node);
> cleanup_pds:
> for (i--; i >= 0; i--) {
> + imx8m_blk_ctrl_put_boot_on(&bc->domains[i]);
> pm_genpd_remove(&bc->domains[i].genpd);
> dev_pm_domain_detach(bc->domains[i].power_dev, true);
> }
[Severity: Critical]
This problem wasn't introduced by this patch, but if
devm_of_platform_populate() fails in imx8m_blk_ctrl_probe() [1],
does jumping to cleanup_provider leave bc->power_nb registered on
bc->bus_power_dev after devres frees bc?
When dev_pm_genpd_add_notifier() succeeds and devm_of_platform_populate()
then fails, cleanup_provider does not call
dev_pm_genpd_remove_notifier(bc->bus_power_dev), leaving a dangling
notifier block in the bus power domain's notifier list that causes a
use-after-free on the next bus domain power transition.
[1] https://sashiko.dev/#/bug/linux-61d2c7f1-47af-4d61-8d2d-423ac38bf002
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261121130614.2482656-1-dario.binacchi@amarulasolutions.com?part=2
next prev parent reply other threads:[~2026-11-21 13:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 13:06 [PATCH 0/3] pmdomain: imx: Keep the domains left on by the bootloader Dario Binacchi
2026-11-21 13:06 ` [PATCH 1/3] pmdomain: imx: gpcv2: " Dario Binacchi
2026-11-21 13:06 ` [PATCH 2/3] pmdomain: imx8m-blk-ctrl: " Dario Binacchi
2026-11-21 13:29 ` sashiko-bot [this message]
2026-11-21 13:06 ` [PATCH 3/3] pmdomain: imx8m-blk-ctrl: Hold boot-on domain clocks until sync_state Dario Binacchi
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=sashiko-outbox-227073@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dario.binacchi@amarulasolutions.com \
--cc=imx@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.