From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/2] drm/i915: Move the modulus for ring emission to the register write
Date: Thu, 28 Jul 2016 12:59:52 +0300 [thread overview]
Message-ID: <1469699992.3897.48.camel@linux.intel.com> (raw)
In-Reply-To: <1469697366-27175-2-git-send-email-chris@chris-wilson.co.uk>
On to, 2016-07-28 at 10:16 +0100, Chris Wilson wrote:
> Space reservation is already safe with respect to the ring->size
> modulus, but hardware only expects to see values in the range
> 0...ring->size-1 (inclusive) and so requires the modulus to prevent us
> writing the value ring->size instead of 0. As this is only required for
> the register itself, we can defer the modulus to the register update and
> not perform it after every command packet. We keep the
> intel_ring_advance() around in the code to provide demarcation for the
> end-of-packet (with then can be compared against intel_ring_begin() as
> the number of dwords emitted must match the reserved space).
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Dave Gordon <david.s.gordon@intel.com>
LGTM,
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> ---
> drivers/gpu/drm/i915/intel_lrc.c | 2 +-
> drivers/gpu/drm/i915/intel_ringbuffer.c | 6 ++++--
> drivers/gpu/drm/i915/intel_ringbuffer.h | 17 +++++++++++++----
> 3 files changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
> index bf42a66d6624..824f7efe4e64 100644
> --- a/drivers/gpu/drm/i915/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> @@ -373,7 +373,7 @@ static void execlists_update_context(struct drm_i915_gem_request *rq)
> struct i915_hw_ppgtt *ppgtt = rq->ctx->ppgtt;
> uint32_t *reg_state = rq->ctx->engine[engine->id].lrc_reg_state;
>
> - reg_state[CTX_RING_TAIL+1] = rq->tail;
> + reg_state[CTX_RING_TAIL+1] = intel_ring_offset(rq->ring, rq->tail);
>
> /* True 32b PPGTT with dynamic page allocation: update PDP
> * registers and point the unallocated PDPs to scratch page.
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
> index 3142085b5cc0..21d5e8209400 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
> @@ -1718,7 +1718,8 @@ static void i9xx_submit_request(struct drm_i915_gem_request *request)
> {
> struct drm_i915_private *dev_priv = request->i915;
>
> - I915_WRITE_TAIL(request->engine, request->tail);
> + I915_WRITE_TAIL(request->engine,
> + intel_ring_offset(request->ring, request->tail));
> }
>
> static void
> @@ -2505,7 +2506,8 @@ static void gen6_bsd_submit_request(struct drm_i915_gem_request *request)
> DRM_ERROR("timed out waiting for the BSD ring to wake up\n");
>
> /* Now that the ring is fully powered up, update the tail */
> - I915_WRITE_FW(RING_TAIL(request->engine->mmio_base), request->tail);
> + I915_WRITE_FW(RING_TAIL(request->engine->mmio_base),
> + intel_ring_offset(request->ring, request->tail));
> POSTING_READ_FW(RING_TAIL(request->engine->mmio_base));
>
> /* Let the ring send IDLE messages to the GT again,
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
> index 14d2ea36fb88..198b541f9b22 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.h
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
> @@ -460,14 +460,23 @@ static inline void intel_ring_emit_reg(struct intel_ring *ring, i915_reg_t reg)
>
> static inline void intel_ring_advance(struct intel_ring *ring)
> {
> + /* Dummy function.
> + *
> + * This serves as a placeholder in the code so that the reader
> + * can compare against the preceeding intel_ring_begin() and
> + * check that the number of dwords emitted matches the space
> + * reserved for the command packet (i.e. the value passed to
> + * intel_ring_begin()).
> + */
> +}
> +
> +static inline u32 intel_ring_offset(struct intel_ring *ring, u32 value)
> +{
> /* The modulus is required so that we avoid writing
> * request->tail == ring->size, rather than the expected 0,
> * into the RING_TAIL register as that can cause a GPU hang.
> - * As this is only strictly required for the request->tail,
> - * and only then as we write the value into hardware, we can
> - * one day remove the modulus after every command packet.
> */
> - ring->tail &= ring->size - 1;
> + return value & (ring->size - 1);
> }
>
> int __intel_ring_space(int head, int tail, int size);
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-07-28 9:59 UTC|newest]
Thread overview: 94+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-25 7:44 Refined set of intel_ringbuffer renames Chris Wilson
2016-07-25 7:44 ` [PATCH 01/31] drm/i915: Reduce breadcrumb lock coverage for intel_engine_enable_signaling() Chris Wilson
2016-07-26 4:37 ` Joonas Lahtinen
2016-07-25 7:44 ` [PATCH 02/31] drm/i915: Prefer list_first_entry_or_null Chris Wilson
2016-07-25 7:55 ` Joonas Lahtinen
2016-07-25 8:03 ` Chris Wilson
2016-07-25 10:01 ` Joonas Lahtinen
2016-07-25 7:44 ` [PATCH 03/31] drm/i915: Only clear the client pointer when tearing down the file Chris Wilson
2016-07-25 8:15 ` Joonas Lahtinen
2016-07-25 7:44 ` [PATCH 04/31] drm/i915: Only drop the batch-pool's object reference Chris Wilson
2016-07-25 8:38 ` Joonas Lahtinen
2016-07-25 8:44 ` Chris Wilson
2016-07-25 10:43 ` Joonas Lahtinen
2016-07-25 7:44 ` [PATCH 05/31] drm/i915/cmdparser: Remove stray intel_engine_cs *ring Chris Wilson
2016-07-25 8:40 ` Joonas Lahtinen
2016-07-25 9:06 ` [PATCH v2] " Chris Wilson
2016-07-25 11:01 ` Joonas Lahtinen
2016-07-25 11:12 ` Chris Wilson
2016-07-25 7:44 ` [PATCH 06/31] drm/i915: Use engine to refer to the user's BSD intel_engine_cs Chris Wilson
2016-07-25 8:42 ` Joonas Lahtinen
2016-07-25 7:44 ` [PATCH 07/31] drm/i915: Avoid using intel_engine_cs *ring for GPU error capture Chris Wilson
2016-07-25 7:44 ` [PATCH 08/31] drm/i915: Remove stray intel_engine_cs ring identifiers from i915_gem.c Chris Wilson
2016-07-25 8:45 ` Joonas Lahtinen
2016-07-25 8:49 ` Chris Wilson
2016-07-26 15:12 ` Dave Gordon
2016-07-25 7:44 ` [PATCH 09/31] drm/i915: Update a couple of hangcheck comments to talk about engines Chris Wilson
2016-07-25 8:46 ` Joonas Lahtinen
2016-07-25 7:44 ` [PATCH 10/31] drm/i915: Unify intel_logical_ring_emit and intel_ring_emit Chris Wilson
2016-07-25 7:44 ` [PATCH 11/31] drm/i915: Rename request->ringbuf to request->ring Chris Wilson
2016-07-25 7:44 ` [PATCH 12/31] drm/i915: Rename backpointer from intel_ringbuffer to intel_engine_cs Chris Wilson
2016-07-25 8:49 ` Joonas Lahtinen
2016-07-25 9:10 ` Chris Wilson
2016-07-25 7:44 ` [PATCH 13/31] drm/i915: Rename intel_context[engine].ringbuf Chris Wilson
2016-07-25 7:44 ` [PATCH 14/31] drm/i915: Rename struct intel_ringbuffer to struct intel_ring Chris Wilson
2016-07-25 7:44 ` [PATCH 15/31] drm/i915: Rename residual ringbuf parameters Chris Wilson
2016-07-25 8:58 ` Joonas Lahtinen
2016-07-25 7:44 ` [PATCH 16/31] drm/i915: Rename intel_pin_and_map_ring() Chris Wilson
2016-07-25 7:44 ` [PATCH 17/31] drm/i915: Remove obsolete engine->gpu_caches_dirty Chris Wilson
2016-07-25 9:14 ` Joonas Lahtinen
2016-07-25 9:24 ` Chris Wilson
2016-07-27 9:49 ` Dave Gordon
2016-07-27 10:00 ` Chris Wilson
2016-07-27 11:18 ` Dave Gordon
2016-07-27 11:26 ` Joonas Lahtinen
2016-07-27 10:53 ` [PATCH] drm/i915: Reduce engine->emit_flush() to a single mode parameter Chris Wilson
2016-07-28 7:11 ` Joonas Lahtinen
2016-07-28 8:37 ` Chris Wilson
2016-07-28 10:03 ` Joonas Lahtinen
2016-07-28 14:57 ` Dave Gordon
2016-07-25 7:44 ` [PATCH 18/31] drm/i915: Simplify request_alloc by returning the allocated request Chris Wilson
2016-07-25 9:18 ` Joonas Lahtinen
2016-07-27 11:08 ` Dave Gordon
2016-07-27 15:28 ` Chris Wilson
2016-07-28 12:48 ` Dave Gordon
2016-07-28 15:10 ` Chris Wilson
2016-07-28 15:20 ` Dave Gordon
2016-07-25 7:44 ` [PATCH 19/31] drm/i915: Unify legacy/execlists emission of MI_BATCHBUFFER_START Chris Wilson
2016-07-25 7:44 ` [PATCH 20/31] drm/i915: Remove intel_ring_get_tail() Chris Wilson
2016-07-25 9:43 ` Joonas Lahtinen
2016-07-25 7:44 ` [PATCH 21/31] drm/i915: Convert engine->write_tail to operate on a request Chris Wilson
2016-07-27 11:53 ` Dave Gordon
2016-07-27 12:29 ` Chris Wilson
2016-07-28 15:05 ` Dave Gordon
2016-07-28 15:09 ` Chris Wilson
2016-07-27 12:30 ` Chris Wilson
2016-07-28 6:41 ` Joonas Lahtinen
2016-07-28 7:12 ` Chris Wilson
2016-07-28 7:52 ` Joonas Lahtinen
2016-07-28 9:16 ` [PATCH 1/2] " Chris Wilson
2016-07-28 9:16 ` [PATCH 2/2] drm/i915: Move the modulus for ring emission to the register write Chris Wilson
2016-07-28 9:59 ` Joonas Lahtinen [this message]
2016-07-28 15:16 ` Dave Gordon
2016-07-25 7:44 ` [PATCH 22/31] drm/i915: Unify request submission Chris Wilson
2016-07-25 9:49 ` Joonas Lahtinen
2016-07-25 7:44 ` [PATCH 23/31] drm/i915/lrc: Update function names to match request flow Chris Wilson
2016-07-25 9:50 ` Joonas Lahtinen
2016-07-25 7:44 ` [PATCH 24/31] drm/i915: Stop passing caller's num_dwords to engine->semaphore.signal() Chris Wilson
2016-07-25 9:53 ` Joonas Lahtinen
2016-07-25 7:44 ` [PATCH 25/31] drm/i915: Reuse legacy breadcrumbs + tail emission Chris Wilson
2016-07-28 15:23 ` Dave Gordon
2016-07-28 15:29 ` Chris Wilson
2016-07-28 15:33 ` Dave Gordon
2016-07-25 7:44 ` [PATCH 26/31] drm/i915/ringbuffer: Specialise SNB+ request emission for semaphores Chris Wilson
2016-07-25 9:55 ` Joonas Lahtinen
2016-07-25 7:44 ` [PATCH 27/31] drm/i915: Remove duplicate golden render state init from execlists Chris Wilson
2016-07-25 7:44 ` [PATCH 28/31] drm/i915: Refactor golden render state emission to unconfuse gcc Chris Wilson
2016-07-25 9:59 ` Joonas Lahtinen
2016-07-25 7:44 ` [PATCH 29/31] drm/i915: Unify legacy/execlists submit_execbuf callbacks Chris Wilson
2016-07-25 7:44 ` [PATCH 30/31] drm/i915: Simplify calling engine->sync_to Chris Wilson
2016-07-25 7:44 ` [PATCH 31/31] drm/i915: Rename engine->semaphore.sync_to, engine->sempahore.signal locals Chris Wilson
2016-07-25 8:28 ` ✓ Ro.CI.BAT: success for series starting with [01/31] drm/i915: Reduce breadcrumb lock coverage for intel_engine_enable_signaling() Patchwork
2016-07-25 9:32 ` ✓ Ro.CI.BAT: success for series starting with [01/31] drm/i915: Reduce breadcrumb lock coverage for intel_engine_enable_signaling() (rev2) Patchwork
2016-07-27 11:00 ` ✗ Ro.CI.BAT: failure for series starting with [01/31] drm/i915: Reduce breadcrumb lock coverage for intel_engine_enable_signaling() (rev3) Patchwork
2016-07-28 9:20 ` ✗ Ro.CI.BAT: failure for series starting with [01/31] drm/i915: Reduce breadcrumb lock coverage for intel_engine_enable_signaling() (rev5) Patchwork
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=1469699992.3897.48.camel@linux.intel.com \
--to=joonas.lahtinen@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