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 10/21] drm/i915: Mark up all locked waiters
Date: Tue, 06 Sep 2016 12:24:10 +0300	[thread overview]
Message-ID: <87wpip8jph.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20160905130438.31046-11-chris@chris-wilson.co.uk>

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

> In the next patch we want to handle reset directly by a locked waiter in
> order to avoid issues with returning before the reset is handled. To
> handle the reset, we must first know whether we hold the struct_mutex.
> If we do not hold the struct_mtuex we can not perform the reset, but we do
> not block the reset worker either (and so we can just continue to wait for
> request completion) - otherwise we must relinquish the mutex.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

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

> ---
>  drivers/gpu/drm/i915/i915_debugfs.c      |  4 +++-
>  drivers/gpu/drm/i915/i915_gem.c          |  7 +++++--
>  drivers/gpu/drm/i915/i915_gem_evict.c    |  8 ++++++--
>  drivers/gpu/drm/i915/i915_gem_gtt.c      |  2 +-
>  drivers/gpu/drm/i915/i915_gem_request.c  | 15 ++++++++++++---
>  drivers/gpu/drm/i915/i915_gem_request.h  | 11 ++++++++---
>  drivers/gpu/drm/i915/i915_gem_shrinker.c |  2 +-
>  drivers/gpu/drm/i915/intel_ringbuffer.c  |  3 ++-
>  8 files changed, 38 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index f61d7d584f3f..8ea64aa0a282 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -4803,7 +4803,9 @@ i915_drop_caches_set(void *data, u64 val)
>  		return ret;
>  
>  	if (val & DROP_ACTIVE) {
> -		ret = i915_gem_wait_for_idle(dev_priv, I915_WAIT_INTERRUPTIBLE);
> +		ret = i915_gem_wait_for_idle(dev_priv,
> +					     I915_WAIT_INTERRUPTIBLE |
> +					     I915_WAIT_LOCKED);
>  		if (ret)
>  			goto unlock;
>  	}
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 4617250c3000..23069a2d2850 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -2802,7 +2802,8 @@ __i915_gem_object_sync(struct drm_i915_gem_request *to,
>  
>  	if (!i915.semaphores) {
>  		ret = i915_wait_request(from,
> -					from->i915->mm.interruptible,
> +					from->i915->mm.interruptible |
> +					I915_WAIT_LOCKED,
>  					NULL,
>  					NO_WAITBOOST);
>  		if (ret)
> @@ -4304,7 +4305,9 @@ int i915_gem_suspend(struct drm_device *dev)
>  	if (ret)
>  		goto err;
>  
> -	ret = i915_gem_wait_for_idle(dev_priv, I915_WAIT_INTERRUPTIBLE);
> +	ret = i915_gem_wait_for_idle(dev_priv,
> +				     I915_WAIT_INTERRUPTIBLE |
> +				     I915_WAIT_LOCKED);
>  	if (ret)
>  		goto err;
>  
> diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
> index 103085246975..5b6f81c1dbca 100644
> --- a/drivers/gpu/drm/i915/i915_gem_evict.c
> +++ b/drivers/gpu/drm/i915/i915_gem_evict.c
> @@ -170,7 +170,9 @@ search_again:
>  	if (ret)
>  		return ret;
>  
> -	ret = i915_gem_wait_for_idle(dev_priv, I915_WAIT_INTERRUPTIBLE);
> +	ret = i915_gem_wait_for_idle(dev_priv,
> +				     I915_WAIT_INTERRUPTIBLE |
> +				     I915_WAIT_LOCKED);
>  	if (ret)
>  		return ret;
>  
> @@ -275,7 +277,9 @@ int i915_gem_evict_vm(struct i915_address_space *vm, bool do_idle)
>  				return ret;
>  		}
>  
> -		ret = i915_gem_wait_for_idle(dev_priv, I915_WAIT_INTERRUPTIBLE);
> +		ret = i915_gem_wait_for_idle(dev_priv,
> +					     I915_WAIT_INTERRUPTIBLE |
> +					     I915_WAIT_LOCKED);
>  		if (ret)
>  			return ret;
>  
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 576a11454d18..904c5e3f1974 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -2680,7 +2680,7 @@ void i915_gem_gtt_finish_object(struct drm_i915_gem_object *obj)
>  	struct i915_ggtt *ggtt = &dev_priv->ggtt;
>  
>  	if (unlikely(ggtt->do_idle_maps)) {
> -		if (i915_gem_wait_for_idle(dev_priv, 0)) {
> +		if (i915_gem_wait_for_idle(dev_priv, I915_WAIT_LOCKED)) {
>  			DRM_ERROR("Failed to wait for idle; VT'd may hang.\n");
>  			/* Wait a bit, in hopes it avoids the hang */
>  			udelay(10);
> diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c
> index f4c15f319d08..f8589efec310 100644
> --- a/drivers/gpu/drm/i915/i915_gem_request.c
> +++ b/drivers/gpu/drm/i915/i915_gem_request.c
> @@ -260,7 +260,9 @@ static int i915_gem_init_seqno(struct drm_i915_private *dev_priv, u32 seqno)
>  
>  	/* Carefully retire all requests without writing to the rings */
>  	for_each_engine(engine, dev_priv) {
> -		ret = intel_engine_idle(engine, I915_WAIT_INTERRUPTIBLE);
> +		ret = intel_engine_idle(engine,
> +					I915_WAIT_INTERRUPTIBLE |
> +					I915_WAIT_LOCKED);
>  		if (ret)
>  			return ret;
>  	}
> @@ -625,6 +627,10 @@ int i915_wait_request(struct drm_i915_gem_request *req,
>  	int ret = 0;
>  
>  	might_sleep();
> +#if IS_ENABLED(CONFIG_LOCKDEP)
> +	GEM_BUG_ON(!!lockdep_is_held(&req->i915->drm.struct_mutex) !=
> +		   !!(flags & I915_WAIT_LOCKED));
> +#endif
>  
>  	if (i915_gem_request_completed(req))
>  		return 0;
> @@ -667,7 +673,8 @@ int i915_wait_request(struct drm_i915_gem_request *req,
>  		goto complete;
>  
>  	set_current_state(state);
> -	add_wait_queue(&req->i915->gpu_error.wait_queue, &reset);
> +	if (flags & I915_WAIT_LOCKED)
> +		add_wait_queue(&req->i915->gpu_error.wait_queue, &reset);
>  
>  	intel_wait_init(&wait, req->fence.seqno);
>  	if (intel_engine_add_wait(req->engine, &wait))
> @@ -707,7 +714,9 @@ wakeup:
>  		if (i915_spin_request(req, state, 2))
>  			break;
>  	}
> -	remove_wait_queue(&req->i915->gpu_error.wait_queue, &reset);
> +
> +	if (flags & I915_WAIT_LOCKED)
> +		remove_wait_queue(&req->i915->gpu_error.wait_queue, &reset);
>  
>  	intel_engine_remove_wait(req->engine, &wait);
>  	__set_current_state(TASK_RUNNING);
> diff --git a/drivers/gpu/drm/i915/i915_gem_request.h b/drivers/gpu/drm/i915/i915_gem_request.h
> index 479896ef791e..def35721e9ed 100644
> --- a/drivers/gpu/drm/i915/i915_gem_request.h
> +++ b/drivers/gpu/drm/i915/i915_gem_request.h
> @@ -222,7 +222,8 @@ int i915_wait_request(struct drm_i915_gem_request *req,
>  		      s64 *timeout,
>  		      struct intel_rps_client *rps)
>  	__attribute__((nonnull(1)));
> -#define I915_WAIT_INTERRUPTIBLE BIT(0)
> +#define I915_WAIT_INTERRUPTIBLE	BIT(0)
> +#define I915_WAIT_LOCKED	BIT(1) /* struct_mutex held, handle GPU reset */
>  
>  static inline u32 intel_engine_get_seqno(struct intel_engine_cs *engine);
>  
> @@ -576,7 +577,9 @@ i915_gem_active_wait(const struct i915_gem_active *active, struct mutex *mutex)
>  	if (!request)
>  		return 0;
>  
> -	return i915_wait_request(request, I915_WAIT_INTERRUPTIBLE, NULL, NULL);
> +	return i915_wait_request(request,
> +				 I915_WAIT_INTERRUPTIBLE | I915_WAIT_LOCKED,
> +				 NULL, NULL);
>  }
>  
>  /**
> @@ -639,7 +642,9 @@ i915_gem_active_retire(struct i915_gem_active *active,
>  	if (!request)
>  		return 0;
>  
> -	ret = i915_wait_request(request, I915_WAIT_INTERRUPTIBLE, NULL, NULL);
> +	ret = i915_wait_request(request,
> +				I915_WAIT_INTERRUPTIBLE | I915_WAIT_LOCKED,
> +				NULL, NULL);
>  	if (ret)
>  		return ret;
>  
> diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c
> index 35a05f4c51c1..1c237d02f30b 100644
> --- a/drivers/gpu/drm/i915/i915_gem_shrinker.c
> +++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c
> @@ -414,7 +414,7 @@ i915_gem_shrinker_vmap(struct notifier_block *nb, unsigned long event, void *ptr
>  		return NOTIFY_DONE;
>  
>  	/* Force everything onto the inactive lists */
> -	ret = i915_gem_wait_for_idle(dev_priv, 0);
> +	ret = i915_gem_wait_for_idle(dev_priv, I915_WAIT_LOCKED);
>  	if (ret)
>  		goto out;
>  
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
> index 9d76bf9cc78a..eae261e62b8b 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
> @@ -2223,7 +2223,8 @@ static int wait_for_space(struct drm_i915_gem_request *req, int bytes)
>  	if (WARN_ON(&target->ring_link == &ring->request_list))
>  		return -ENOSPC;
>  
> -	ret = i915_wait_request(target, I915_WAIT_INTERRUPTIBLE,
> +	ret = i915_wait_request(target,
> +				I915_WAIT_INTERRUPTIBLE | I915_WAIT_LOCKED,
>  				NULL, NO_WAITBOOST);
>  	if (ret)
>  		return ret;
> -- 
> 2.9.3
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2016-09-06  9:25 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-05 13:04 Non-blocking, explict fences Chris Wilson
2016-09-05 13:04 ` [PATCH 01/21] drm/i915: Add a sw fence for collecting up dma fences Chris Wilson
2016-09-05 13:04 ` [PATCH 02/21] drm/i915: Only queue requests during execlists submission Chris Wilson
2016-09-05 13:04 ` [PATCH 03/21] drm/i915: Record the position of the workarounds in the tail of the request Chris Wilson
2016-09-05 13:04 ` [PATCH 04/21] drm/i915: Compute the ELSP register location once Chris Wilson
2016-09-05 13:04 ` [PATCH 05/21] drm/i915: Reorder submitting the requests to ELSP Chris Wilson
2016-09-05 13:04 ` [PATCH 06/21] drm/i915: Simplify ELSP queue request tracking Chris Wilson
2016-09-05 13:04 ` [PATCH 07/21] drm/i915: Separate out reset flags from the reset counter Chris Wilson
2016-09-05 13:04 ` [PATCH 08/21] drm/i915: Drop local struct_mutex around intel_init_emon[ilk] Chris Wilson
2016-09-05 13:04 ` [PATCH 09/21] drm/i915: Expand bool interruptible to pass flags to i915_wait_request() Chris Wilson
2016-09-05 13:04 ` [PATCH 10/21] drm/i915: Mark up all locked waiters Chris Wilson
2016-09-06  9:24   ` Mika Kuoppala [this message]
2016-09-05 13:04 ` [PATCH 11/21] drm/i915: Perform a direct reset of the GPU from the waiter Chris Wilson
2016-09-05 13:04 ` [PATCH 12/21] drm/i915: Replace wait-on-mutex with wait-on-bit in reset worker Chris Wilson
2016-09-06  9:28   ` Mika Kuoppala
2016-09-05 13:04 ` [PATCH 13/21] drm/i915: Update reset path to fix incomplete requests Chris Wilson
2016-09-05 13:04 ` [PATCH 14/21] drm/i915: Drive request submission through fence callbacks Chris Wilson
2016-09-05 13:04 ` [PATCH 15/21] drm/i915: Reorder i915_add_request to separate the phases better Chris Wilson
2016-09-06  9:36   ` Mika Kuoppala
2016-09-05 13:04 ` [PATCH 16/21] drm/i915: Prepare object synchronisation for asynchronicity Chris Wilson
2016-09-05 13:04 ` [PATCH 17/21] drm/i915/guc: Prepare for nonblocking execbuf submission Chris Wilson
2016-09-05 13:04 ` [PATCH 18/21] drm/i915: Nonblocking request submission Chris Wilson
2016-09-05 13:04 ` [PATCH 19/21] drm/i915: Serialise execbuf operation after a dma-buf reservation object Chris Wilson
2016-09-05 13:04 ` [PATCH 20/21] drm/i915: Enable userspace to opt-out of implicit fencing Chris Wilson
2016-09-05 13:04 ` [PATCH 21/21] drm/i915: Support explicit fencing for execbuf Chris Wilson
2016-09-05 13:59 ` ✗ Fi.CI.BAT: failure for series starting with [01/21] drm/i915: Add a sw fence for collecting up dma fences Patchwork
2016-09-05 14:07   ` Chris Wilson
2016-09-07 14:44 ` [PATCH v2 01/22] " Chris Wilson
2016-09-07 14:44   ` [PATCH v2 02/22] drm/i915: Only queue requests during execlists submission Chris Wilson
2016-09-07 14:44   ` [PATCH v2 03/22] drm/i915: Record the position of the workarounds in the tail of the request Chris Wilson
2016-09-07 14:44   ` [PATCH v2 04/22] drm/i915: Compute the ELSP register location once Chris Wilson
2016-09-07 14:44   ` [PATCH v2 05/22] drm/i915: Reorder submitting the requests to ELSP Chris Wilson
2016-09-07 14:45   ` [PATCH v2 06/22] drm/i915: Simplify ELSP queue request tracking Chris Wilson
2016-09-07 14:45   ` [PATCH v2 07/22] drm/i915: Separate out reset flags from the reset counter Chris Wilson
2016-09-07 14:45   ` [PATCH v2 08/22] drm/i915: Drop local struct_mutex around intel_init_emon[ilk] Chris Wilson
2016-09-07 14:45   ` [PATCH v2 09/22] drm/i915: Expand bool interruptible to pass flags to i915_wait_request() Chris Wilson
2016-09-07 14:45   ` [PATCH v2 10/22] drm/i915: Mark up all locked waiters Chris Wilson
2016-09-07 14:45   ` [PATCH v2 11/22] drm/i915: Perform a direct reset of the GPU from the waiter Chris Wilson
2016-09-08  9:35     ` Mika Kuoppala
2016-09-07 14:45   ` [PATCH v2 12/22] drm/i915: Replace wait-on-mutex with wait-on-bit in reset worker Chris Wilson
2016-09-08 10:52     ` Mika Kuoppala
2016-09-08 13:24       ` Chris Wilson
2016-09-07 14:45   ` [PATCH v2 13/22] drm/i915: Update reset path to fix incomplete requests Chris Wilson
2016-09-08 12:03     ` Mika Kuoppala
2016-10-03 12:44     ` Tvrtko Ursulin
2016-10-03 12:56       ` Chris Wilson
2016-09-07 14:45   ` [PATCH v2 14/22] drm/i915: Drive request submission through fence callbacks Chris Wilson
2016-09-07 14:45   ` [PATCH v2 15/22] drm/i915: Reorder i915_add_request to separate the phases better Chris Wilson
2016-09-07 14:45   ` [PATCH v2 16/22] drm/i915: Prepare object synchronisation for asynchronicity Chris Wilson
2016-09-07 14:45   ` [PATCH v2 17/22] drm/i915/guc: Prepare for nonblocking execbuf submission Chris Wilson
2016-09-12 14:14     ` Tvrtko Ursulin
2016-09-07 14:45   ` [PATCH v2 18/22] drm/i915: Ignore valid but unknown semaphores Chris Wilson
2016-09-08  6:31     ` Joonas Lahtinen
2016-09-07 14:45   ` [PATCH v2 19/22] drm/i915: Nonblocking request submission Chris Wilson
2016-09-07 14:45   ` [PATCH v2 20/22] drm/i915: Serialise execbuf operation after a dma-buf reservation object Chris Wilson
2016-09-07 14:45   ` [PATCH v2 21/22] drm/i915: Enable userspace to opt-out of implicit fencing Chris Wilson
2016-09-07 14:45   ` [PATCH v2 22/22] drm/i915: Support explicit fencing for execbuf Chris Wilson
2016-09-07 15:49 ` ✗ Fi.CI.BAT: warning for series starting with [01/21] drm/i915: Add a sw fence for collecting up dma fences (rev22) 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=87wpip8jph.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.