devm_pm_runtime_enable() can fail after it has already rolled runtime PM
back to the disabled state. __dw_mipi_dsi2_probe() ignored that error and
could publish a MIPI DSI host whose mode-setting path then issues
pm_runtime_get_sync() calls against a runtime-PM-disabled device.

Propagate the setup error before registering the host.
Leave runtime PM cleanup to devres if host registration then fails, so
runtime PM is not disabled twice.

Fixes: 0d6d86253fef ("drm/bridge/synopsys: Add MIPI DSI2 host controller 
bridge")
Signed-off-by: Jiawen Liu <[email protected]>
---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c 
b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c
index eb7d5713bd285..6ac2ed9378580 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c
@@ -973,14 +973,16 @@ __dw_mipi_dsi2_probe(struct platform_device *pdev,
                clk_disable_unprepare(dsi2->pclk);
        }
 
-       devm_pm_runtime_enable(dev);
+       ret = devm_pm_runtime_enable(dev);
+       if (ret)
+               return dev_err_ptr_probe(dev, ret,
+                                        "Failed to enable runtime PM\n");
 
        dsi2->dsi_host.ops = &dw_mipi_dsi2_host_ops;
        dsi2->dsi_host.dev = dev;
        ret = mipi_dsi_host_register(&dsi2->dsi_host);
        if (ret) {
                dev_err(dev, "Failed to register MIPI host: %d\n", ret);
-               pm_runtime_disable(dev);
                return ERR_PTR(ret);
        }
 
-- 
2.34.1

Reply via email to