Skip to contentSkip to conversation

OSPI pm_runtime fixes

PATCH In review Anurag Dutta 2 participants 4 messages Nov 5, 2025 – Nov 14, 2025 SPI

lore
Share & tools
lore
#0 lore raw

cover OSPI pm_runtime fixes

Hi all
This short series introduces fixes for OSPI pm_runtime to balance the runtime PM reference counting.

Logs :
https://gist.github.com/anuragdutta731/238dbc6d9ff7927c63cd4dcfc51dfa97

Anurag Dutta (2):
spi: spi-cadence-quadspi: Enable pm runtime earlier to avoid imbalance
spi: spi-cadence-quadspi: Remove duplicate
pm_runtime_put_autosuspend() call

 drivers/spi/spi-cadence-quadspi.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 spi: spi-cadence-quadspi: Enable pm runtime earlier to avoid imbalance

The "probe_setup_failed" label calls pm_runtime_disable(), but pm_runtime_enable() was placed after a possible jump to this label. When cqspi_setup_flash() fails, control jumps to the label without pm_runtime_enable() being called, leading to unbalanced PM runtime reference counting.

Move pm_runtime_enable() and associated calls above the first possible branch to "probe_setup_failed" to ensure balanced enable/disable calls across all error paths.

Fixes 30dbc1c8d50f ("spi: cadence-qspi: defer runtime support on socfpga if reset bit is enabled")
---
 drivers/spi/spi-cadence-quadspi.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/spi/spi-cadence-quadspi.c +7 -7
index 81017402bc56..56906dc76b34 100644
@@ -1981,6 +1981,13 @@ static int cqspi_probe(struct platform_device *pdev)
 	cqspi->current_cs = -1;
 	cqspi->sclk = 0;
 
+	if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
+		pm_runtime_enable(dev);
+		pm_runtime_set_autosuspend_delay(dev, CQSPI_AUTOSUSPEND_TIMEOUT);
+		pm_runtime_use_autosuspend(dev);
+		pm_runtime_get_noresume(dev);
+	}
+
 	ret = cqspi_setup_flash(cqspi);
 	if (ret) {
 		dev_err(dev, "failed to setup flash parameters %d\n", ret);
@@ -1998,13 +2005,6 @@ static int cqspi_probe(struct platform_device *pdev)
 			goto probe_dma_failed;
 	}
 
-	if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
-		pm_runtime_enable(dev);
-		pm_runtime_set_autosuspend_delay(dev, CQSPI_AUTOSUSPEND_TIMEOUT);
-		pm_runtime_use_autosuspend(dev);
-		pm_runtime_get_noresume(dev);
-	}
-
 	ret = spi_register_controller(host);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to register SPI ctlr %d\n", ret);
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/2 spi: spi-cadence-quadspi: Remove duplicate pm_runtime_put_autosuspend() call

In reply to Anurag Dutta

Fix runtime PM usage count underflow caused by calling pm_runtime_put_autosuspend() twice with only one corresponding pm_runtime_get_noresume() call. This triggers the warning:
"Runtime PM usage count underflow!"

Remove the duplicate put call to balance the runtime PM reference counting.

Fixes 30dbc1c8d50f ("spi: cadence-qspi: defer runtime support on socfpga if reset bit is enabled")
---
 drivers/spi/spi-cadence-quadspi.c | 1 -
 1 file changed, 1 deletion(-)
drivers/spi/spi-cadence-quadspi.c +0 -1
index 56906dc76b34..8e0df08609c0 100644
@@ -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);
 	}
Signature · 1 line
2.34.1
maintainer
#3 lore raw
In reply to Anurag Dutta
Quoted 6 lines · Anurag Dutta

This short series introduces fixes for OSPI pm_runtime to balance the runtime PM reference counting.

Logs :
https://gist.github.com/anuragdutta731/238dbc6d9ff7927c63cd4dcfc51dfa97

Quoted 6 lines

Anurag Dutta (2):
spi: spi-cadence-quadspi: Enable pm runtime earlier to avoid imbalance
spi: spi-cadence-quadspi: Remove duplicate
pm_runtime_put_autosuspend() call

[...]

Applied to

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

Thanks!

[1/2] spi: spi-cadence-quadspi: Enable pm runtime earlier to avoid imbalance

      commit: f1eb4e792bb1ee3dcdffa66f8a83a4867cda2dd3
[2/2] spi: spi-cadence-quadspi: Remove duplicate pm_runtime_put_autosuspend() call
      commit: 10eaa4c4a257944e9b30d13fda7d09164a70866d

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