Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH] drm/i915: Reject < 1x1 pixel plane source size
@ 2023-01-12 15:21 Ville Syrjala
  2023-01-12 16:56 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ville Syrjala @ 2023-01-12 15:21 UTC (permalink / raw)
  To: intel-gfx; +Cc: Drew Davenport, stable

From: Ville Syrjälä <ville.syrjala@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@vger.kernel.org
Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reported-by: Drew Davenport <ddavenport@chromium.org>
Signed-off-by: Ville Syrjälä <ville.syrjala@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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-13  5:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-12 15:21 [Intel-gfx] [PATCH] drm/i915: Reject < 1x1 pixel plane source size Ville Syrjala
2023-01-12 16:56 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
2023-01-12 18:29 ` [Intel-gfx] [PATCH] " Ville Syrjälä
2023-01-13  5:46 ` [Intel-gfx] ✓ Fi.CI.IGT: success for " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox