[PATCH] spi: cadence-qspi: Fix runtime PM imbalance in probe

Ali Tariq posted 1 patch 2 months, 1 week ago
drivers/spi/spi-cadence-quadspi.c | 1 -
1 file changed, 1 deletion(-)
[PATCH] spi: cadence-qspi: Fix runtime PM imbalance in probe
Posted by Ali Tariq 2 months, 1 week ago
The probe function incorrectly calls pm_runtime_put_autosuspend()
twice in succession at the end of successful probe, dropping two
runtime PM references while only one was acquired earlier with
pm_runtime_get_sync(). This causes a usage count underflow:

    cadence-qspi 13010000.spi: Runtime PM usage count underflow!

Remove the first redundant pm_runtime_put_autosuspend() call to
balance the reference count.

Tested on StarFive VisionFive 2 v1.2A board.

Fixes: 30dbc1c8d50f ("spi: cadence-qspi: defer runtime support on socfpga if reset bit is enabled")

Signed-off-by: Ali Tariq <alitariq45892@gmail.com>
---
 drivers/spi/spi-cadence-quadspi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index 81017402bc56..638edca3805a 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -2012,7 +2012,6 @@ static int cqspi_probe(struct platform_device *pdev)
 	}
 
 	if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
-		pm_runtime_put_autosuspend(dev);
 		pm_runtime_mark_last_busy(dev);
 		pm_runtime_put_autosuspend(dev);
 	}
-- 
2.43.0
Re: [PATCH] spi: cadence-qspi: Fix runtime PM imbalance in probe
Posted by Andy Shevchenko 2 months, 1 week ago
On Sun, Nov 30, 2025 at 09:12:51AM +0000, Ali Tariq wrote:
> The probe function incorrectly calls pm_runtime_put_autosuspend()
> twice in succession at the end of successful probe, dropping two
> runtime PM references while only one was acquired earlier with
> pm_runtime_get_sync(). This causes a usage count underflow:
> 
>     cadence-qspi 13010000.spi: Runtime PM usage count underflow!
> 
> Remove the first redundant pm_runtime_put_autosuspend() call to
> balance the reference count.
> 
> Tested on StarFive VisionFive 2 v1.2A board.

...

>  	if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
> -		pm_runtime_put_autosuspend(dev);
>  		pm_runtime_mark_last_busy(dev);

This one — pm_runtime_mark_last_busy() — also may be removed as it's integrated
into the _put_auutosuspend().

>  		pm_runtime_put_autosuspend(dev);
>  	}

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] spi: cadence-qspi: Fix runtime PM imbalance in probe
Posted by Ali Tariq 2 months ago
Thanks for the merge. Recently, there was a patch which removed the
redundant pm_runtime_mark_last_busy() call:

https://lore.kernel.org/linux-kernel/20251203181921.97171-1-akifejaz40@gmail.com/

The patch removes pm_runtime_mark_last_busy() from the probe function,
as pm_runtime_put_autosuspend() already handles this internally.

Best Regards,
Ali

On 12/3/25 1:50 AM, Andy Shevchenko wrote:
> On Sun, Nov 30, 2025 at 09:12:51AM +0000, Ali Tariq wrote:
>> The probe function incorrectly calls pm_runtime_put_autosuspend()
>> twice in succession at the end of successful probe, dropping two
>> runtime PM references while only one was acquired earlier with
>> pm_runtime_get_sync(). This causes a usage count underflow:
>>
>>      cadence-qspi 13010000.spi: Runtime PM usage count underflow!
>>
>> Remove the first redundant pm_runtime_put_autosuspend() call to
>> balance the reference count.
>>
>> Tested on StarFive VisionFive 2 v1.2A board.
> 
> ...
> 
>>   	if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
>> -		pm_runtime_put_autosuspend(dev);
>>   		pm_runtime_mark_last_busy(dev);
> 
> This one — pm_runtime_mark_last_busy() — also may be removed as it's integrated
> into the _put_auutosuspend().
> 
>>   		pm_runtime_put_autosuspend(dev);
>>   	}
> 

Re: [PATCH] spi: cadence-qspi: Fix runtime PM imbalance in probe
Posted by Mark Brown 2 months, 1 week ago
On Sun, 30 Nov 2025 09:12:51 +0000, Ali Tariq wrote:
> The probe function incorrectly calls pm_runtime_put_autosuspend()
> twice in succession at the end of successful probe, dropping two
> runtime PM references while only one was acquired earlier with
> pm_runtime_get_sync(). This causes a usage count underflow:
> 
>     cadence-qspi 13010000.spi: Runtime PM usage count underflow!
> 
> [...]

Applied to

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

Thanks!

[1/1] spi: cadence-qspi: Fix runtime PM imbalance in probe
      commit: e1f2e77624dbc35f317efd7e092aa91f7136f3f9

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