From: sashiko-bot@kernel.org
To: "Markus Elfring" <Markus.Elfring@web.de>, imx@lists.linux.dev
Cc: Frank.Li@kernel.org
Subject: Re: [PATCH] spi: imx: Use devm_clk_get_enabled() calls in spi_imx_probe()
Date: Mon, 23 Nov 2026 16:29:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-229658@kernel.org> (raw)
In-Reply-To: <895d50a6-3a42-44d2-8625-3b8cba8fbfff@web.de>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] spi: imx: double clk_disable_unprepare() on unbind in
spi_imx_probe()
--
commit e7cc62f9e52ed65ab0fb34e0d12c2e19021d535c
Author: Markus Elfring <elfring@users.sourceforge.net>
spi: imx: Use devm_clk_get_enabled() calls in spi_imx_probe()
This commit replaces devm_clk_get() and clk_prepare_enable() for clk_ipg
and clk_per in spi_imx_probe() with devm_clk_get_enabled() and removes the
clk_disable_unprepare() calls from the probe error path.
> diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> index 90d5b635c3822..76f5543adfd2e 100644
> --- a/drivers/spi/spi-imx.c
> +++ b/drivers/spi/spi-imx.c
> @@ -2320,22 +2320,14 @@ static int spi_imx_probe(struct platform_device *pdev)
> if (ret)
> return dev_err_probe(&pdev->dev, ret, "can't get irq%d\n", irq);
>
> - spi_imx->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
> + spi_imx->clk_ipg = devm_clk_get_enabled(&pdev->dev, "ipg");
> if (IS_ERR(spi_imx->clk_ipg))
> return PTR_ERR(spi_imx->clk_ipg);
>
> - spi_imx->clk_per = devm_clk_get(&pdev->dev, "per");
> + spi_imx->clk_per = devm_clk_get_enabled(&pdev->dev, "per");
> if (IS_ERR(spi_imx->clk_per))
> return PTR_ERR(spi_imx->clk_per);
>
> - ret = clk_prepare_enable(spi_imx->clk_per);
> - if (ret)
> - return ret;
> -
> - ret = clk_prepare_enable(spi_imx->clk_ipg);
> - if (ret)
> - goto out_put_per;
> -
> pm_runtime_set_autosuspend_delay(spi_imx->dev, MXC_RPM_TIMEOUT);
> pm_runtime_use_autosuspend(spi_imx->dev);
> pm_runtime_get_noresume(spi_imx->dev);
[Severity: High]
Does using devm_clk_get_enabled() here cause a double
clk_disable_unprepare() on clk_per and clk_ipg when the device is unbound?
spi_imx_probe() calls pm_runtime_set_active() right after enabling the
clocks, handing ownership of that initial prepare/enable reference to
runtime PM:
drivers/spi/spi-imx.c:spi_imx_remove() {
...
pm_runtime_dont_use_autosuspend(spi_imx->dev);
pm_runtime_put_sync(spi_imx->dev);
pm_runtime_disable(spi_imx->dev);
...
}
drivers/spi/spi-imx.c:spi_imx_runtime_suspend() {
...
clk_disable_unprepare(spi_imx->clk_per);
clk_disable_unprepare(spi_imx->clk_ipg);
return 0;
}
When spi_imx_remove() runs with CONFIG_PM enabled, pm_runtime_put_sync()
invokes spi_imx_runtime_suspend() and disables both clocks. The
devm_clk_get_enabled() release action then calls clk_disable_unprepare() a
second time on already-disabled clk_per and clk_ipg, triggering clock
enable/prepare count underflow warnings.
--
Sashiko AI review · https://sashiko.dev/#/patchset/895d50a6-3a42-44d2-8625-3b8cba8fbfff@web.de?part=1
next prev parent reply other threads:[~2026-11-23 16:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 16:23 [PATCH] spi: imx: Use devm_clk_get_enabled() calls in spi_imx_probe() Markus Elfring
2026-11-23 16:29 ` sashiko-bot [this message]
2026-11-23 17:27 ` Andy Shevchenko
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-229658@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=Markus.Elfring@web.de \
--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