Skip to content

Commit cdfb20e

Browse files
kromligregkh
authored andcommitted
spi: spi-cadence-quadspi: Fix pm runtime unbalance
commit b07f349 upstream. Having PM put sync in remove function is causing PM underflow during remove operation. This is caused by the function, runtime_pm_get_sync, not being called anywhere during the op. Ensure that calls to pm_runtime_enable()/pm_runtime_disable() and pm_runtime_get_sync()/pm_runtime_put_sync() match. echo 108d2000.spi > /sys/bus/platform/drivers/cadence-qspi/unbind [ 49.644256] Deleting MTD partitions on "108d2000.spi.0": [ 49.649575] Deleting u-boot MTD partition [ 49.684087] Deleting root MTD partition [ 49.724188] cadence-qspi 108d2000.spi: Runtime PM usage count underflow! Continuous bind/unbind will result in an "Unbalanced pm_runtime_enable" error. Subsequent unbind attempts will return a "No such device" error, while bind attempts will return a "Resource temporarily unavailable" error. [ 47.592434] cadence-qspi 108d2000.spi: Runtime PM usage count underflow! [ 49.592233] cadence-qspi 108d2000.spi: detected FIFO depth (1024) different from config (128) [ 53.232309] cadence-qspi 108d2000.spi: Runtime PM usage count underflow! [ 55.828550] cadence-qspi 108d2000.spi: detected FIFO depth (1024) different from config (128) [ 57.940627] cadence-qspi 108d2000.spi: Runtime PM usage count underflow! [ 59.912490] cadence-qspi 108d2000.spi: detected FIFO depth (1024) different from config (128) [ 61.876243] cadence-qspi 108d2000.spi: Runtime PM usage count underflow! [ 61.883000] platform 108d2000.spi: Unbalanced pm_runtime_enable! [ 532.012270] cadence-qspi 108d2000.spi: probe with driver cadence-qspi failed1 Also, change clk_disable_unprepare() to clk_disable() since continuous bind and unbind operations will trigger a warning indicating that the clock is already unprepared. Fixes: 4892b37 ("mtd: spi-nor: cadence-quadspi: Add runtime PM support") cc: stable@vger.kernel.org # 6.6+ Signed-off-by: Khairul Anuar Romli <khairul.anuar.romli@altera.com> Reviewed-by: Matthew Gerlach <matthew.gerlach@altera.com> Link: https://patch.msgid.link/4e7a4b8aba300e629b45a04f90bddf665fbdb335.1749601877.git.khairul.anuar.romli@altera.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c46358d commit cdfb20e

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

drivers/spi/spi-cadence-quadspi.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1868,6 +1868,13 @@ static int cqspi_probe(struct platform_device *pdev)
18681868
goto probe_setup_failed;
18691869
}
18701870

1871+
pm_runtime_enable(dev);
1872+
1873+
if (cqspi->rx_chan) {
1874+
dma_release_channel(cqspi->rx_chan);
1875+
goto probe_setup_failed;
1876+
}
1877+
18711878
ret = spi_register_controller(host);
18721879
if (ret) {
18731880
dev_err(&pdev->dev, "failed to register SPI ctlr %d\n", ret);
@@ -1877,6 +1884,7 @@ static int cqspi_probe(struct platform_device *pdev)
18771884
return 0;
18781885
probe_setup_failed:
18791886
cqspi_controller_enable(cqspi, 0);
1887+
pm_runtime_disable(dev);
18801888
probe_reset_failed:
18811889
if (cqspi->is_jh7110)
18821890
cqspi_jh7110_disable_clk(pdev, cqspi);
@@ -1898,7 +1906,8 @@ static void cqspi_remove(struct platform_device *pdev)
18981906
if (cqspi->rx_chan)
18991907
dma_release_channel(cqspi->rx_chan);
19001908

1901-
clk_disable_unprepare(cqspi->clk);
1909+
if (pm_runtime_get_sync(&pdev->dev) >= 0)
1910+
clk_disable(cqspi->clk);
19021911

19031912
if (cqspi->is_jh7110)
19041913
cqspi_jh7110_disable_clk(pdev, cqspi);

0 commit comments

Comments
 (0)