Re: [PATCH 2/2] drm/amd/display: add cursor pitch check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020-12-02 4:09 p.m., Simon Ser wrote:
Replace the width check with a pitch check, which matches DM internals.
Add a new check to make sure the pitch (in pixels) matches the width.

Signed-off-by: Simon Ser <contact@xxxxxxxxxxx>
Cc: Alex Deucher <alexander.deucher@xxxxxxx>
Cc: Harry Wentland <hwentlan@xxxxxxx>
Cc: Nicholas Kazlauskas <nicholas.kazlauskas@xxxxxxx>

Series is:

Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@xxxxxxx>

Regards,
Nicholas Kazlauskas

---
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 +++++++++++++++----
  1 file changed, 15 insertions(+), 4 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 9e328101187e..862a59703060 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -8988,6 +8988,7 @@ static int dm_update_plane_state(struct dc *dc,
  	struct amdgpu_crtc *new_acrtc;
  	bool needs_reset;
  	int ret = 0;
+	unsigned int pitch;
new_plane_crtc = new_plane_state->crtc;
@@ -9021,15 +9022,25 @@ static int dm_update_plane_state(struct dc *dc,
  				return -EINVAL;
  			}
- switch (new_plane_state->fb->width) {
+			/* Pitch in pixels */
+			pitch = new_plane_state->fb->pitches[0] / new_plane_state->fb->format->cpp[0];
+
+			if (new_plane_state->fb->width != pitch) {
+				DRM_DEBUG_ATOMIC("Cursor FB width %d doesn't match pitch %d",
+						 new_plane_state->fb->width,
+						 pitch);
+				return -EINVAL;
+			}
+
+			switch (pitch) {
  			case 64:
  			case 128:
  			case 256:
-				/* FB width is supported by cursor plane */
+				/* FB pitch is supported by cursor plane */
  				break;
  			default:
-				DRM_DEBUG_ATOMIC("Bad cursor FB width %d\n",
-						 new_plane_state->fb->width);
+				DRM_DEBUG_ATOMIC("Bad cursor FB pitch %d px\n",
+						 pitch);
  				return -EINVAL;
  			}
  		}


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



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux