drm/msm/dpu: move layout setup population out of dpu_plane_prepare_fb()
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Tue, 3 Sep 2024 03:22:55 +0000 (06:22 +0300)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Mon, 21 Oct 2024 11:11:12 +0000 (14:11 +0300)
Move the call to dpu_format_populate_plane_sizes() to the atomic_check
step, so that any issues with the FB layout can be reported as early as
possible.

At the same time move the call to dpu_format_populate_addrs() to
dpu_plane_sspp_atomic_update(). This way the all layout management is
performed only for the visible planes: the .prepare_fb callback is
called for not visible planes too, so keeping dpu_format_populate_addrs
in dpu_plane_prepare_fb() will require dpu_format_populate_plane_sizes()
to be called for !visible planes too.

Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/612251/
Link: https://lore.kernel.org/r/20240903-dpu-mode-config-width-v6-12-617e1ecc4b7a@linaro.org
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c

index df95377b98fca33f69a8a2e2548a8cc6483e9618..3045bda8a7b7e5b58793bb66b276c8b0f11bd3de 100644 (file)
@@ -675,19 +675,6 @@ static int dpu_plane_prepare_fb(struct drm_plane *plane,
                }
        }
 
-       ret = dpu_format_populate_plane_sizes(new_state->fb, &pstate->layout);
-       if (ret) {
-               DPU_ERROR_PLANE(pdpu, "failed to get format plane sizes, %d\n", ret);
-               if (pstate->aspace)
-                       msm_framebuffer_cleanup(new_state->fb, pstate->aspace,
-                                               pstate->needs_dirtyfb);
-               return ret;
-       }
-
-       dpu_format_populate_addrs(pstate->aspace,
-                                 new_state->fb,
-                                 &pstate->layout);
-
        return 0;
 }
 
@@ -863,6 +850,12 @@ static int dpu_plane_atomic_check(struct drm_plane *plane,
                return -E2BIG;
        }
 
+       ret = dpu_format_populate_plane_sizes(new_plane_state->fb, &pstate->layout);
+       if (ret) {
+               DPU_ERROR_PLANE(pdpu, "failed to get format plane sizes, %d\n", ret);
+               return ret;
+       }
+
        fmt = msm_framebuffer_format(new_plane_state->fb);
 
        max_linewidth = pdpu->catalog->caps->max_linewidth;
@@ -1102,7 +1095,8 @@ static void dpu_plane_sspp_update_pipe(struct drm_plane *plane,
                _dpu_plane_set_qos_remap(plane, pipe);
 }
 
-static void dpu_plane_sspp_atomic_update(struct drm_plane *plane)
+static void dpu_plane_sspp_atomic_update(struct drm_plane *plane,
+                                        struct drm_plane_state *new_state)
 {
        struct dpu_plane *pdpu = to_dpu_plane(plane);
        struct drm_plane_state *state = plane->state;
@@ -1123,6 +1117,8 @@ static void dpu_plane_sspp_atomic_update(struct drm_plane *plane)
        pstate->needs_qos_remap |= (is_rt_pipe != pdpu->is_rt_pipe);
        pdpu->is_rt_pipe = is_rt_pipe;
 
+       dpu_format_populate_addrs(pstate->aspace, new_state->fb, &pstate->layout);
+
        DPU_DEBUG_PLANE(pdpu, "FB[%u] " DRM_RECT_FP_FMT "->crtc%u " DRM_RECT_FMT
                        ", %p4cc ubwc %d\n", fb->base.id, DRM_RECT_FP_ARG(&state->src),
                        crtc->base.id, DRM_RECT_ARG(&state->dst),
@@ -1187,7 +1183,7 @@ static void dpu_plane_atomic_update(struct drm_plane *plane,
        if (!new_state->visible) {
                _dpu_plane_atomic_disable(plane);
        } else {
-               dpu_plane_sspp_atomic_update(plane);
+               dpu_plane_sspp_atomic_update(plane, new_state);
        }
 }