spi: cadence-qspi: Fix exec_mem_op error handling
Subsystems (2)
PATCH 1/1 spi: cadence-qspi: Fix exec_mem_op error handling
From: Emanuele Ghidoli <[email protected]>
cqspi_exec_mem_op() increments the runtime PM usage counter before all refcount checks are performed. If one of these checks fails, the function returns without dropping the PM reference.
Move the pm_runtime_resume_and_get() call after the refcount checks so that runtime PM is only acquired when the operation can proceed and drop the inflight_ops refcount if the PM resume fails.
--- drivers/spi/spi-cadence-quadspi.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/spi/spi-cadence-quadspi.c +9 -8
@@ -1483,14 +1483,6 @@ static int cqspi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op)if (refcount_read (&cqspi->inflight_ops) ==0 )return -ENODEV ; -if (!(ddata && (ddata->quirks &CQSPI_DISABLE_RUNTIME_PM ))) { - ret =pm_runtime_resume_and_get (dev); -if (ret) { -dev_err (&mem->spi->dev,"resume failed with %d\n" , ret); -return ret; - } - } -if (!refcount_read (&cqspi->refcount))return -EBUSY ;
@@ -1502,6 +1494,14 @@ static int cqspi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op)return -EBUSY ; } +if (!(ddata && (ddata->quirks &CQSPI_DISABLE_RUNTIME_PM ))) { + ret =pm_runtime_resume_and_get (dev); +if (ret) { +dev_err (&mem->spi->dev,"resume failed with %d\n" , ret); + goto dec_inflight_refcount; + } + } + ret =cqspi_mem_process (mem, op);if (!(ddata && (ddata->quirks &CQSPI_DISABLE_RUNTIME_PM )))
@@ -1510,6 +1510,7 @@ static int cqspi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op)if (ret)dev_err (&mem->spi->dev,"operation failed with %d\n" , ret); +dec_inflight_refcount:if (refcount_read (&cqspi->inflight_ops) >1 )refcount_dec (&cqspi->inflight_ops);
Signature · 1 line
2.43.0
Mark Brown
maintainerQuoted 1 line · Emanuele Ghidoli
spi: cadence-qspi: Fix
exec_mem_operror handling
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.0
Thanks!
[1/1] spi: cadence-qspi: Fix exec_mem_op error handling
https://git.kernel.org/broonie/misc/c/59e1be1278f0
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
Mark Brown
maintainerQuoted 9 lines · Emanuele Ghidoli
cqspi_exec_mem_op()increments the runtime PM usage counter before all refcount checks are performed. If one of these checks fails, the function returns without dropping the PM reference.Move the
pm_runtime_resume_and_get()call after the refcount checks so that runtime PM is only acquired when the operation can proceed and drop theinflight_opsrefcount if the PM resume fails.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: cadence-qspi: Fix exec_mem_op error handling
https://git.kernel.org/broonie/misc/c/59e1be1278f0
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