~emersion/linux

1ee16c7f7882863b69df0bacbdda9e53931bda52 — Simon Ser 2 years ago dff6979
drm/amd/display: check cursor FB is linear on GFX8

Previously we accepted non-linear buffers for the cursor plane. This
results in bad output, DC validation failures and oops.

Make sure the FB uses a linear layout in the atomic check function.

Signed-off-by: Simon Ser <contact@emersion.fr>
References: https://gitlab.freedesktop.org/drm/amd/-/issues/1390
Cc: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Harry Wentland <hwentlan@amd.com>
Cc: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
1 files changed, 14 insertions(+), 0 deletions(-)

M drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
M drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c => drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +14 -0
@@ 8978,6 8978,8 @@ static int dm_check_cursor_fb(struct amdgpu_crtc *new_acrtc,
			      struct drm_plane_state *new_plane_state,
			      struct drm_framebuffer *fb)
{
	struct amdgpu_device *adev = drm_to_adev(new_acrtc->base.dev);
	struct amdgpu_framebuffer *afb = to_amdgpu_framebuffer(fb);
	unsigned int pitch;

	if (fb->width > new_acrtc->max_cursor_width ||


@@ 9013,6 9015,18 @@ static int dm_check_cursor_fb(struct amdgpu_crtc *new_acrtc,
		return -EINVAL;
	}

	/* Core DRM takes care of checking FB modifiers, so we only need to
	 * check tiling flags when the FB doesn't have a modifier. */
	if (!(fb->flags & DRM_MODE_FB_MODIFIERS)) {
		/* Modifiers should always be set for GFX9+ */
		BUG_ON(adev->family >= AMDGPU_FAMILY_AI);
		if (AMDGPU_TILING_GET(afb->tiling_flags, ARRAY_MODE) != 0 ||
		    AMDGPU_TILING_GET(afb->tiling_flags, MICRO_TILE_MODE) != 0) {
			DRM_DEBUG_ATOMIC("Cursor FB not linear");
			return -EINVAL;
		}
	}

	return 0;
}