From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 02/39] drm/i915: Refine i915_reset.lock_map
Date: Fri, 14 Jun 2019 17:10:08 +0300 [thread overview]
Message-ID: <87pnng8dhb.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20190614071023.17929-3-chris@chris-wilson.co.uk>
Chris Wilson <chris@chris-wilson.co.uk> writes:
> We already use a mutex to serialise i915_reset() and wedging, so all we
> need it to link that into i915_request_wait() and we have our lock cycle
> detection.
>
> v2.5: Take error mutex for selftests
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> ---
> drivers/gpu/drm/i915/gt/intel_reset.c | 6 ++----
> drivers/gpu/drm/i915/i915_drv.h | 8 --------
> drivers/gpu/drm/i915/i915_gem.c | 3 ---
> drivers/gpu/drm/i915/i915_request.c | 12 ++++++++++--
> drivers/gpu/drm/i915/selftests/mock_gem_device.c | 2 --
> 5 files changed, 12 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_reset.c b/drivers/gpu/drm/i915/gt/intel_reset.c
> index 8ba7af8b7ced..41a294f5cc19 100644
> --- a/drivers/gpu/drm/i915/gt/intel_reset.c
> +++ b/drivers/gpu/drm/i915/gt/intel_reset.c
> @@ -978,7 +978,7 @@ void i915_reset(struct drm_i915_private *i915,
>
> might_sleep();
> GEM_BUG_ON(!test_bit(I915_RESET_BACKOFF, &error->flags));
> - lock_map_acquire(&i915->gt.reset_lockmap);
> + mutex_lock(&error->wedge_mutex);
>
> /* Clear any previous failed attempts at recovery. Time to try again. */
> if (!__i915_gem_unset_wedged(i915))
> @@ -1031,7 +1031,7 @@ void i915_reset(struct drm_i915_private *i915,
> finish:
> reset_finish(i915);
> unlock:
> - lock_map_release(&i915->gt.reset_lockmap);
> + mutex_unlock(&error->wedge_mutex);
> return;
>
> taint:
> @@ -1147,9 +1147,7 @@ static void i915_reset_device(struct drm_i915_private *i915,
> /* Flush everyone using a resource about to be clobbered */
> synchronize_srcu_expedited(&error->reset_backoff_srcu);
>
> - mutex_lock(&error->wedge_mutex);
> i915_reset(i915, engine_mask, reason);
> - mutex_unlock(&error->wedge_mutex);
>
> intel_finish_reset(i915);
> }
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 90d94d904e65..3683ef6d4c28 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1901,14 +1901,6 @@ struct drm_i915_private {
> ktime_t last_init_time;
>
> struct i915_vma *scratch;
> -
> - /*
> - * We must never wait on the GPU while holding a lock as we
> - * may need to perform a GPU reset. So while we don't need to
> - * serialise wait/reset with an explicit lock, we do want
> - * lockdep to detect potential dependency cycles.
> - */
> - struct lockdep_map reset_lockmap;
> } gt;
>
> struct {
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 4bbded4aa936..7232361973fd 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -1746,7 +1746,6 @@ static void i915_gem_init__mm(struct drm_i915_private *i915)
>
> int i915_gem_init_early(struct drm_i915_private *dev_priv)
> {
> - static struct lock_class_key reset_key;
> int err;
>
> intel_gt_pm_init(dev_priv);
> @@ -1754,8 +1753,6 @@ int i915_gem_init_early(struct drm_i915_private *dev_priv)
> INIT_LIST_HEAD(&dev_priv->gt.active_rings);
> INIT_LIST_HEAD(&dev_priv->gt.closed_vma);
> spin_lock_init(&dev_priv->gt.closed_lock);
> - lockdep_init_map(&dev_priv->gt.reset_lockmap,
> - "i915.reset", &reset_key, 0);
>
> i915_gem_init__mm(dev_priv);
> i915_gem_init__pm(dev_priv);
> diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
> index 1cbc3ef4fc27..5311286578b7 100644
> --- a/drivers/gpu/drm/i915/i915_request.c
> +++ b/drivers/gpu/drm/i915/i915_request.c
> @@ -1444,7 +1444,15 @@ long i915_request_wait(struct i915_request *rq,
> return -ETIME;
>
> trace_i915_request_wait_begin(rq, flags);
> - lock_map_acquire(&rq->i915->gt.reset_lockmap);
> +
> + /*
> + * We must never wait on the GPU while holding a lock as we
> + * may need to perform a GPU reset. So while we don't need to
> + * serialise wait/reset with an explicit lock, we do want
> + * lockdep to detect potential dependency cycles.
> + */
> + mutex_acquire(&rq->i915->gpu_error.wedge_mutex.dep_map,
> + 0, 0, _THIS_IP_);
Seems to translate to exclusive lock with full checking.
There was ofcourse a slight possibilty that previous reviewer did
read all the lockdep.h. Looked at the wedge mutex and connected
the dots. Well, it is obvious now.
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
>
> /*
> * Optimistic spin before touching IRQs.
> @@ -1518,7 +1526,7 @@ long i915_request_wait(struct i915_request *rq,
> dma_fence_remove_callback(&rq->fence, &wait.cb);
>
> out:
> - lock_map_release(&rq->i915->gt.reset_lockmap);
> + mutex_release(&rq->i915->gpu_error.wedge_mutex.dep_map, 0, _THIS_IP_);
> trace_i915_request_wait_end(rq);
> return timeout;
> }
> diff --git a/drivers/gpu/drm/i915/selftests/mock_gem_device.c b/drivers/gpu/drm/i915/selftests/mock_gem_device.c
> index 1e9ffced78c1..b7f3fbb4ae89 100644
> --- a/drivers/gpu/drm/i915/selftests/mock_gem_device.c
> +++ b/drivers/gpu/drm/i915/selftests/mock_gem_device.c
> @@ -130,7 +130,6 @@ static struct dev_pm_domain pm_domain = {
>
> struct drm_i915_private *mock_gem_device(void)
> {
> - static struct lock_class_key reset_key;
> struct drm_i915_private *i915;
> struct pci_dev *pdev;
> int err;
> @@ -205,7 +204,6 @@ struct drm_i915_private *mock_gem_device(void)
> INIT_LIST_HEAD(&i915->gt.active_rings);
> INIT_LIST_HEAD(&i915->gt.closed_vma);
> spin_lock_init(&i915->gt.closed_lock);
> - lockdep_init_map(&i915->gt.reset_lockmap, "i915.reset", &reset_key, 0);
>
> mutex_lock(&i915->drm.struct_mutex);
>
> --
> 2.20.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-06-14 14:10 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-14 7:09 WIP glance towards struct_mutex removal Chris Wilson
2019-06-14 7:09 ` [PATCH 01/39] drm/i915: Discard some redundant cache domain flushes Chris Wilson
2019-06-14 9:12 ` Matthew Auld
2019-06-14 7:09 ` [PATCH 02/39] drm/i915: Refine i915_reset.lock_map Chris Wilson
2019-06-14 14:10 ` Mika Kuoppala [this message]
2019-06-14 14:17 ` Chris Wilson
2019-06-14 7:09 ` [PATCH 03/39] drm/i915: Avoid tainting i915_gem_park() with wakeref.lock Chris Wilson
2019-06-14 14:47 ` Mika Kuoppala
2019-06-14 14:51 ` Chris Wilson
2019-06-14 7:09 ` [PATCH 04/39] drm/i915: Enable refcount debugging for default debug levels Chris Wilson
2019-06-14 15:11 ` Mika Kuoppala
2019-06-14 15:11 ` Mika Kuoppala
2019-06-14 7:09 ` [PATCH 05/39] drm/i915: Keep contexts pinned until after the next kernel context switch Chris Wilson
2019-06-14 7:09 ` [PATCH 06/39] drm/i915: Stop retiring along engine Chris Wilson
2019-06-14 7:09 ` [PATCH 07/39] drm/i915: Replace engine->timeline with a plain list Chris Wilson
2019-06-14 7:09 ` [PATCH 08/39] drm/i915: Flush the execution-callbacks on retiring Chris Wilson
2019-06-14 7:09 ` [PATCH 09/39] drm/i915/execlists: Preempt-to-busy Chris Wilson
2019-06-14 7:09 ` [PATCH 10/39] drm/i915/execlists: Minimalistic timeslicing Chris Wilson
2019-06-14 7:09 ` [PATCH 11/39] drm/i915/execlists: Force preemption Chris Wilson
2019-06-14 7:09 ` [PATCH 12/39] dma-fence: Propagate errors to dma-fence-array container Chris Wilson
2019-06-14 7:09 ` [PATCH 13/39] dma-fence: Report the composite sync_file status Chris Wilson
2019-06-14 7:09 ` [PATCH 14/39] dma-fence: Refactor signaling for manual invocation Chris Wilson
2019-06-14 7:09 ` [PATCH 15/39] dma-fence: Always execute signal callbacks Chris Wilson
2019-06-14 7:10 ` [PATCH 16/39] drm/i915: Execute signal callbacks from no-op i915_request_wait Chris Wilson
2019-06-14 10:45 ` Tvrtko Ursulin
2019-06-14 7:10 ` [PATCH 17/39] drm/i915: Make the semaphore saturation mask global Chris Wilson
2019-06-14 7:10 ` [PATCH 18/39] drm/i915: Throw away the active object retirement complexity Chris Wilson
2019-06-14 7:10 ` [PATCH 19/39] drm/i915: Provide an i915_active.acquire callback Chris Wilson
2019-06-14 7:10 ` [PATCH 20/39] drm/i915: Push the i915_active.retire into a worker Chris Wilson
2019-06-14 7:10 ` [PATCH 21/39] drm/i915/overlay: Switch to using i915_active tracking Chris Wilson
2019-06-14 7:10 ` [PATCH 22/39] drm/i915: Forgo last_fence active request tracking Chris Wilson
2019-06-14 7:10 ` [PATCH 23/39] drm/i915: Extract intel_frontbuffer active tracking Chris Wilson
2019-06-14 7:10 ` [PATCH 24/39] drm/i915: Coordinate i915_active with its own mutex Chris Wilson
2019-06-14 7:10 ` [PATCH 25/39] drm/i915: Track ggtt fence reservations under " Chris Wilson
2019-06-14 7:10 ` [PATCH 26/39] drm/i915: Only track bound elements of the GTT Chris Wilson
2019-06-14 7:10 ` [PATCH 27/39] drm/i915: Explicitly cleanup initial_plane_config Chris Wilson
2019-06-14 7:10 ` [PATCH 28/39] initial-plane-vma Chris Wilson
2019-06-14 7:10 ` [PATCH 29/39] drm/i915: Make i915_vma track its own kref Chris Wilson
2019-06-14 11:15 ` Matthew Auld
2019-06-14 11:18 ` Chris Wilson
2019-06-14 7:10 ` [PATCH 30/39] drm/i915: Propagate fence errors Chris Wilson
2019-06-14 7:10 ` [PATCH 31/39] drm/i915: Allow page pinning to be in the background Chris Wilson
2019-06-14 7:10 ` [PATCH 32/39] drm/i915: Allow vma binding to occur asynchronously Chris Wilson
2019-08-05 20:35 ` Kumar Valsan, Prathap
2019-06-14 7:10 ` [PATCH 33/39] revoke-fence Chris Wilson
2019-06-14 7:10 ` [PATCH 34/39] drm/i915: Use vm->mutex for serialising GTT insertion Chris Wilson
2019-06-14 19:14 ` Matthew Auld
2019-06-14 19:20 ` Chris Wilson
2019-06-14 7:10 ` [PATCH 35/39] drm/i915: Pin pages before waiting Chris Wilson
2019-06-14 19:53 ` Matthew Auld
2019-06-14 19:58 ` Chris Wilson
2019-06-14 20:13 ` Chris Wilson
2019-06-14 20:18 ` Matthew Auld
2019-06-14 7:10 ` [PATCH 36/39] drm/i915: Use reservation_object to coordinate userptr get_pages() Chris Wilson
2019-08-07 20:49 ` Daniel Vetter
2019-08-08 7:30 ` [Intel-gfx] " Daniel Vetter
2019-06-14 7:10 ` [PATCH 37/39] drm/i915: Use forced preemptions in preference over hangcheck Chris Wilson
2019-06-14 7:10 ` [PATCH 38/39] drm/i915: Remove logical HW ID Chris Wilson
2019-06-14 7:10 ` [PATCH 39/39] active-rings Chris Wilson
2019-06-14 7:22 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/39] drm/i915: Discard some redundant cache domain flushes Patchwork
2019-06-14 7:35 ` ✗ Fi.CI.SPARSE: " 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=87pnng8dhb.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.