[PATCH] spi: imx: fix runtime pm leak on probe deferral

Johan Hovold posted 1 patch 1 month, 3 weeks ago
drivers/spi/spi-imx.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] spi: imx: fix runtime pm leak on probe deferral
Posted by Johan Hovold 1 month, 3 weeks ago
Make sure to balance the runtime PM usage count before returning on
probe failure (e.g. probe deferral) so that the controller can be
suspended when a driver is later bound.

Fixes: 43b6bf406cd0 ("spi: imx: fix runtime pm support for !CONFIG_PM")
Cc: stable@vger.kernel.org	# 5.10
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/spi/spi-imx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 4747899e0646..e5c907c45b87 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -2373,6 +2373,7 @@ static int spi_imx_probe(struct platform_device *pdev)
 out_runtime_pm_put:
 	pm_runtime_dont_use_autosuspend(spi_imx->dev);
 	pm_runtime_disable(spi_imx->dev);
+	pm_runtime_put_noidle(spi_imx->dev);
 	pm_runtime_set_suspended(&pdev->dev);
 
 	clk_disable_unprepare(spi_imx->clk_ipg);
-- 
2.52.0
Re: [PATCH] spi: imx: fix runtime pm leak on probe deferral
Posted by Mark Brown 1 month, 3 weeks ago
On Tue, 21 Apr 2026 14:56:32 +0200, Johan Hovold wrote:
> spi: imx: fix runtime pm leak on probe deferral

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.1

Thanks!

[1/1] spi: imx: fix runtime pm leak on probe deferral
      https://git.kernel.org/broonie/spi/c/a1d50a37d3b1

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
Re: [PATCH] spi: imx: fix runtime pm leak on probe deferral
Posted by Frank Li 1 month, 3 weeks ago
On Tue, Apr 21, 2026 at 02:56:32PM +0200, Johan Hovold wrote:
> Make sure to balance the runtime PM usage count before returning on
> probe failure (e.g. probe deferral) so that the controller can be
> suspended when a driver is later bound.
>
> Fixes: 43b6bf406cd0 ("spi: imx: fix runtime pm support for !CONFIG_PM")
> Cc: stable@vger.kernel.org	# 5.10
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  drivers/spi/spi-imx.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> index 4747899e0646..e5c907c45b87 100644
> --- a/drivers/spi/spi-imx.c
> +++ b/drivers/spi/spi-imx.c
> @@ -2373,6 +2373,7 @@ static int spi_imx_probe(struct platform_device *pdev)
>  out_runtime_pm_put:
>  	pm_runtime_dont_use_autosuspend(spi_imx->dev);
>  	pm_runtime_disable(spi_imx->dev);
> +	pm_runtime_put_noidle(spi_imx->dev);

use devm_pm_runtime_get_noresume() and  devm_pm_runtime_enable() to
fix this problem

Frank
>  	pm_runtime_set_suspended(&pdev->dev);
>
>  	clk_disable_unprepare(spi_imx->clk_ipg);
> --
> 2.52.0
>
Re: [PATCH] spi: imx: fix runtime pm leak on probe deferral
Posted by Johan Hovold 1 month, 3 weeks ago
On Tue, Apr 21, 2026 at 11:32:48PM -0400, Frank Li wrote:
> On Tue, Apr 21, 2026 at 02:56:32PM +0200, Johan Hovold wrote:
> > Make sure to balance the runtime PM usage count before returning on
> > probe failure (e.g. probe deferral) so that the controller can be
> > suspended when a driver is later bound.
> >
> > Fixes: 43b6bf406cd0 ("spi: imx: fix runtime pm support for !CONFIG_PM")
> > Cc: stable@vger.kernel.org	# 5.10
> > Cc: Sascha Hauer <s.hauer@pengutronix.de>
> > Signed-off-by: Johan Hovold <johan@kernel.org>
> > ---
> >  drivers/spi/spi-imx.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> > index 4747899e0646..e5c907c45b87 100644
> > --- a/drivers/spi/spi-imx.c
> > +++ b/drivers/spi/spi-imx.c
> > @@ -2373,6 +2373,7 @@ static int spi_imx_probe(struct platform_device *pdev)
> >  out_runtime_pm_put:
> >  	pm_runtime_dont_use_autosuspend(spi_imx->dev);
> >  	pm_runtime_disable(spi_imx->dev);
> > +	pm_runtime_put_noidle(spi_imx->dev);
> 
> use devm_pm_runtime_get_noresume() and  devm_pm_runtime_enable() to
> fix this problem

No. The first helper you mentioned was only added a year ago and does
not even solve the issue without rewriting larger parts of the driver.

So that would need to be a separate change in any case.

Johan
Re: [PATCH] spi: imx: fix runtime pm leak on probe deferral
Posted by Frank Li 1 month, 3 weeks ago
On Wed, Apr 22, 2026 at 08:47:57AM +0200, Johan Hovold wrote:
> On Tue, Apr 21, 2026 at 11:32:48PM -0400, Frank Li wrote:
> > On Tue, Apr 21, 2026 at 02:56:32PM +0200, Johan Hovold wrote:
> > > Make sure to balance the runtime PM usage count before returning on
> > > probe failure (e.g. probe deferral) so that the controller can be
> > > suspended when a driver is later bound.
> > >
> > > Fixes: 43b6bf406cd0 ("spi: imx: fix runtime pm support for !CONFIG_PM")
> > > Cc: stable@vger.kernel.org	# 5.10
> > > Cc: Sascha Hauer <s.hauer@pengutronix.de>
> > > Signed-off-by: Johan Hovold <johan@kernel.org>
> > > ---
> > >  drivers/spi/spi-imx.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> > > index 4747899e0646..e5c907c45b87 100644
> > > --- a/drivers/spi/spi-imx.c
> > > +++ b/drivers/spi/spi-imx.c
> > > @@ -2373,6 +2373,7 @@ static int spi_imx_probe(struct platform_device *pdev)
> > >  out_runtime_pm_put:
> > >  	pm_runtime_dont_use_autosuspend(spi_imx->dev);
> > >  	pm_runtime_disable(spi_imx->dev);
> > > +	pm_runtime_put_noidle(spi_imx->dev);
> >
> > use devm_pm_runtime_get_noresume() and  devm_pm_runtime_enable() to
> > fix this problem
>
> No. The first helper you mentioned was only added a year ago and does
> not even solve the issue without rewriting larger parts of the driver.
>
> So that would need to be a separate change in any case.

It should be less 10 line code changes. separate change is okay, but suggest
create following patches for this also.

Frank

>
> Johan