diff options
author | Simon Ser <contact@emersion.fr> | 2020-11-20 20:18:55 +0000 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2020-11-24 12:09:52 -0500 |
commit | 24f99d2b21db3be1da2800470fecfa583a181929 (patch) | |
tree | d69df40783de7fe77339276d60d639d6469791d8 /drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | |
parent | 7fe466153e5618716f06d09b1b3e1af309dcf0be (diff) | |
download | lwn-24f99d2b21db3be1da2800470fecfa583a181929.tar.gz lwn-24f99d2b21db3be1da2800470fecfa583a181929.zip |
drm/amd/display: add cursor FB size check
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.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Simon Ser <contact@emersion.fr>
Reported-by: Pierre-Loup A. Griffais <pgriffais@valvesoftware.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Harry Wentland <hwentlan@amd.com>
Cc: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c')
-rw-r--r-- | drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 22 |
1 files changed, 22 insertions, 0 deletions
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 63d9bfaa113b..c7322d3e0b0a 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -8982,6 +8982,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 */ + break; + default: + DRM_DEBUG_ATOMIC("Bad cursor FB width %d\n", + new_plane_state->fb->width); + return -EINVAL; + } + } + return 0; } |