mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-26 04:34:41 -04:00
spi: cadence-quadspi: runtime PM fixes
Johan Hovold <johan@kernel.org> says: This series fixes some runtime PM related issues in the cadence-quadspi driver. Included is also a couple of related cleanups.
This commit is contained in:
@@ -1478,7 +1478,6 @@ static int cqspi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op)
|
||||
int ret;
|
||||
struct cqspi_st *cqspi = spi_controller_get_devdata(mem->spi->controller);
|
||||
struct device *dev = &cqspi->pdev->dev;
|
||||
const struct cqspi_driver_platdata *ddata = of_device_get_match_data(dev);
|
||||
|
||||
if (refcount_read(&cqspi->inflight_ops) == 0)
|
||||
return -ENODEV;
|
||||
@@ -1494,18 +1493,15 @@ 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 = 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)))
|
||||
pm_runtime_put_autosuspend(dev);
|
||||
pm_runtime_put_autosuspend(dev);
|
||||
|
||||
if (ret)
|
||||
dev_err(&mem->spi->dev, "operation failed with %d\n", ret);
|
||||
@@ -1860,14 +1856,10 @@ static int cqspi_probe(struct platform_device *pdev)
|
||||
if (irq < 0)
|
||||
return -ENXIO;
|
||||
|
||||
ret = pm_runtime_set_active(dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = clk_bulk_prepare_enable(CLK_QSPI_NUM, cqspi->clks);
|
||||
if (ret) {
|
||||
dev_err(dev, "Cannot enable QSPI clocks.\n");
|
||||
goto disable_rpm;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Obtain QSPI reset control */
|
||||
@@ -1961,12 +1953,11 @@ static int cqspi_probe(struct platform_device *pdev)
|
||||
cqspi->current_cs = -1;
|
||||
cqspi->sclk = 0;
|
||||
|
||||
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
|
||||
pm_runtime_enable(dev);
|
||||
pm_runtime_set_autosuspend_delay(dev, CQSPI_AUTOSUSPEND_TIMEOUT);
|
||||
pm_runtime_use_autosuspend(dev);
|
||||
pm_runtime_get_noresume(dev);
|
||||
}
|
||||
pm_runtime_set_autosuspend_delay(dev, CQSPI_AUTOSUSPEND_TIMEOUT);
|
||||
pm_runtime_use_autosuspend(dev);
|
||||
pm_runtime_get_noresume(dev);
|
||||
pm_runtime_set_active(dev);
|
||||
pm_runtime_enable(dev);
|
||||
|
||||
host->num_chipselect = cqspi->num_chipselect;
|
||||
|
||||
@@ -1977,7 +1968,7 @@ static int cqspi_probe(struct platform_device *pdev)
|
||||
ret = cqspi_request_mmap_dma(cqspi);
|
||||
if (ret == -EPROBE_DEFER) {
|
||||
dev_err_probe(&pdev->dev, ret, "Failed to request mmap DMA\n");
|
||||
goto disable_controller;
|
||||
goto disable_rpm;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1995,27 +1986,25 @@ static int cqspi_probe(struct platform_device *pdev)
|
||||
release_dma_chan:
|
||||
if (cqspi->rx_chan)
|
||||
dma_release_channel(cqspi->rx_chan);
|
||||
disable_controller:
|
||||
disable_rpm:
|
||||
pm_runtime_disable(dev);
|
||||
pm_runtime_set_suspended(dev);
|
||||
pm_runtime_put_noidle(dev);
|
||||
pm_runtime_dont_use_autosuspend(dev);
|
||||
|
||||
cqspi_controller_enable(cqspi, 0);
|
||||
disable_clks:
|
||||
if (pm_runtime_get_sync(&pdev->dev) >= 0)
|
||||
clk_bulk_disable_unprepare(CLK_QSPI_NUM, cqspi->clks);
|
||||
disable_rpm:
|
||||
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM)))
|
||||
pm_runtime_disable(dev);
|
||||
clk_bulk_disable_unprepare(CLK_QSPI_NUM, cqspi->clks);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void cqspi_remove(struct platform_device *pdev)
|
||||
{
|
||||
const struct cqspi_driver_platdata *ddata;
|
||||
struct cqspi_st *cqspi = platform_get_drvdata(pdev);
|
||||
struct device *dev = &pdev->dev;
|
||||
const struct cqspi_driver_platdata *ddata = cqspi->ddata;
|
||||
int ret = 0;
|
||||
|
||||
ddata = of_device_get_match_data(dev);
|
||||
|
||||
spi_unregister_controller(cqspi->host);
|
||||
|
||||
refcount_set(&cqspi->refcount, 0);
|
||||
@@ -2026,19 +2015,18 @@ static void cqspi_remove(struct platform_device *pdev)
|
||||
if (cqspi->rx_chan)
|
||||
dma_release_channel(cqspi->rx_chan);
|
||||
|
||||
cqspi_controller_enable(cqspi, 0);
|
||||
|
||||
|
||||
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM)))
|
||||
ret = pm_runtime_get_sync(&pdev->dev);
|
||||
|
||||
if (ret >= 0)
|
||||
if (ret >= 0) {
|
||||
cqspi_controller_enable(cqspi, 0);
|
||||
clk_bulk_disable_unprepare(CLK_QSPI_NUM, cqspi->clks);
|
||||
|
||||
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
|
||||
pm_runtime_put_sync(&pdev->dev);
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
}
|
||||
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
pm_runtime_set_suspended(&pdev->dev);
|
||||
pm_runtime_put_noidle(&pdev->dev);
|
||||
pm_runtime_dont_use_autosuspend(&pdev->dev);
|
||||
}
|
||||
|
||||
static int cqspi_runtime_suspend(struct device *dev)
|
||||
|
||||
Reference in New Issue
Block a user