spi: cadence: Correct initialisation of runtime PM
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Fri, 4 Jan 2019 18:08:09 +0000 (18:08 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Jan 2020 13:50:12 +0000 (14:50 +0100)
commitce519d838622bfed7eeeb7a87310c9732998bde3
tree60bd5ad3ea9ecb6529dbad4979f8b2304c467b9d
parent77f383f4fda973b60806b73ebe2cd3e3e658abfa
spi: cadence: Correct initialisation of runtime PM

[ Upstream commit 734882a8bf984c2ac8a57d8ac3ee53230bd0bed8 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/spi/spi-cadence.c