lkml.org 
[lkml]   [2022]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.15 093/846] drm/vc4: hdmi: Rework the pre_crtc_configure error handling
    Date
    From: Maxime Ripard <maxime@cerno.tech>

    [ Upstream commit caa51a4c11f1cadba9bcf61ed9e0105711952ce7 ]

    Since our pre_crtc_configure hook returned void, we didn't implement a
    goto-based error path handling, leading to errors like failing to put
    back the device in pm_runtime in all the error paths, but also failing
    to disable the pixel clock if clk_set_min_rate on the HSM clock fails.

    Move to a goto-based implementation to have an easier consitency.

    Fixes: 4f6e3d66ac52 ("drm/vc4: Add runtime PM support to the HDMI encoder driver")
    Link: https://patchwork.freedesktop.org/patch/msgid/20210819135931.895976-4-maxime@cerno.tech
    Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
    Signed-off-by: Maxime Ripard <maxime@cerno.tech>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/gpu/drm/vc4/vc4_hdmi.c | 20 ++++++++++++++------
    1 file changed, 14 insertions(+), 6 deletions(-)

    diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
    index 2087717f1cce9..49944644a9b36 100644
    --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
    +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
    @@ -933,15 +933,16 @@ 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);
    - return;
    + goto err_put_runtime_pm;
    }

    ret = clk_prepare_enable(vc4_hdmi->pixel_clock);
    if (ret) {
    DRM_ERROR("Failed to turn on pixel clock: %d\n", ret);
    - return;
    + goto err_put_runtime_pm;
    }

    +
    vc4_hdmi_cec_update_clk_div(vc4_hdmi);

    if (pixel_rate > 297000000)
    @@ -954,15 +955,13 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,
    ret = clk_set_min_rate(vc4_hdmi->pixel_bvb_clock, bvb_rate);
    if (ret) {
    DRM_ERROR("Failed to set pixel bvb clock rate: %d\n", ret);
    - clk_disable_unprepare(vc4_hdmi->pixel_clock);
    - return;
    + goto err_disable_pixel_clock;
    }

    ret = clk_prepare_enable(vc4_hdmi->pixel_bvb_clock);
    if (ret) {
    DRM_ERROR("Failed to turn on pixel bvb clock: %d\n", ret);
    - clk_disable_unprepare(vc4_hdmi->pixel_clock);
    - return;
    + goto err_disable_pixel_clock;
    }

    if (vc4_hdmi->variant->phy_init)
    @@ -975,6 +974,15 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,

    if (vc4_hdmi->variant->set_timings)
    vc4_hdmi->variant->set_timings(vc4_hdmi, conn_state, mode);
    +
    + return;
    +
    +err_disable_pixel_clock:
    + clk_disable_unprepare(vc4_hdmi->pixel_clock);
    +err_put_runtime_pm:
    + pm_runtime_put(&vc4_hdmi->pdev->dev);
    +
    + return;
    }

    static void vc4_hdmi_encoder_pre_crtc_enable(struct drm_encoder *encoder,
    --
    2.34.1


    \
     
     \ /
      Last update: 2022-01-24 23:11    [W:2.468 / U:0.496 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site