From: sashiko-bot@kernel.org
To: "Dario Binacchi" <dario.binacchi@amarulasolutions.com>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH v2 3/4] pmdomain: imx8m-blk-ctrl: Keep the domains left on by the bootloader
Date: Sun, 22 Nov 2026 10:20:33 +0000 [thread overview]
Message-ID: <sashiko-outbox-227889@kernel.org> (raw)
In-Reply-To: <20261122095927.2631909-4-dario.binacchi@amarulasolutions.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] pmdomain: imx8m-blk-ctrl: unlocked bus domain check in
imx8m_blk_ctrl_is_off()
- [Medium] pmdomain: imx8m-blk-ctrl: put_boot_on() races with genpd
power_off_work
--
commit c08d94b261d674a0f3a8ba6bcb7abe4442f21fa6
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 at probe time on supported SoCs
(i.MX8MN DISP) to keep power domains left on by the bootloader active
until their consumers release them.
> diff --git a/drivers/pmdomain/imx/imx8m-blk-ctrl.c b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
> index 7d6735728d8c6..5ab201eefeb38 100644
> --- a/drivers/pmdomain/imx/imx8m-blk-ctrl.c
> +++ b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
[ ... ]
> @@ -187,11 +190,80 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
> /* allow bus domain to suspend */
> pm_runtime_put(bc->bus_power_dev);
>
> + domain->boot_on = false;
> +
> return 0;
> }
>
> static struct lock_class_key blk_ctrl_genpd_lock_class;
>
> +/*
> + * A domain left on by the bootloader has its resets deasserted and its
> + * clocks enabled. The registers can only be read if the bus domain is
> + * on, so a domain is considered off whenever the bus domain is off.
> + */
> +static bool imx8m_blk_ctrl_is_off(struct imx8m_blk_ctrl *bc,
> + const struct imx8m_blk_ctrl_data *bc_data,
> + const struct imx8m_blk_ctrl_domain_data *data)
> +{
> + u32 rst, clk, mipi = 0;
> +
> + if (!bc_data->boot_state_readable ||
> + !dev_pm_genpd_is_on(bc->bus_power_dev))
> + return true;
> +
> + if (regmap_read(bc->regmap, BLK_SFT_RSTN, &rst) ||
> + regmap_read(bc->regmap, BLK_CLK_EN, &clk))
> + return true;
> +
> + if (data->mipi_phy_rst_mask &&
> + regmap_read(bc->regmap, BLK_MIPI_RESET_DIV, &mipi))
> + return true;
> +
> + return (rst & data->rst_mask) != data->rst_mask ||
> + (clk & data->clk_mask) != data->clk_mask ||
> + (mipi & data->mipi_phy_rst_mask) != data->mipi_phy_rst_mask;
> +}
[Severity: High]
Can the upstream bus domain (pgc_dispmix) power down asynchronously on
pm_wq between dev_pm_genpd_is_on(bc->bus_power_dev) and the regmap_read()
calls?
dev_pm_genpd_is_on() drops the genpd lock before returning, and no
runtime PM reference is held on bc->bus_power_dev during the domain loop
in imx8m_blk_ctrl_probe(). If DISPMIX was off at boot, an earlier probe
of a child domain such as pgc_mipi powers pgc_dispmix on with
PD_FLAG_ATTACH_POWER_ON, and dev_pm_domain_attach_by_name() in
imx8m_blk_ctrl_probe() queues pgc_dispmix->power_off_work on pm_wq right
before imx8m_blk_ctrl_is_off() runs:
CPU0 kworker (pm_wq)
imx8m_blk_ctrl_probe()
dev_pm_domain_attach_by_name()
genpd_queue_power_off_work()
imx8m_blk_ctrl_is_off()
dev_pm_genpd_is_on() -> true
genpd_power_off_work_fn()
imx_pgc_power_down(pgc_dispmix)
regmap_read(bc->regmap, ...) <-- MMIO read with DISPMIX powered off
Reading the disp_blk_ctrl registers after DISPMIX and its
DISP_AXI_ROOT/DISP_APB_ROOT clocks are disabled causes a bus hang or
synchronous external abort during boot.
> +
> +/* 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;
> +
> + if (!domain->boot_on)
> + return 0;
> +
> + 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");
> +
> + return 0;
> +}
> +
> +static void imx8m_blk_ctrl_put_boot_on(struct imx8m_blk_ctrl_domain *domain)
> +{
> + if (!domain->boot_on)
> + return;
> +
> + /* Sync, to power down the bus domain before its notifier is removed */
> + pm_runtime_put_sync(domain->power_dev);
> + pm_runtime_put_sync(domain->bc->bus_power_dev);
> + domain->boot_on = false;
> +}
[ ... ]
> @@ -353,6 +439,10 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
> dev_pm_genpd_remove_notifier(bc->bus_power_dev);
> cleanup_provider:
> of_genpd_del_provider(dev->of_node);
> +cleanup_boot_on:
> + while (i--)
> + imx8m_blk_ctrl_put_boot_on(&bc->domains[i]);
> + i = bc_data->num_domains;
> cleanup_pds:
> for (i--; i >= 0; i--) {
> pm_genpd_remove(&bc->domains[i].genpd);
> @@ -374,6 +464,7 @@ static void imx8m_blk_ctrl_remove(struct platform_device *pdev)
> for (i = 0; i < bc->onecell_data.num_domains; i++) {
> struct imx8m_blk_ctrl_domain *domain = &bc->domains[i];
>
> + imx8m_blk_ctrl_put_boot_on(domain);
> pm_genpd_remove(&domain->genpd);
> dev_pm_domain_detach(domain->power_dev, true);
> }
[Severity: Medium]
Can imx8m_blk_ctrl_put_boot_on() race with domain->genpd.power_off_work
when called before pm_genpd_remove()?
Both imx8m_blk_ctrl_remove() and the cleanup_boot_on path in
imx8m_blk_ctrl_probe() call imx8m_blk_ctrl_put_boot_on() before
pm_genpd_remove() cancels power_off_work, without taking genpd_lock or
transitioning domain->genpd.status to GENPD_STATE_OFF. If power_off_work
was queued on pm_wq (for example by genpd_power_off_unused() or when a
consumer detaches), both paths drop the same runtime PM references:
CPU0 kworker (pm_wq)
imx8m_blk_ctrl_remove()
imx8m_blk_ctrl_put_boot_on(domain)
pm_runtime_put_sync(power_dev)
pm_runtime_put_sync(bus_power_dev)
domain->boot_on = false
pm_genpd_remove(&domain->genpd)
cancel_work_sync(&power_off_work)
genpd_power_off_work_fn()
genpd_power_off()
imx8m_blk_ctrl_power_off()
regmap_clear_bits(...)
pm_runtime_put(power_dev)
pm_runtime_put(bus_power_dev)
<-- double put & MMIO while
bus_power_dev is off
Calling pm_genpd_remove(&domain->genpd) before
imx8m_blk_ctrl_put_boot_on(domain) (matching imx_pgc_domain_remove() in
drivers/pmdomain/imx/gpcv2.c) ensures power_off_work is flushed before
checking domain->boot_on.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261122095927.2631909-1-dario.binacchi@amarulasolutions.com?part=3
next prev parent reply other threads:[~2026-11-22 10:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 9:59 [PATCH v2 0/4] pmdomain: imx: Keep the domains left on by the bootloader Dario Binacchi
2026-11-22 9:59 ` [PATCH v2 1/4] pmdomain: imx8m-blk-ctrl: Remove the power notifier on probe failure Dario Binacchi
2026-11-22 9:59 ` [PATCH v2 2/4] pmdomain: imx: gpcv2: Keep the domains left on by the bootloader Dario Binacchi
2026-11-22 10:12 ` sashiko-bot
2026-11-22 9:59 ` [PATCH v2 3/4] pmdomain: imx8m-blk-ctrl: " Dario Binacchi
2026-11-22 10:20 ` sashiko-bot [this message]
2026-11-22 9:59 ` [PATCH v2 4/4] 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-227889@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox