On 2020-12-03 3:19 p.m., Simon Ser wrote:
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.

The GFX8- check is inspired from ac_surface_set_bo_metadata in Mesa.
The GFX9+ check comes from convert_tiling_flags_to_modifier.

Signed-off-by: Simon Ser <cont...@emersion.fr>
References: https://gitlab.freedesktop.org/drm/amd/-/issues/1390
Cc: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl>
Cc: Alex Deucher <alexander.deuc...@amd.com>
Cc: Harry Wentland <hwent...@amd.com>
Cc: Nicholas Kazlauskas <nicholas.kazlaus...@amd.com>
---

Looks good to me, series is:

Reviewed-by: Nicholas Kazlauskas <nicholas.kazlaus...@amd.com>

Regards,
Nicholas Kazlauskas

  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 +++++++++++++++++++
  1 file changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 070bb55ec4e1..b46b188588b4 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -8978,7 +8978,10 @@ 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;
+       bool linear;
if (fb->width > new_acrtc->max_cursor_width ||
            fb->height > new_acrtc->max_cursor_height) {
@@ -9013,6 +9016,22 @@ 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)) {
+               if (adev->family < AMDGPU_FAMILY_AI) {
+                       linear = AMDGPU_TILING_GET(afb->tiling_flags, ARRAY_MODE) != 
DC_ARRAY_2D_TILED_THIN1 &&
+                                AMDGPU_TILING_GET(afb->tiling_flags, ARRAY_MODE) != 
DC_ARRAY_1D_TILED_THIN1 &&
+                                AMDGPU_TILING_GET(afb->tiling_flags, 
MICRO_TILE_MODE) == 0;
+               } else {
+                       linear = AMDGPU_TILING_GET(afb->tiling_flags, 
SWIZZLE_MODE) == 0;
+               }
+               if (!linear) {
+                       DRM_DEBUG_ATOMIC("Cursor FB not linear");
+                       return -EINVAL;
+               }
+       }
+
        return 0;
  }

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to