[Intel-gfx] [PATCH 01/10] drm/i915: Check the minimum pitch for the user framebuffer

Rodrigo Vivi rodrigo.vivi at intel.com
Tue Nov 4 13:51:39 CET 2014


From: Chris Wilson <chris at chris-wilson.co.uk>

Compute the smallest pitch required for a linear framebuffer and assert
that the user has declared a pitch that meets that minimum requirement.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 7d891e5..0b1e193 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -12414,6 +12414,8 @@ static int intel_framebuffer_init(struct drm_device *dev,
 {
 	int aligned_height;
 	int pitch_limit;
+	int depth;
+	int bpp;
 	int ret;
 
 	WARN_ON(!mutex_is_locked(&dev->struct_mutex));
@@ -12429,6 +12431,15 @@ static int intel_framebuffer_init(struct drm_device *dev,
 		return -EINVAL;
 	}
 
+	drm_fb_get_bpp_depth(mode_cmd->pixel_format, &bpp, &depth);
+	if (mode_cmd->pitches[0] < intel_framebuffer_pitch_for_width(mode_cmd->width,
+								     bpp)) {
+		DRM_DEBUG("pitch (%d) must be at least the linear stride (%d)\n",
+			  mode_cmd->pitches[0],
+			  intel_framebuffer_pitch_for_width(mode_cmd->width, bpp));
+		return -EINVAL;
+	}
+
 	if (INTEL_INFO(dev)->gen >= 5 && !IS_VALLEYVIEW(dev)) {
 		pitch_limit = 32*1024;
 	} else if (INTEL_INFO(dev)->gen >= 4) {
-- 
1.9.3




More information about the Intel-gfx mailing list