1. Issue on branch 6.6.y using board Stratix10.
I encountered cadence-qspi ff8d2000.spi: Unbalanced pm_runtime_enable! error.
After reverting these two commitsi on branch 6.6.y: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/driv... https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/driv... Unbalanced pm_runtime_enable! error does not appear.
2. Analyse of the codes These two commits are cherry-picked from master branch, the commit id on master branch is b07f349d1864 and 04a8ff1bc351. 04a8ff1bc351 fix b07f349d1864. b07f349d1864 fix 86401132d7bb. 86401132d7bb fix 0578a6dbfe75. 6.6.y only backport b07f349d1864 and 04a8ff1bc351, but does not backport 0578a6dbfe75 and 86401132d7bb. And the backport of b07f349d1864 differs with the original patch. So there is Unbalanced pm_runtime_enable error. If revert the backport for b07f349d1864 and 04a8ff1bc351, there is no error. If backport 0578a6dbfe75 and 86401132d7bb, there is hang during booting. I didn't find the cause of the hang. Since 0578a6dbfe75 and 86401132d7bb are not backported, b07f349d1864 and 04a8ff1bc351 are not needed. How about reverting the bakcports cdfb20e4b34a and 1af6d1696ca4 for b07f349d1864 and 04a8ff1bc351 on 6.6?
3. More details are belows: These two commits are cherry-picked from master branch, the commit id on master branch is b07f349d1864 and 04a8ff1bc351. And the second commit(master:04a8ff1bc351) is to fix the first commit(master:b07f349d1864). So later focus on analyzing the first commit(master:b07f349d1864).
the change of master:b07f349d1864 in function cqspi_probe is: +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1958,10 +1958,10 @@ static int cqspi_probe(struct platform_device *pdev) goto probe_setup_failed; }
- ret = devm_pm_runtime_enable(dev); - if (ret) { - if (cqspi->rx_chan) - dma_release_channel(cqspi->rx_chan); + pm_runtime_enable(dev); + + if (cqspi->rx_chan) { + dma_release_channel(cqspi->rx_chan); goto probe_setup_failed; } commit(master:b07f349d1864) is to fix logical after these two commits(0578a6dbfe75 and 86401132d7bb: the second 86401132d7bb is to fix the first 0578a6dbfe75): https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/driv...
@@ -1862,21 +1877,29 @@ static int cqspi_probe(struct platform_device *pdev) goto probe_setup_failed; }
+ ret = devm_pm_runtime_enable(dev); + if (ret) + return ret; + + pm_runtime_set_autosuspend_delay(dev, CQSPI_AUTOSUSPEND_TIMEOUT); + pm_runtime_use_autosuspend(dev); + pm_runtime_get_noresume(dev);
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/driv...
diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c index 4828da4587c564..3d7bf62da11cb6 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1878,8 +1878,11 @@ static int cqspi_probe(struct platform_device *pdev) }
ret = devm_pm_runtime_enable(dev); - if (ret) - return ret; + if (ret) { + if (cqspi->rx_chan) + dma_release_channel(cqspi->rx_chan); + goto probe_setup_failed; + }
pm_runtime_set_autosuspend_delay(dev, CQSPI_AUTOSUSPEND_TIMEOUT); pm_runtime_use_autosuspend(dev);
So the "Fixes: 4892b374c9b7" section in the commit b07f349d1864 seems not correct. commit b07f349d1864 is to fix 0578a6dbfe75 and 86401132d7bb. 6.6 doesn't cherry-pick the commits(0578a6dbfe75 and 86401132d7bb). 6.6 only cherry-pick the their fix commits.
I tried to backport 0578a6dbfe75 to 6.6 after reverting (branch6.6 cdfb20e4b34a and 1af6d1696ca4), it failed to boot the board. So 0578a6dbfe75 has other dependency.
Thanks.