drm/vc4: hdmi: Put the device on error in pre_crtc_configure
authorMaxime Ripard <maxime@cerno.tech>
Tue, 29 Jun 2021 09:36:38 +0000 (11:36 +0200)
committerPhil Elwell <8911409+pelwell@users.noreply.github.com>
Fri, 2 Jul 2021 15:45:04 +0000 (16:45 +0100)
In the vc4_hdmi_encoder_pre_crtc_configure() function error path we
never actually call pm_runtime_put() even though
pm_runtime_resume_and_get() is our very first call.

Fixes: 4f6e3d66ac52 ("drm/vc4: Add runtime PM support to the HDMI encoder driver")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
drivers/gpu/drm/vc4/vc4_hdmi.c

index 0833cbf..a64cfb7 100644 (file)
@@ -917,6 +917,7 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,
        ret = pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev);
        if (ret) {
                DRM_ERROR("Failed to retain power domain: %d\n", ret);
+               pm_runtime_put(&vc4_hdmi->pdev->dev);
                return;
        }
 
@@ -924,12 +925,14 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,
        ret = clk_set_rate(vc4_hdmi->pixel_clock, pixel_rate);
        if (ret) {
                DRM_ERROR("Failed to set pixel clock rate: %d\n", ret);
+               pm_runtime_put(&vc4_hdmi->pdev->dev);
                return;
        }
 
        ret = clk_prepare_enable(vc4_hdmi->pixel_clock);
        if (ret) {
                DRM_ERROR("Failed to turn on pixel clock: %d\n", ret);
+               pm_runtime_put(&vc4_hdmi->pdev->dev);
                return;
        }
 
@@ -937,6 +940,7 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,
        vc4_hdmi->hsm_req = clk_request_start(vc4_hdmi->hsm_clock, hsm_rate);
        if (IS_ERR(vc4_hdmi->hsm_req)) {
                DRM_ERROR("Failed to set HSM clock rate: %ld\n", PTR_ERR(vc4_hdmi->hsm_req));
+               pm_runtime_put(&vc4_hdmi->pdev->dev);
                return;
        }
 
@@ -955,6 +959,7 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,
                DRM_ERROR("Failed to set pixel bvb clock rate: %ld\n", PTR_ERR(vc4_hdmi->bvb_req));
                clk_request_done(vc4_hdmi->hsm_req);
                clk_disable_unprepare(vc4_hdmi->pixel_clock);
+               pm_runtime_put(&vc4_hdmi->pdev->dev);
                return;
        }
 
@@ -965,6 +970,7 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,
                        clk_request_done(vc4_hdmi->bvb_req);
                clk_request_done(vc4_hdmi->hsm_req);
                clk_disable_unprepare(vc4_hdmi->pixel_clock);
+               pm_runtime_put(&vc4_hdmi->pdev->dev);
                return;
        }