All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 2/3] drm/i915: Assert that the request->tail fits within the ring
Date: Mon, 27 Mar 2017 16:57:13 +0300	[thread overview]
Message-ID: <87wpbax1om.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20170327130009.4678-2-chris@chris-wilson.co.uk>

Chris Wilson <chris@chris-wilson.co.uk> writes:

> In addition to being qword-aligned, the RING_TAIL offset must be within
> the ring!
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com>

> ---
>  drivers/gpu/drm/i915/intel_lrc.c        | 4 ++++
>  drivers/gpu/drm/i915/intel_ringbuffer.c | 3 +++
>  2 files changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
> index 32fb8ad3fd36..39cb84a5d4e4 100644
> --- a/drivers/gpu/drm/i915/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> @@ -327,6 +327,7 @@ static u64 execlists_update_context(struct drm_i915_gem_request *rq)
>  	u32 *reg_state = ce->lrc_reg_state;
>  
>  	GEM_BUG_ON(!IS_ALIGNED(rq->tail, 8));
> +	GEM_BUG_ON(rq->tail >= rq->ring->size);
>  	reg_state[CTX_RING_TAIL+1] = rq->tail;
>  
>  	/* True 32b PPGTT with dynamic page allocation: update PDP
> @@ -1282,6 +1283,7 @@ static void reset_common_ring(struct intel_engine_cs *engine,
>  		intel_ring_wrap(request->ring,
>  				request->wa_tail - WA_TAIL_DWORDS*sizeof(u32));
>  	GEM_BUG_ON(!IS_ALIGNED(request->tail, 8));
> +	GEM_BUG_ON(request->tail >= request->ring->size);
>  }
>  
>  static int intel_logical_ring_emit_pdps(struct drm_i915_gem_request *req)
> @@ -1493,6 +1495,7 @@ static void gen8_emit_breadcrumb(struct drm_i915_gem_request *request, u32 *cs)
>  	*cs++ = MI_NOOP;
>  	request->tail = intel_ring_offset(request, cs);
>  	GEM_BUG_ON(!IS_ALIGNED(request->tail, 8));
> +	GEM_BUG_ON(request->tail >= request->ring->size);
>  
>  	gen8_emit_wa_tail(request, cs);
>  }
> @@ -1521,6 +1524,7 @@ static void gen8_emit_breadcrumb_render(struct drm_i915_gem_request *request,
>  	*cs++ = MI_NOOP;
>  	request->tail = intel_ring_offset(request, cs);
>  	GEM_BUG_ON(!IS_ALIGNED(request->tail, 8));
> +	GEM_BUG_ON(request->tail >= request->ring->size);
>  
>  	gen8_emit_wa_tail(request, cs);
>  }
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
> index 4729ac7ac122..47921dcbedb3 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
> @@ -775,6 +775,7 @@ static void i9xx_submit_request(struct drm_i915_gem_request *request)
>  	i915_gem_request_submit(request);
>  
>  	GEM_BUG_ON(!IS_ALIGNED(request->tail, 8));
> +	GEM_BUG_ON(request->tail >= request->ring->size);
>  	I915_WRITE_TAIL(request->engine, request->tail);
>  }
>  
> @@ -787,6 +788,7 @@ static void i9xx_emit_breadcrumb(struct drm_i915_gem_request *req, u32 *cs)
>  
>  	req->tail = intel_ring_offset(req, cs);
>  	GEM_BUG_ON(!IS_ALIGNED(req->tail, 8));
> +	GEM_BUG_ON(req->tail >= req->ring->size);
>  }
>  
>  static const int i9xx_emit_breadcrumb_sz = 4;
> @@ -826,6 +828,7 @@ static void gen8_render_emit_breadcrumb(struct drm_i915_gem_request *req,
>  
>  	req->tail = intel_ring_offset(req, cs);
>  	GEM_BUG_ON(!IS_ALIGNED(req->tail, 8));
> +	GEM_BUG_ON(req->tail >= req->ring->size);
>  }
>  
>  static const int gen8_render_emit_breadcrumb_sz = 8;
> -- 
> 2.11.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-03-27 13:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-27 13:00 [PATCH v2 1/3] drm/i915/execlists: Wrap tail pointer after reset tweaking Chris Wilson
2017-03-27 13:00 ` [PATCH v2 2/3] drm/i915: Assert that the request->tail fits within the ring Chris Wilson
2017-03-27 13:57   ` Mika Kuoppala [this message]
2017-03-27 13:00 ` [PATCH v2 3/3] drm/i915: Refactor tests for validity of RING_TAIL Chris Wilson
2017-03-27 13:14   ` [PATCH v3] " Chris Wilson
2017-03-27 13:57     ` Mika Kuoppala
2017-03-27 13:05 ` [PATCH v2 1/3] drm/i915/execlists: Wrap tail pointer after reset tweaking Mika Kuoppala
2017-03-27 13:05   ` Mika Kuoppala
2017-03-27 14:11 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/3] drm/i915/execlists: Wrap tail pointer after reset tweaking (rev2) Patchwork
2017-03-27 14:20   ` Chris Wilson

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=87wpbax1om.fsf@gaia.fi.intel.com \
    --to=mika.kuoppala@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.