]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/ast: Call drm_atomic_helper_check_plane_state() unconditionally
authorThomas Zimmermann <tzimmermann@suse.de>
Thu, 13 Oct 2022 11:29:17 +0000 (13:29 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Sun, 16 Oct 2022 09:15:45 +0000 (11:15 +0200)
Always call drm_atomic_helper_check_plane_state() in each plane's
atomic_check function. At the minimum, it needs to set or clear the
plane state's 'visible' field. Otherwise the plane-state handling
is bogus and would keep updating planes that have been disabled.

While at it, also warn if the primary plane has been enabled, but is
not visible. This cannot legally happen as the plane always covers
the entire screen.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Tested-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221013112923.769-3-tzimmermann@suse.de
drivers/gpu/drm/ast/ast_mode.c

index e1e07928906e7a366c5da74f6f2699b606eeb198..e26471ecffb1de9e44a3d27eed77ac075e5514e1 100644 (file)
@@ -578,27 +578,28 @@ static const uint32_t ast_primary_plane_formats[] = {
 static int ast_primary_plane_helper_atomic_check(struct drm_plane *plane,
                                                 struct drm_atomic_state *state)
 {
+       struct drm_device *dev = plane->dev;
        struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
                                                                                 plane);
-       struct drm_crtc_state *crtc_state;
+       struct drm_crtc_state *crtc_state = NULL;
        struct ast_crtc_state *ast_crtc_state;
        int ret;
 
-       if (!new_plane_state->crtc)
-               return 0;
-
-       crtc_state = drm_atomic_get_new_crtc_state(state,
-                                                  new_plane_state->crtc);
+       if (new_plane_state->crtc)
+               crtc_state = drm_atomic_get_new_crtc_state(state, new_plane_state->crtc);
 
        ret = drm_atomic_helper_check_plane_state(new_plane_state, crtc_state,
                                                  DRM_PLANE_NO_SCALING,
                                                  DRM_PLANE_NO_SCALING,
                                                  false, true);
-       if (ret)
+       if (ret) {
                return ret;
-
-       if (!new_plane_state->visible)
-               return 0;
+       } else if (!new_plane_state->visible) {
+               if (drm_WARN_ON(dev, new_plane_state->crtc)) /* cannot legally happen */
+                       return -EINVAL;
+               else
+                       return 0;
+       }
 
        ast_crtc_state = to_ast_crtc_state(crtc_state);
 
@@ -805,25 +806,19 @@ static int ast_cursor_plane_helper_atomic_check(struct drm_plane *plane,
        struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
                                                                                 plane);
        struct drm_framebuffer *fb = new_plane_state->fb;
-       struct drm_crtc_state *crtc_state;
+       struct drm_crtc_state *crtc_state = NULL;
        int ret;
 
-       if (!new_plane_state->crtc)
-               return 0;
-
-       crtc_state = drm_atomic_get_new_crtc_state(state,
-                                                  new_plane_state->crtc);
+       if (new_plane_state->crtc)
+               crtc_state = drm_atomic_get_new_crtc_state(state, new_plane_state->crtc);
 
        ret = drm_atomic_helper_check_plane_state(new_plane_state, crtc_state,
                                                  DRM_PLANE_NO_SCALING,
                                                  DRM_PLANE_NO_SCALING,
                                                  true, true);
-       if (ret)
+       if (ret || !new_plane_state->visible)
                return ret;
 
-       if (!new_plane_state->visible)
-               return 0;
-
        if (fb->width > AST_MAX_HWC_WIDTH || fb->height > AST_MAX_HWC_HEIGHT)
                return -EINVAL;