sti_gdp_atomic_check() reparents the GDP pixel clock and calls
clk_set_rate() on it with the clock of the mode being checked.
.atomic_check() must not touch the hardware. A commit with
DRM_MODE_ATOMIC_TEST_ONLY only runs the check hooks, and a commit that
fails a later check is dropped, so in both cases the clock of a mode
that was never applied is programmed on a display that is still scanning
out the previous one.
Move the clock setup to .atomic_update(), where the rest of the plane is
programmed. A clk_set_rate() failure can no longer reject the commit,
so it is logged and the plane is left as it was.
Fixes: dd86dc2f9ae1 ("drm/sti: implement atomic_check for the planes")
Signed-off-by: Minseo Park <[email protected]>
---
drivers/gpu/drm/sti/sti_gdp.c | 52 +++++++++++++++++------------------
1 file changed, 25 insertions(+), 27 deletions(-)
diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
index d0c886029c57..09f8d3f936ca 100644
--- a/drivers/gpu/drm/sti/sti_gdp.c
+++ b/drivers/gpu/drm/sti/sti_gdp.c
@@ -623,7 +623,6 @@ static int sti_gdp_atomic_check(struct drm_plane *drm_plane,
struct drm_plane_state *new_plane_state =
drm_atomic_get_new_plane_state(state,
drm_plane);
struct sti_plane *plane = to_sti_plane(drm_plane);
- struct sti_gdp *gdp = to_sti_gdp(plane);
struct drm_crtc *crtc = new_plane_state->crtc;
struct drm_framebuffer *fb = new_plane_state->fb;
struct drm_crtc_state *crtc_state;
@@ -667,32 +666,6 @@ static int sti_gdp_atomic_check(struct drm_plane
*drm_plane,
return -EINVAL;
}
- /* Set gdp clock */
- if (mode->clock && gdp->clk_pix) {
- struct clk *clkp;
- int rate = mode->clock * 1000;
- int res;
-
- /*
- * According to the mixer used, the gdp pixel clock
- * should have a different parent clock.
- */
- if (mixer->id == STI_MIXER_MAIN)
- clkp = gdp->clk_main_parent;
- else
- clkp = gdp->clk_aux_parent;
-
- if (clkp)
- clk_set_parent(gdp->clk_pix, clkp);
-
- res = clk_set_rate(gdp->clk_pix, rate);
- if (res < 0) {
- DRM_ERROR("Cannot set rate (%dHz) for gdp\n",
- rate);
- return -EINVAL;
- }
- }
-
DRM_DEBUG_KMS("CRTC:%d (%s) drm plane:%d (%s)\n",
crtc->base.id, sti_mixer_to_str(mixer),
drm_plane->base.id, sti_plane_to_str(plane));
@@ -757,6 +730,31 @@ static void sti_gdp_atomic_update(struct drm_plane
*drm_plane,
}
mode = &crtc->mode;
+
+ /* Set gdp clock */
+ if (mode->clock && gdp->clk_pix) {
+ struct sti_mixer *mixer = to_sti_mixer(crtc);
+ int rate = mode->clock * 1000;
+ struct clk *clkp;
+
+ /*
+ * According to the mixer used, the gdp pixel clock
+ * should have a different parent clock.
+ */
+ if (mixer->id == STI_MIXER_MAIN)
+ clkp = gdp->clk_main_parent;
+ else
+ clkp = gdp->clk_aux_parent;
+
+ if (clkp)
+ clk_set_parent(gdp->clk_pix, clkp);
+
+ if (clk_set_rate(gdp->clk_pix, rate) < 0) {
+ DRM_ERROR("Cannot set rate (%dHz) for gdp\n", rate);
+ return;
+ }
+ }
+
dst_x = newstate->crtc_x;
dst_y = newstate->crtc_y;
dst_w = clamp_val(newstate->crtc_w, 0, mode->hdisplay - dst_x);
--
2.43.0