[Intel-gfx] [PATCH] drm/i915: Reject < 1x1 pixel plane source size

Ville Syrjala ville.syrjala at linux.intel.com
Thu Jan 12 15:21:45 UTC 2023


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

We don't have proper sub-pixel coordinate support (some platforms
simply can't do it, for others we've not implemented it). This
can cause us to treat a < 1 pixel source width/height as zero
which is not valid for the hardware, and can also cause a div
by zero in some cases.

Refuse < 1x1 plane source size to avoid these problems.

Cc: stable at vger.kernel.org
Cc: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
Reported-by: Drew Davenport <ddavenport at chromium.org>
Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
The other option would be to clamp the source size to >=1x1 pixels,
but dunno if that has any real benefits.

 drivers/gpu/drm/i915/display/intel_atomic_plane.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index 10e1fc9d0698..c6e43d684458 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -921,6 +921,21 @@ int intel_atomic_plane_check_clipping(struct intel_plane_state *plane_state,
 	 */
 	plane_state->uapi.visible = drm_rect_clip_scaled(src, dst, clip);
 
+	/*
+	 * Avoid zero source size when we later
+	 * discard the fractional coords.
+	 *
+	 * FIXME add proper sub-pixel coordinate handling
+	 * for platforms/planes that support it.
+	 */
+	if (plane_state->uapi.visible &&
+	    (drm_rect_width(src) < 0x10000 || drm_rect_height(src) < 0x10000)) {
+		drm_dbg_kms(&i915->drm, "Plane source must be at least 1x1 pixels\n");
+		drm_rect_debug_print("src: ", src, true);
+		drm_rect_debug_print("dst: ", dst, false);
+		return -EINVAL;
+	}
+
 	drm_rect_rotate_inv(src, fb->width << 16, fb->height << 16, rotation);
 
 	if (!can_position && plane_state->uapi.visible &&
-- 
2.38.2



More information about the Intel-gfx mailing list