summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-cadence.c
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.cirrus.com>2019-01-04 13:08:09 -0500
committerMark Brown <broonie@kernel.org>2019-01-14 17:16:48 -0500
commit734882a8bf984c2ac8a57d8ac3ee53230bd0bed8 (patch)
tree8c88baf470c34204604122da7bf85706d2e476d5 /drivers/spi/spi-cadence.c
parentde43affed77b1bd9f246235dbd94eb23b07ab657 (diff)
spi: cadence: Correct initialisation of runtime PM
Currently the driver calls pm_runtime_put_autosuspend but without ever having done a pm_runtime_get, this causes the reference count in the pm runtime core to become -1. The bad reference count causes the core to sometimes suspend whilst an active SPI transfer is in progress. arizona spi0.1: SPI transfer timed out spi_master spi0: failed to transfer one message from queue The correct proceedure is to do all the initialisation that requires the hardware to be powered up before enabling the PM runtime, then enable the PM runtime having called pm_runtime_set_active to inform it that the hardware is currently powered up. The core will then power it down at it's leisure and no explicit pm_runtime_put is required. Fixes: d36ccd9f7ea4 ("spi: cadence: Runtime pm adaptation") Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-cadence.c')
-rw-r--r--drivers/spi/spi-cadence.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
index e332d173dbf9..5036d89f46bb 100644
--- a/drivers/spi/spi-cadence.c
+++ b/drivers/spi/spi-cadence.c
@@ -522,11 +522,6 @@ static int cdns_spi_probe(struct platform_device *pdev)
522 goto clk_dis_apb; 522 goto clk_dis_apb;
523 } 523 }
524 524
525 pm_runtime_use_autosuspend(&pdev->dev);
526 pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT);
527 pm_runtime_set_active(&pdev->dev);
528 pm_runtime_enable(&pdev->dev);
529
530 ret = of_property_read_u32(pdev->dev.of_node, "num-cs", &num_cs); 525 ret = of_property_read_u32(pdev->dev.of_node, "num-cs", &num_cs);
531 if (ret < 0) 526 if (ret < 0)
532 master->num_chipselect = CDNS_SPI_DEFAULT_NUM_CS; 527 master->num_chipselect = CDNS_SPI_DEFAULT_NUM_CS;
@@ -541,8 +536,10 @@ static int cdns_spi_probe(struct platform_device *pdev)
541 /* SPI controller initializations */ 536 /* SPI controller initializations */
542 cdns_spi_init_hw(xspi); 537 cdns_spi_init_hw(xspi);
543 538
544 pm_runtime_mark_last_busy(&pdev->dev); 539 pm_runtime_set_active(&pdev->dev);
545 pm_runtime_put_autosuspend(&pdev->dev); 540 pm_runtime_enable(&pdev->dev);
541 pm_runtime_use_autosuspend(&pdev->dev);
542 pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT);
546 543
547 irq = platform_get_irq(pdev, 0); 544 irq = platform_get_irq(pdev, 0);
548 if (irq <= 0) { 545 if (irq <= 0) {