Skip to content

Commit

Permalink
drm/ast: Call drm_atomic_helper_check_plane_state() unconditionally
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Thomas Zimmermann committed Oct 16, 2022
1 parent 1fe1821 commit 0432a50
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions drivers/gpu/drm/ast/ast_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 0432a50

Please sign in to comment.