]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
drm/bridge: Add missing pm_runtime_put_sync
authorYongzhi Liu <lyz_cs@pku.edu.cn>
Mon, 24 Jan 2022 07:20:35 +0000 (23:20 -0800)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 12:40:35 +0000 (14:40 +0200)
BugLink: https://bugs.launchpad.net/bugs/1969107
[ Upstream commit 46f47807738441e354873546dde0b000106c068a ]

pm_runtime_get_sync() will increase the rumtime PM counter
even when it returns an error. Thus a pairing decrement is needed
to prevent refcount leak. Fix this by replacing this API with
pm_runtime_resume_and_get(), which will not change the runtime
PM counter on error. Besides, a matching decrement is needed
on the error handling path to keep the counter balanced.

Signed-off-by: Yongzhi Liu <lyz_cs@pku.edu.cn>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Robert Foss <robert.foss@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1643008835-73961-1-git-send-email-lyz_cs@pku.edu.cn
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit ff13c90d7f7ab606b37be6d15140d19013d6736c)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/gpu/drm/bridge/nwl-dsi.c

index 6e484d836cfe2f6f2a2427ef1803c0817d29197e..691039aba87f44f59101882cb1aedd5337291677 100644 (file)
@@ -861,18 +861,19 @@ nwl_dsi_bridge_mode_set(struct drm_bridge *bridge,
        memcpy(&dsi->mode, adjusted_mode, sizeof(dsi->mode));
        drm_mode_debug_printmodeline(adjusted_mode);
 
-       pm_runtime_get_sync(dev);
+       if (pm_runtime_resume_and_get(dev) < 0)
+               return;
 
        if (clk_prepare_enable(dsi->lcdif_clk) < 0)
-               return;
+               goto runtime_put;
        if (clk_prepare_enable(dsi->core_clk) < 0)
-               return;
+               goto runtime_put;
 
        /* Step 1 from DSI reset-out instructions */
        ret = reset_control_deassert(dsi->rst_pclk);
        if (ret < 0) {
                DRM_DEV_ERROR(dev, "Failed to deassert PCLK: %d\n", ret);
-               return;
+               goto runtime_put;
        }
 
        /* Step 2 from DSI reset-out instructions */
@@ -882,13 +883,18 @@ nwl_dsi_bridge_mode_set(struct drm_bridge *bridge,
        ret = reset_control_deassert(dsi->rst_esc);
        if (ret < 0) {
                DRM_DEV_ERROR(dev, "Failed to deassert ESC: %d\n", ret);
-               return;
+               goto runtime_put;
        }
        ret = reset_control_deassert(dsi->rst_byte);
        if (ret < 0) {
                DRM_DEV_ERROR(dev, "Failed to deassert BYTE: %d\n", ret);
-               return;
+               goto runtime_put;
        }
+
+       return;
+
+runtime_put:
+       pm_runtime_put_sync(dev);
 }
 
 static void