[PATCH v2 3/3] spi: nxp-fspi: check runtime PM get in cleanup
Jiawen Liu <[email protected]> Tue, 28 Jul 2026 12:04:43 +0400
| Newsgroups | org.kernel.vger.linux-spi,dev.linux.lists.imx,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
nxp_fspi_cleanup() resumes the device before disabling the controller, because the cleanup path writes to controller registers. The return value from the runtime PM get is currently ignored, so a failed resume can be followed by MMIO access while the controller clock is still gated. Use PM_RUNTIME_ACQUIRE() and check the acquire result before touching the registers. If the device cannot be resumed, skip the hardware-disable MMIO write and continue with the remaining cleanup. Signed-off-by: Jiawen Liu <[email protected]> --- drivers/spi/spi-nxp-fspi.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c index 3f1c3ed748eb..2671ffb49096 100644 --- a/drivers/spi/spi-nxp-fspi.c +++ b/drivers/spi/spi-nxp-fspi.c @@ -1268,14 +1268,21 @@ static const struct spi_controller_mem_caps nxp_fspi_mem_caps_disable_dtr = { static void nxp_fspi_cleanup(void *data) { struct nxp_fspi *f = data; + int ret; - /* enable clock first since there is register access */ - pm_runtime_get_sync(f->dev); + { + /* enable clock first since there is register access */ + PM_RUNTIME_ACQUIRE(f->dev, pm); - /* disable the hardware */ - fspi_writel(f, FSPI_MCR0_MDIS, f->iobase + FSPI_MCR0); + ret = PM_RUNTIME_ACQUIRE_ERR(&pm); + if (ret < 0) { + dev_warn(f->dev, "Failed to enable clock for cleanup: %d\n", ret); + } else { + /* disable the hardware */ + fspi_writel(f, FSPI_MCR0_MDIS, f->iobase + FSPI_MCR0); + } + } - pm_runtime_put_noidle(f->dev); nxp_fspi_clk_disable_unprep(f); if (f->ahb_addr) -- 2.34.1