[PATCH 1/4] drm/amd/display: add cursor FB size check

Alex Deucher alexdeucher at gmail.com
Fri Nov 20 20:50:57 UTC 2020


On Fri, Nov 20, 2020 at 3:19 PM Simon Ser <contact at emersion.fr> wrote:
>
> This patch expands the cursor checks added in "drm/amd/display: add basic
> atomic check for cursor plane" to also include a FB size check. Without
> this patch, setting a FB smaller than max_cursor_size with an invalid
> width would result in amdgpu error messages and a fallback to a 64-byte
> width:
>
>     [drm:hubp1_cursor_set_attributes [amdgpu]] *ERROR* Invalid cursor pitch of 100. Only 64/128/256 is supported on DCN.
>
> Note that DC uses the word "pitch" when actually checking the FB width.
> Indeed, the function handle_cursor_update does this:
>
>     attributes.pitch = attributes.width;
>
> In my tests, the cursor FB actually had a pitch of 512 bytes.
>
> Signed-off-by: Simon Ser <contact at emersion.fr>
> Reported-by: Pierre-Loup A. Griffais <pgriffais at valvesoftware.com>
> Cc: Alex Deucher <alexander.deucher at amd.com>
> Cc: Harry Wentland <hwentlan at amd.com>
> Cc: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
> ---
>  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 22 +++++++++++++++++++
>  1 file changed, 22 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 2855bb918535..bd63f1c4ae79 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -8902,6 +8902,28 @@ static int dm_update_plane_state(struct dc *dc,
>                         return -EINVAL;
>                 }
>
> +               if (new_plane_state->fb) {
> +                       if (new_plane_state->fb->width > new_acrtc->max_cursor_width ||
> +                           new_plane_state->fb->height > new_acrtc->max_cursor_height) {
> +                               DRM_DEBUG_ATOMIC("Bad cursor FB size %dx%d\n",
> +                                                new_plane_state->fb->width,
> +                                                new_plane_state->fb->height);
> +                               return -EINVAL;
> +                       }
> +
> +                       switch (new_plane_state->fb->width) {
> +                       case 64:
> +                       case 128:
> +                       case 256:
> +                               /* FB width is supported by cursor plane */

I'm pretty sure DCE6.x only supports 64 and DCE8-12 only supports 128.
I think only DCN supports 256.

Alex


> +                               break;
> +                       default:
> +                               DRM_DEBUG_ATOMIC("Bad cursor FB width %d\n",
> +                                                new_plane_state->fb->width);
> +                               return -EINVAL;
> +                       }
> +               }
> +
>                 return 0;
>         }
>
> --
> 2.29.2
>
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


More information about the amd-gfx mailing list