[PATCH] spi: Fix runtime PM imbalance on pump transfer message error
Sebastian Reichel
sebastian.reichel at collabora.com
Mon Nov 9 16:41:58 PST 2026
The current SPI message pumping code may drop the runtime PM twice when
an SPI message cannot be sent:
spi_master spi2: noqueue transfer failed
rockchip-spi feb20000.spi: Runtime PM usage count underflow!
Fix the problem by always keeping the runtime PM count increased when
exiting __spi_pump_transfer_message(), as the caller handles decreasing
it.
Note, that the function already keeps the RPM usage counter increased
for the error paths following after the prepare_transfer_hardware step.
Cc: stable at vger.kernel.org
Fixes: bef4a48f4ef7 ("spi: Fix null dereference on suspend")
Signed-off-by: Sebastian Reichel <sebastian.reichel at collabora.com>
---
I noticed this with RK3588 system suspend/resume, which uses SPI based
PMIC and runs into SPI transmission problems when the PM domain driver
tries to disable regulators required by e.g. NPU or GPU domain. I've not
yet checked too closely, but suspect Heiko's atomic SPI transmission
support series might also help with fixing the actual failure.
My patch is not really a v2, but Alexander Shiyan probably ran into the
same issue before and came up with a way different patch and rationale:
https://lore.kernel.org/linux-rockchip/20260806191854.922530-1-eagle.alexander923@gmail.com/
---
drivers/spi/spi.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index ce257b3ec530..4d9c5d026ff6 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1967,7 +1967,6 @@ static int __spi_pump_transfer_message(struct spi_controller *ctlr,
if (!was_busy && ctlr->auto_runtime_pm) {
ret = pm_runtime_get_sync(ctlr->dev.parent);
if (ret < 0) {
- pm_runtime_put_noidle(ctlr->dev.parent);
dev_err(&ctlr->dev, "Failed to power device: %d\n",
ret);
@@ -1988,9 +1987,6 @@ static int __spi_pump_transfer_message(struct spi_controller *ctlr,
"failed to prepare transfer hardware: %d\n",
ret);
- if (ctlr->auto_runtime_pm)
- pm_runtime_put(ctlr->dev.parent);
-
msg->status = ret;
spi_finalize_current_message(ctlr);
---
base-commit: 059518f775baecc9803fc97787bd0b17558f8047
change-id: 20261110-spi-runtime-pm-fix-529325c25582
Best regards,
--
Sebastian Reichel <sebastian.reichel at collabora.com>
More information about the Linux-rockchip
mailing list