All of lore.kernel.org
 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: Empty the ring before disabling
Date: Fri, 27 Oct 2017 14:27:59 +0300	[thread overview]
Message-ID: <20171027112759.GZ10981@intel.com> (raw)
In-Reply-To: <20171026235639.5281-1-chris@chris-wilson.co.uk>

On Fri, Oct 27, 2017 at 12:56:39AM +0100, Chris Wilson wrote:
> An interesting snippet from Sandybridge's prm:
> 
> "Although a Ring Buffer can be enabled in the non-empty state, it must
> not be disabled unless it is empty. Attempting to disable a Ring Buffer
> in the non-empty state is UNDEFINED."

However elsewhere it still says:
"Writing the Head Offset while the RB is enabled is UNDEFINED"
and
"It can be enabled or disabled regardless of whether there
 are valid instructions pending."

And gen2/3 bspec says this:
"Ring buffers can be disabled with valid instructions pending.
When disabled, the ring buffer will be removed from command 
stream arbitration at the next arbitration point (i.e.,
instruction boundary)."

> 
> Let's avoid the undefined behaviour as we disable the rings prior to
> reset and resume.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_ringbuffer.c | 4 +++-
>  drivers/gpu/drm/i915/intel_uncore.c     | 4 +++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
> index 05e01446b00b..3f2073a9d37a 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
> @@ -480,10 +480,12 @@ static bool stop_ring(struct intel_engine_cs *engine)
>  		}
>  	}
>  
> -	I915_WRITE_CTL(engine, 0);
>  	I915_WRITE_HEAD(engine, 0);
>  	I915_WRITE_TAIL(engine, 0);
>  
> +	/* The ring must be empty before it is disabled */
> +	I915_WRITE_CTL(engine, 0);
> +
>  	return (I915_READ_HEAD(engine) & HEAD_ADDR) == 0;
>  }
>  
> diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
> index 20e3c65c0999..ac688ee6fe4e 100644
> --- a/drivers/gpu/drm/i915/intel_uncore.c
> +++ b/drivers/gpu/drm/i915/intel_uncore.c
> @@ -1387,10 +1387,12 @@ static void gen3_stop_engine(struct intel_engine_cs *engine)
>  		DRM_DEBUG_DRIVER("%s: timed out on STOP_RING\n",
>  				 engine->name);
>  
> -	I915_WRITE_FW(RING_CTL(base), 0);
>  	I915_WRITE_FW(RING_HEAD(base), 0);
>  	I915_WRITE_FW(RING_TAIL(base), 0);
>  
> +	/* The ring must be empty before it is disabled */
> +	I915_WRITE_FW(RING_CTL(base), 0);
> +
>  	/* Check acts as a post */
>  	if (I915_READ_FW(RING_HEAD(base)) != 0)
>  		DRM_DEBUG_DRIVER("%s: ring head not parked\n",
> -- 
> 2.15.0.rc2
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-10-27 11:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-26 23:56 [PATCH] drm/i915: Empty the ring before disabling Chris Wilson
2017-10-27  0:35 ` ✗ Fi.CI.BAT: failure for " Patchwork
2017-10-27  6:44 ` [PATCH] " Mika Kuoppala
2017-10-27  9:18   ` Chris Wilson
2017-10-27 11:27 ` Ville Syrjälä [this message]
2017-10-27 11:35   ` 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=20171027112759.GZ10981@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 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.