Skip to content

Commit 102e9d1

Browse files
Christophe Kerellobroonie
authored andcommitted
spi: stm32-qspi: fix pm_runtime usage_count counter
pm_runtime usage_count counter is not well managed. pm_runtime_put_autosuspend callback drops the usage_counter but this one has never been increased. Add pm_runtime_get_sync callback to bump up the usage counter. It is also needed to use pm_runtime_force_suspend and pm_runtime_force_resume APIs to handle properly the clock. Fixes: 9d282c1 ("spi: stm32-qspi: Add pm_runtime support") Signed-off-by: Christophe Kerello <christophe.kerello@foss.st.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20210419121541.11617-2-patrice.chotard@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 126bdb6 commit 102e9d1

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

drivers/spi/spi-stm32-qspi.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,21 +727,31 @@ static int __maybe_unused stm32_qspi_suspend(struct device *dev)
727727
{
728728
pinctrl_pm_select_sleep_state(dev);
729729

730-
return 0;
730+
return pm_runtime_force_suspend(dev);
731731
}
732732

733733
static int __maybe_unused stm32_qspi_resume(struct device *dev)
734734
{
735735
struct stm32_qspi *qspi = dev_get_drvdata(dev);
736+
int ret;
737+
738+
ret = pm_runtime_force_resume(dev);
739+
if (ret < 0)
740+
return ret;
736741

737742
pinctrl_pm_select_default_state(dev);
738-
clk_prepare_enable(qspi->clk);
743+
744+
ret = pm_runtime_get_sync(dev);
745+
if (ret < 0) {
746+
pm_runtime_put_noidle(dev);
747+
return ret;
748+
}
739749

740750
writel_relaxed(qspi->cr_reg, qspi->io_base + QSPI_CR);
741751
writel_relaxed(qspi->dcr_reg, qspi->io_base + QSPI_DCR);
742752

743-
pm_runtime_mark_last_busy(qspi->dev);
744-
pm_runtime_put_autosuspend(qspi->dev);
753+
pm_runtime_mark_last_busy(dev);
754+
pm_runtime_put_autosuspend(dev);
745755

746756
return 0;
747757
}

0 commit comments

Comments
 (0)