intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: Detect invalid scanout pitches
Date: Thu, 20 Jun 2013 11:17:16 +0300	[thread overview]
Message-ID: <20130620081716.GH5004@intel.com> (raw)
In-Reply-To: <1371657034-9189-1-git-send-email-chris@chris-wilson.co.uk>

On Wed, Jun 19, 2013 at 04:50:34PM +0100, Chris Wilson wrote:
> Report back the user error of attempting to setup a CRTC with an invalid
> framebuffer pitch. This is trickier than it should be as on gen4, there
> is a restriction that tiled surfaces must have a stride less than 16k -
> which is less than the largest supported CRTC size.
> 
> v2: Fix the limits for gen3
> 
> References: https://bugs.freedesktop.org/show_bug.cgi?id=65099
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 39e7b1b..68cab9f 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -1871,6 +1871,7 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,
>  	struct drm_i915_gem_object *obj;
>  	int plane = intel_crtc->plane;
>  	unsigned long linear_offset;
> +	int pitch_limit;
>  	u32 dspcntr;
>  	u32 reg;
>  
> @@ -1886,6 +1887,27 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,
>  	intel_fb = to_intel_framebuffer(fb);
>  	obj = intel_fb->obj;
>  
> +	if (IS_VLV(dev)) {

That won't compile.

> +		pitch_limit = 32*1024;
> +	} else if (IS_GEN4(dev)) {
> +		if (obj->tiling_mode)
> +			pitch_limit = 16*1024;
> +		else
> +			pitch_limit = 32*1024;
> +	} else if (IS_GEN3(dev)) {
> +		if (obj->tiling_mode)
> +			pitch_limit = 8*1024;
> +		else
> +			pitch_limit = 16*1024;
> +	} else
> +		pitch_limit = 8*1024;
> +
> +
> +	if (fb->pitches[0] > pitch_limit) {
> +		DRM_DEBUG_KMS("Invalid pitch (%d) for scanout\n", fb->pitches[0]);
> +		return -EINVAL;
> +	}

We already have a bit of pitch checking in intel_framebuffer_init().
In fact there's a FIXME about pre-ilk limits there.

Assuming all the planes on a specific piece of hardware have the same
pitch limits, I'd like the checks to be live in
intel_framebuffer_init() so that the issue gets caught as early as
possible. For stricter per-plane limits we obviously need the checks
in update_plane.

What I can gather from BSpec is this:
gen2: linear/tiled 8k, (maybe DSPC tiled max 4k?)
gen3: linear ?, tiled 8k
gen4: linear ?, tiled 16k
ctg: linear ?, tiled 16k
ilk+: 32k all the way

Looking at your patch you have 16k,32k,32k for the ?s in my list.
Otherwise your numbers seem to agree with my findings.

So, to me it looks like all the planes do share the same limits (DSPC on
gen2 might be a minor exception), so I think we could move all of these
checks to intel_framebuffer_init().

> +
>  	reg = DSPCNTR(plane);
>  	dspcntr = I915_READ(reg);
>  	/* Mask out pixel format bits in case we change it */
> @@ -1983,6 +2005,11 @@ static int ironlake_update_plane(struct drm_crtc *crtc,
>  		return -EINVAL;
>  	}
>  
> +	if (fb->pitches[0] > 32*1024) {
> +		DRM_DEBUG_KMS("Invalid pitch (%d) for scanout\n", fb->pitches[0]);
> +		return -EINVAL;
> +	}
> +
>  	intel_fb = to_intel_framebuffer(fb);
>  	obj = intel_fb->obj;
>  
> -- 
> 1.8.3.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC

  reply	other threads:[~2013-06-20  8:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-19 15:20 [PATCH] drm/i915: Detect invalid scanout pitches Chris Wilson
2013-06-19 15:50 ` Chris Wilson
2013-06-20  8:17   ` Ville Syrjälä [this message]
2013-06-20  9:14     ` Chris Wilson
2013-06-20 10:29       ` Ville Syrjälä
2013-06-20 12:27         ` Chris Wilson
2013-06-20 12:44           ` Ville Syrjälä
2013-06-20 13:54             ` Chris Wilson
2013-06-20 10:34       ` Ville Syrjälä
  -- strict thread matches above, loose matches on Subject: below --
2013-06-20 16:14 Chris Wilson
2013-06-24 15:05 ` Ville Syrjälä
2013-06-25 16:26   ` Chris Wilson
2013-06-25 16:29     ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130620081716.GH5004@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).