From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: Recursive i915_reset_trylock() verboten
Date: Tue, 12 Feb 2019 13:12:05 +0200 [thread overview]
Message-ID: <87imxp1csa.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20190212102354.22284-1-chris@chris-wilson.co.uk>
Chris Wilson <chris@chris-wilson.co.uk> writes:
> We cannot nest i915_reset_trylock() as the inner may wait for the
> I915_RESET_BACKOFF which in turn is waiting upon sync_srcu who is
> waiting for our outermost lock. As we take the reset srcu around the
> fence update, we have to defer taking it in i915_gem_fault() until after
> we acquire the pin on the fence to avoid nesting. This is a little ugly,
> but still works. If a reset occurs between i915_vma_pin_fence() and the
> second reset lock, the reset will restore the fence register back to the
> pinned value before the reset lock allows us to proceed (our mmap won't
> be revoked as we haven't yet marked it as being a userfault as that
> requires us to hold the reset lock), so the pagefault is still
> serialised with the revocation in reset.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109605
> Fixes: 2caffbf11762 ("drm/i915: Revoke mmaps and prevent access to fence registers across reset")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@intel.com>
> ---
> drivers/gpu/drm/i915/i915_gem.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index c8c355bec091..ae1467a74a08 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -1923,16 +1923,16 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
> if (ret)
> goto err_unpin;
>
> + ret = i915_vma_pin_fence(vma);
> + if (ret)
> + goto err_unpin;
> +
As this is obviusness slipped past us, would it
be worthwhile, in retrospect, to build a debug in
i915_reset_trylock to be vocal about it failing
to make progress?
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> srcu = i915_reset_trylock(dev_priv);
> if (srcu < 0) {
> ret = srcu;
> - goto err_unpin;
> + goto err_fence;
> }
>
> - ret = i915_vma_pin_fence(vma);
> - if (ret)
> - goto err_reset;
> -
> /* Finally, remap it using the new GTT offset */
> ret = remap_io_mapping(area,
> area->vm_start + (vma->ggtt_view.partial.offset << PAGE_SHIFT),
> @@ -1940,7 +1940,7 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
> min_t(u64, vma->size, area->vm_end - area->vm_start),
> &ggtt->iomap);
> if (ret)
> - goto err_fence;
> + goto err_reset;
>
> /* Mark as being mmapped into userspace for later revocation */
> assert_rpm_wakelock_held(dev_priv);
> @@ -1950,10 +1950,10 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
>
> i915_vma_set_ggtt_write(vma);
>
> -err_fence:
> - i915_vma_unpin_fence(vma);
> err_reset:
> i915_reset_unlock(dev_priv, srcu);
> +err_fence:
> + i915_vma_unpin_fence(vma);
> err_unpin:
> __i915_vma_unpin(vma);
> err_unlock:
> --
> 2.20.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-02-12 11:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-12 10:23 [PATCH] drm/i915: Recursive i915_reset_trylock() verboten Chris Wilson
2019-02-12 10:53 ` ✗ Fi.CI.SPARSE: warning for " Patchwork
2019-02-12 11:12 ` Mika Kuoppala [this message]
2019-02-12 11:18 ` [PATCH] " Chris Wilson
2019-02-12 11:13 ` ✓ Fi.CI.BAT: success for " Patchwork
2019-02-12 12:58 ` ✓ Fi.CI.IGT: " 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=87imxp1csa.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.