Intel-GFX Archive on 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 4/4] drm/i915: Provide an assert for when we expect forcewake to be held
Date: Mon, 09 Oct 2017 13:05:40 +0300	[thread overview]
Message-ID: <87y3okzle3.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20171009093256.13996-4-chris@chris-wilson.co.uk>

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

> Add assert_forcewakes_active() (the complementary function to
> assert_forcewakes_inactive) that documents the requirement of a
> function for its callers to be holding the forcewake ref (i.e. the
> function is part of a sequence over which RC6 must be prevented).
>
> One such example is during ringbuffer reset, where RC6 must be held
> across the whole reinitialisation sequence.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_ringbuffer.c | 11 ++++++++++-
>  drivers/gpu/drm/i915/intel_uncore.c     | 12 ++++++++++++
>  drivers/gpu/drm/i915/intel_uncore.h     |  2 ++
>  3 files changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
> index 05c08b0bc172..4285f09ff8b8 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
> @@ -579,7 +579,16 @@ static int init_ring_common(struct intel_engine_cs *engine)
>  static void reset_ring_common(struct intel_engine_cs *engine,
>  			      struct drm_i915_gem_request *request)
>  {
> -	/* Try to restore the logical GPU state to match the continuation
> +	/*
> +	 * RC6 must be prevented until the reset is complete and the engine
> +	 * reinitialised. If it occurs in the middle of this sequence, the
> +	 * state written to/loaded from the power context is ill-defined (e.g.
> +	 * the PP_BASE_DIR may be lost).
> +	 */
> +	assert_forcewakes_active(engine->i915, FORCEWAKE_ALL);
> +
> +	/*
> +	 * Try to restore the logical GPU state to match the continuation
>  	 * of the request queue. If we skip the context/PD restore, then
>  	 * the next request may try to execute assuming that its context
>  	 * is valid and loaded on the GPU and so may try to access invalid
> diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
> index b3c3f94fc7e4..3d41667919dc 100644
> --- a/drivers/gpu/drm/i915/intel_uncore.c
> +++ b/drivers/gpu/drm/i915/intel_uncore.c
> @@ -629,6 +629,18 @@ void assert_forcewakes_inactive(struct drm_i915_private *dev_priv)
>  	WARN_ON(dev_priv->uncore.fw_domains_active);
>  }
>  
> +void assert_forcewakes_active(struct drm_i915_private *dev_priv,
> +			      enum forcewake_domains fw_domains)
> +{
> +	if (!dev_priv->uncore.funcs.force_wake_get)
> +		return;
> +
> +	assert_rpm_wakelock_held(dev_priv);
> +
> +	fw_domains &= dev_priv->uncore.fw_domains;
> +	WARN_ON(fw_domains & ~dev_priv->uncore.fw_domains_active);
> +}
> +

Adding a debug telling about current domains seems not
to add any value...atleast yet.

I remember yearning after this in the past. 

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


>  /* We give fast paths for the really cool registers */
>  #define NEEDS_FORCE_WAKE(reg) ((reg) < 0x40000)
>  
> diff --git a/drivers/gpu/drm/i915/intel_uncore.h b/drivers/gpu/drm/i915/intel_uncore.h
> index 66eae2ce2f29..582771251b57 100644
> --- a/drivers/gpu/drm/i915/intel_uncore.h
> +++ b/drivers/gpu/drm/i915/intel_uncore.h
> @@ -137,6 +137,8 @@ void intel_uncore_resume_early(struct drm_i915_private *dev_priv);
>  
>  u64 intel_uncore_edram_size(struct drm_i915_private *dev_priv);
>  void assert_forcewakes_inactive(struct drm_i915_private *dev_priv);
> +void assert_forcewakes_active(struct drm_i915_private *dev_priv,
> +			      enum forcewake_domains fw_domains);
>  const char *intel_uncore_forcewake_domain_to_str(const enum forcewake_domain_id id);
>  
>  enum forcewake_domains
> -- 
> 2.14.2
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-10-09 10:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-09  9:32 [PATCH 1/4] drm/i915: Make i915_engine_info pretty printer to standalone Chris Wilson
2017-10-09  9:32 ` [PATCH 2/4] drm/i915/selftests: Pretty print engine state when requests fail to start Chris Wilson
2017-10-09  9:32 ` [PATCH 3/4] drm/i915/selftests: Hold the rpm/forcewake wakeref for the reset tests Chris Wilson
2017-10-09 10:14   ` Mika Kuoppala
2017-10-09 10:28     ` Chris Wilson
2017-10-09  9:32 ` [PATCH 4/4] drm/i915: Provide an assert for when we expect forcewake to be held Chris Wilson
2017-10-09 10:05   ` Mika Kuoppala [this message]
2017-10-09 10:14     ` Chris Wilson
2017-10-09 10:24   ` [PATCH v2] " Chris Wilson
2017-10-09 10:22 ` ✓ Fi.CI.BAT: success for series starting with [1/4] drm/i915: Make i915_engine_info pretty printer to standalone Patchwork
2017-10-09 12:01 ` ✗ Fi.CI.BAT: warning for series starting with [1/4] drm/i915: Make i915_engine_info pretty printer to standalone (rev2) 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=87y3okzle3.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox