All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/i915: Acquire uncore.lock over intel_uncore_wait_for_register()
Date: Mon, 10 Apr 2017 18:03:43 +0200	[thread overview]
Message-ID: <20170410160343.GE208996@mwajdecz-MOBL1.ger.corp.intel.com> (raw)
In-Reply-To: <20170410155531.25369-1-chris@chris-wilson.co.uk>

On Mon, Apr 10, 2017 at 04:55:31PM +0100, Chris Wilson wrote:
> We acquire the forcewake and use I915_READ_FW instead for the atomic
> wait within intel_uncore_wait_for_register. However, this still leaves
> us vulnerable to concurrent mmio access to the register, which can cause
> system hangs on gen7. The protection is to acquire uncore.lock around
> each register, so lets add it back.
> 
> v2: Wrap __intel_wait_for_register_fw() to re-use its atomic wait_for
> loop and spare adding another for ourselves.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_uncore.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
> index 53c8457869f6..01cea3b7a704 100644
> --- a/drivers/gpu/drm/i915/intel_uncore.c
> +++ b/drivers/gpu/drm/i915/intel_uncore.c
> @@ -1661,14 +1661,20 @@ int intel_wait_for_register(struct drm_i915_private *dev_priv,
>  			    u32 value,
>  			    unsigned int timeout_ms)
>  {
> -
>  	unsigned fw =
>  		intel_uncore_forcewake_for_reg(dev_priv, reg, FW_REG_READ);
>  	int ret;
>  
> -	intel_uncore_forcewake_get(dev_priv, fw);
> -	ret = wait_for_us((I915_READ_FW(reg) & mask) == value, 2);
> -	intel_uncore_forcewake_put(dev_priv, fw);
> +	spin_lock_irq(&dev_priv->uncore.lock);
> +	intel_uncore_forcewake_get__locked(dev_priv, fw);
> +
> +	ret = __intel_wait_for_register_fw(dev_priv,
> +					   reg, mask, value,
> +					   2, 0, NULL);
> +
> +	intel_uncore_forcewake_put__locked(dev_priv, fw);
> +	spin_unlock_irq(&dev_priv->uncore.lock);

Hmm, shouldn't we use spin_lock_irqsave/spin_unlock_irqrestore here?
Like in GEN6_READ_HEADER/GEN6_READ_FOOTER.

-Michal

> +
>  	if (ret)
>  		ret = wait_for((I915_READ_NOTRACE(reg) & mask) == value,
>  			       timeout_ms);
> -- 
> 2.11.0
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-04-10 16:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-10 15:02 [PATCH 1/3] drm/i915: Stop second guessing the caller for intel_uncore_wait_for_register() Chris Wilson
2017-04-10 15:02 ` [PATCH 2/3] drm/i915: Stop sleeping from inside gen6_bsd_submit_request() Chris Wilson
2017-04-10 15:23   ` Michal Wajdeczko
2017-04-10 15:31     ` Chris Wilson
2017-04-10 15:02 ` [PATCH 3/3] drm/i915: Acquire uncore.lock over intel_uncore_wait_for_register() Chris Wilson
2017-04-10 15:26   ` Michal Wajdeczko
2017-04-10 15:55     ` [PATCH v2] " Chris Wilson
2017-04-10 16:03       ` Michal Wajdeczko [this message]
2017-04-10 15:20 ` [PATCH 1/3] drm/i915: Stop second guessing the caller for intel_uncore_wait_for_register() Michal Wajdeczko
2017-04-10 15:25   ` Chris Wilson
2017-04-10 15:24 ` ✓ Fi.CI.BAT: success for series starting with [1/3] " Patchwork
2017-04-10 16:23 ` ✗ Fi.CI.BAT: warning for series starting with [1/3] drm/i915: Stop second guessing the caller for intel_uncore_wait_for_register() (rev2) Patchwork
2017-04-11  8:39   ` 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=20170410160343.GE208996@mwajdecz-MOBL1.ger.corp.intel.com \
    --to=michal.wajdeczko@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.