Skip to content

Commit e882575

Browse files
power-xsfbroonie
authored andcommitted
spi: rockchip: Suspend and resume the bus during NOIRQ_SYSTEM_SLEEP_PM ops
the wakeup interrupt handler which is guaranteed not to run while @resume noirq() is being executed. the patch can help to avoid the wakeup source try to access spi when the spi is in suspend mode. Signed-off-by: shengfei Xu <xsf@rock-chips.com> Signed-off-by: Jon Lin <jon.lin@rock-chips.com> Link: https://lore.kernel.org/r/20220216014028.8123-6-jon.lin@rock-chips.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 3a4bf92 commit e882575

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/spi/spi-rockchip.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -964,14 +964,14 @@ static int rockchip_spi_suspend(struct device *dev)
964964
{
965965
int ret;
966966
struct spi_controller *ctlr = dev_get_drvdata(dev);
967+
struct rockchip_spi *rs = spi_controller_get_devdata(ctlr);
967968

968969
ret = spi_controller_suspend(ctlr);
969970
if (ret < 0)
970971
return ret;
971972

972-
ret = pm_runtime_force_suspend(dev);
973-
if (ret < 0)
974-
return ret;
973+
clk_disable_unprepare(rs->spiclk);
974+
clk_disable_unprepare(rs->apb_pclk);
975975

976976
pinctrl_pm_select_sleep_state(dev);
977977

@@ -986,10 +986,14 @@ static int rockchip_spi_resume(struct device *dev)
986986

987987
pinctrl_pm_select_default_state(dev);
988988

989-
ret = pm_runtime_force_resume(dev);
989+
ret = clk_prepare_enable(rs->apb_pclk);
990990
if (ret < 0)
991991
return ret;
992992

993+
ret = clk_prepare_enable(rs->spiclk);
994+
if (ret < 0)
995+
clk_disable_unprepare(rs->apb_pclk);
996+
993997
ret = spi_controller_resume(ctlr);
994998
if (ret < 0) {
995999
clk_disable_unprepare(rs->spiclk);
@@ -1031,7 +1035,7 @@ static int rockchip_spi_runtime_resume(struct device *dev)
10311035
#endif /* CONFIG_PM */
10321036

10331037
static const struct dev_pm_ops rockchip_spi_pm = {
1034-
SET_SYSTEM_SLEEP_PM_OPS(rockchip_spi_suspend, rockchip_spi_resume)
1038+
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(rockchip_spi_suspend, rockchip_spi_resume)
10351039
SET_RUNTIME_PM_OPS(rockchip_spi_runtime_suspend,
10361040
rockchip_spi_runtime_resume, NULL)
10371041
};

0 commit comments

Comments
 (0)