From d34082ef4a697777ea48ca01c030b0b960dcc20d Mon Sep 17 00:00:00 2001 From: Clark Wang <xiaoning.wang@nxp.com> Date: Thu, 15 Jul 2021 18:55:58 +0800 Subject: [PATCH] LF-4174 i2c: imx-lpi2c: fix runtime pm issue when defer probe occurs When the defer probe occurs, the pm_runtime_put() used before may cause runtime pm to be disabled before clks of device truly closed. So use pm_runtime_put_sync() in the error path to suspend it immediately and put pm_runtime_disable() to the last. Signed-off-by: Clark Wang <xiaoning.wang@nxp.com> Reviewed-by: Jun Li <jun.li@nxp.com> Reviewed-by: Haibo Chen <haibo.chen@nxp.com> --- drivers/i2c/busses/i2c-imx-lpi2c.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index 466d8300972fb..9b24ff253dfe8 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -952,8 +952,6 @@ static int lpi2c_imx_probe(struct platform_device *pdev) lpi2c_imx->txfifosize = 1 << (temp & 0x0f); lpi2c_imx->rxfifosize = 1 << ((temp >> 8) & 0x0f); - pm_runtime_put(&pdev->dev); - /* Init optional bus recovery function */ ret = lpi2c_imx_init_recovery_info(lpi2c_imx, pdev); /* Give it another chance if pinctrl used is not ready yet */ @@ -976,13 +974,17 @@ static int lpi2c_imx_probe(struct platform_device *pdev) if (ret) goto rpm_disable; + pm_runtime_mark_last_busy(&pdev->dev); + pm_runtime_put_autosuspend(&pdev->dev); + dev_info(&lpi2c_imx->adapter.dev, "LPI2C adapter registered\n"); return 0; rpm_disable: - pm_runtime_disable(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); + pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); return ret; } -- GitLab