Skip to content

Commit 5e8bb0c

Browse files
jhovoldbroonie
authored andcommitted
spi: cadence-quadspi: fix runtime pm and clock imbalance on unbind
Make sure to balance the runtime PM usage count before returning on probe failure (to allow the controller to suspend after a probe deferral) and to only drop the usage count on driver unbind to avoid a clock disable imbalance. Also restore the autosuspend setting. Fixes: 0578a6d ("spi: spi-cadence-quadspi: add runtime pm support") Cc: stable@vger.kernel.org # 6.7 Cc: Dhruva Gole <d-gole@ti.com> Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20260421125354.1534871-5-johan@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 233db2c commit 5e8bb0c

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

drivers/spi/spi-cadence-quadspi.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,10 +1860,6 @@ static int cqspi_probe(struct platform_device *pdev)
18601860
if (irq < 0)
18611861
return -ENXIO;
18621862

1863-
ret = pm_runtime_set_active(dev);
1864-
if (ret)
1865-
return ret;
1866-
18671863
ret = clk_bulk_prepare_enable(CLK_QSPI_NUM, cqspi->clks);
18681864
if (ret) {
18691865
dev_err(dev, "Cannot enable QSPI clocks.\n");
@@ -1962,10 +1958,11 @@ static int cqspi_probe(struct platform_device *pdev)
19621958
cqspi->sclk = 0;
19631959

19641960
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
1965-
pm_runtime_enable(dev);
19661961
pm_runtime_set_autosuspend_delay(dev, CQSPI_AUTOSUSPEND_TIMEOUT);
19671962
pm_runtime_use_autosuspend(dev);
19681963
pm_runtime_get_noresume(dev);
1964+
pm_runtime_set_active(dev);
1965+
pm_runtime_enable(dev);
19691966
}
19701967

19711968
host->num_chipselect = cqspi->num_chipselect;
@@ -1996,8 +1993,12 @@ static int cqspi_probe(struct platform_device *pdev)
19961993
if (cqspi->rx_chan)
19971994
dma_release_channel(cqspi->rx_chan);
19981995
disable_rpm:
1999-
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM)))
1996+
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
20001997
pm_runtime_disable(dev);
1998+
pm_runtime_set_suspended(dev);
1999+
pm_runtime_put_noidle(dev);
2000+
pm_runtime_dont_use_autosuspend(dev);
2001+
}
20012002
cqspi_controller_enable(cqspi, 0);
20022003
disable_clks:
20032004
clk_bulk_disable_unprepare(CLK_QSPI_NUM, cqspi->clks);
@@ -2033,8 +2034,10 @@ static void cqspi_remove(struct platform_device *pdev)
20332034
}
20342035

20352036
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
2036-
pm_runtime_put_sync(&pdev->dev);
20372037
pm_runtime_disable(&pdev->dev);
2038+
pm_runtime_set_suspended(&pdev->dev);
2039+
pm_runtime_put_noidle(&pdev->dev);
2040+
pm_runtime_dont_use_autosuspend(&pdev->dev);
20382041
}
20392042
}
20402043

0 commit comments

Comments
 (0)