Skip to content

Commit caa51a4

Browse files
committed
drm/vc4: hdmi: Rework the pre_crtc_configure error handling
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: 4f6e3d6 ("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>
1 parent 9c6e4f6 commit caa51a4

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

drivers/gpu/drm/vc4/vc4_hdmi.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -933,15 +933,16 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,
933933
ret = clk_set_rate(vc4_hdmi->pixel_clock, pixel_rate);
934934
if (ret) {
935935
DRM_ERROR("Failed to set pixel clock rate: %d\n", ret);
936-
return;
936+
goto err_put_runtime_pm;
937937
}
938938

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

945+
945946
vc4_hdmi_cec_update_clk_div(vc4_hdmi);
946947

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

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

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

976975
if (vc4_hdmi->variant->set_timings)
977976
vc4_hdmi->variant->set_timings(vc4_hdmi, conn_state, mode);
977+
978+
return;
979+
980+
err_disable_pixel_clock:
981+
clk_disable_unprepare(vc4_hdmi->pixel_clock);
982+
err_put_runtime_pm:
983+
pm_runtime_put(&vc4_hdmi->pdev->dev);
984+
985+
return;
978986
}
979987

980988
static void vc4_hdmi_encoder_pre_crtc_enable(struct drm_encoder *encoder,

0 commit comments

Comments
 (0)