public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Check the minimum pitch for the user framebuffer
@ 2014-06-10 21:22 Chris Wilson
  2014-06-11 10:27 ` Daniel Vetter
  2014-06-11 10:45 ` Ville Syrjälä
  0 siblings, 2 replies; 5+ messages in thread
From: Chris Wilson @ 2014-06-10 21:22 UTC (permalink / raw)
  To: intel-gfx

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@chris-wilson.co.uk>
---
 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 cc62b140eb1c..ef34badbe69c 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -11808,6 +11808,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));
@@ -11823,6 +11825,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) {
-- 
2.0.0

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

* Re: [PATCH] drm/i915: Check the minimum pitch for the user framebuffer
  2014-06-10 21:22 [PATCH] drm/i915: Check the minimum pitch for the user framebuffer Chris Wilson
@ 2014-06-11 10:27 ` Daniel Vetter
  2014-06-11 10:45 ` Ville Syrjälä
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Vetter @ 2014-06-11 10:27 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

On Tue, Jun 10, 2014 at 10:22:33PM +0100, Chris Wilson wrote:
> 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@chris-wilson.co.uk>
> ---
>  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 cc62b140eb1c..ef34badbe69c 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -11808,6 +11808,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));
> @@ -11823,6 +11825,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)) {

Won't this foul up universal planes? Iirc we have a minimal pitch of 128b
somewhere, but cursors are happy with 64. Also not sure about
overlays/planes.

If this blows up I guess we need to patch up the setplane/cursor functions
correctly.
-Daniel

> +		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) {
> -- 
> 2.0.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

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

* Re: [PATCH] drm/i915: Check the minimum pitch for the user framebuffer
  2014-06-10 21:22 [PATCH] drm/i915: Check the minimum pitch for the user framebuffer Chris Wilson
  2014-06-11 10:27 ` Daniel Vetter
@ 2014-06-11 10:45 ` Ville Syrjälä
  1 sibling, 0 replies; 5+ messages in thread
From: Ville Syrjälä @ 2014-06-11 10:45 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

On Tue, Jun 10, 2014 at 10:22:33PM +0100, Chris Wilson wrote:
> 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@chris-wilson.co.uk>
> ---
>  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 cc62b140eb1c..ef34badbe69c 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -11808,6 +11808,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));
> @@ -11823,6 +11825,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;
> +	}

How come framebuffer_check() in drm_crtc.c didn't catch this?

> +
>  	if (INTEL_INFO(dev)->gen >= 5 && !IS_VALLEYVIEW(dev)) {
>  		pitch_limit = 32*1024;
>  	} else if (INTEL_INFO(dev)->gen >= 4) {
> -- 
> 2.0.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC

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

* [PATCH] drm/i915: Check the minimum pitch for the user framebuffer
  2014-06-11 11:40 [PATCH] drm/i915: Make the physical object coherent with GTT Ville Syrjälä
@ 2014-06-11 11:55 ` Chris Wilson
  2014-06-11 12:00   ` Chris Wilson
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Wilson @ 2014-06-11 11:55 UTC (permalink / raw)
  To: intel-gfx

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@chris-wilson.co.uk>
---
 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 fb6ca714af44..f6b67289d819 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -11809,6 +11809,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));
@@ -11824,6 +11826,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) {
-- 
2.0.0

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

* Re: [PATCH] drm/i915: Check the minimum pitch for the user framebuffer
  2014-06-11 11:55 ` [PATCH] drm/i915: Check the minimum pitch for the user framebuffer Chris Wilson
@ 2014-06-11 12:00   ` Chris Wilson
  0 siblings, 0 replies; 5+ messages in thread
From: Chris Wilson @ 2014-06-11 12:00 UTC (permalink / raw)
  To: intel-gfx

On Wed, Jun 11, 2014 at 12:55:38PM +0100, Chris Wilson wrote:
> Compute the smallest pitch required for a linear framebuffer and assert
> that the user has declared a pitch that meets that minimum requirement.

Wrong patch!
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

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

end of thread, other threads:[~2014-06-11 12:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-10 21:22 [PATCH] drm/i915: Check the minimum pitch for the user framebuffer Chris Wilson
2014-06-11 10:27 ` Daniel Vetter
2014-06-11 10:45 ` Ville Syrjälä
  -- strict thread matches above, loose matches on Subject: below --
2014-06-11 11:40 [PATCH] drm/i915: Make the physical object coherent with GTT Ville Syrjälä
2014-06-11 11:55 ` [PATCH] drm/i915: Check the minimum pitch for the user framebuffer Chris Wilson
2014-06-11 12:00   ` Chris Wilson

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