All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [CI 01/19] drm/i915: Introduce i915_gem_active_wait_unlocked()
Date: Fri,  5 Aug 2016 10:14:06 +0100	[thread overview]
Message-ID: <1470388464-28458-1-git-send-email-chris@chris-wilson.co.uk> (raw)

It is useful to be able to wait on pending rendering without grabbing
the struct_mutex. We can do this by using the i915_gem_active_get_rcu()
primitive to acquire a reference to the pending request without
requiring struct_mutex, just the RCU read lock, and then call
i915_wait_request().

v2: Rebase onto new i915_gem_active_get_unlocked() semantics that take
the RCU read lock on behalf of the caller.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem_request.h | 40 +++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_gem_request.h b/drivers/gpu/drm/i915/i915_gem_request.h
index 6002adc43523..15495d1e48e8 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.h
+++ b/drivers/gpu/drm/i915/i915_gem_request.h
@@ -569,6 +569,46 @@ i915_gem_active_wait(const struct i915_gem_active *active, struct mutex *mutex)
 }
 
 /**
+ * i915_gem_active_wait_unlocked - waits until the request is completed
+ * @active - the active request on which to wait
+ * @interruptible - whether the wait can be woken by a userspace signal
+ * @timeout - how long to wait at most
+ * @rps - userspace client to charge for a waitboost
+ *
+ * i915_gem_active_wait_unlocked() waits until the request is completed before
+ * returning, without requiring any locks to be held. Note that it does not
+ * retire any requests before returning.
+ *
+ * This function relies on RCU in order to acquire the reference to the active
+ * request without holding any locks. See __i915_gem_active_get_rcu() for the
+ * glory details on how that is managed. Once the reference is acquired, we
+ * can then wait upon the request, and afterwards release our reference,
+ * free of any locking.
+ *
+ * This function wraps i915_wait_request(), see it for the full details on
+ * the arguments.
+ *
+ * Returns 0 if successful, or a negative error code.
+ */
+static inline int
+i915_gem_active_wait_unlocked(const struct i915_gem_active *active,
+			      bool interruptible,
+			      s64 *timeout,
+			      struct intel_rps_client *rps)
+{
+	struct drm_i915_gem_request *request;
+	int ret = 0;
+
+	request = i915_gem_active_get_unlocked(active);
+	if (request) {
+		ret = i915_wait_request(request, interruptible, timeout, rps);
+		i915_gem_request_put(request);
+	}
+
+	return ret;
+}
+
+/**
  * i915_gem_active_retire - waits until the request is retired
  * @active - the active request on which to wait
  *
-- 
2.8.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

             reply	other threads:[~2016-08-05  9:14 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-05  9:14 Chris Wilson [this message]
2016-08-05  9:14 ` [CI 02/19] drm/i915: Convert non-blocking waits for requests over to using RCU Chris Wilson
2016-08-05  9:14 ` [CI 03/19] drm/i915: Convert non-blocking userptr " Chris Wilson
2016-08-05  9:14 ` [CI 04/19] drm/i915/userptr: Remove superfluous interruptible=false on waiting Chris Wilson
2016-08-05  9:14 ` [CI 05/19] drm/i915: Remove forced stop ring on suspend/unload Chris Wilson
2016-08-05  9:14 ` [CI 06/19] drm/i915: Enable i915_gem_wait_for_idle() without holding struct_mutex Chris Wilson
2016-08-05  9:14 ` [CI 07/19] drm/i915: Simplify do_idling() (Ironlake vt-d w/a) Chris Wilson
2016-08-05  9:14 ` [CI 08/19] drm/i915/shrinker: Wait before acquiring struct_mutex under oom Chris Wilson
2016-08-05  9:14 ` [CI 09/19] drm/i915: Tidy generation of the GTT mmap offset Chris Wilson
2016-08-05  9:14 ` [CI 10/19] drm/i915: Remove unused no-shrinker-steal Chris Wilson
2016-08-05  9:14 ` [CI 11/19] drm/i915: Do a nonblocking wait first in pread/pwrite Chris Wilson
2016-08-05  9:14 ` [CI 12/19] drm/i915: Remove (struct_mutex) locking for wait-ioctl Chris Wilson
2016-08-05  9:14 ` [CI 13/19] drm/i915: Remove (struct_mutex) locking for busy-ioctl Chris Wilson
2016-08-05 19:08   ` Daniel Vetter
2016-08-05 19:30     ` Chris Wilson
2016-08-05 20:12       ` Daniel Vetter
2016-08-05  9:14 ` [CI 14/19] drm/i915: Reduce locking inside swfinish ioctl Chris Wilson
2016-08-05  9:14 ` [CI 15/19] drm/i915: Remove pinned check from madvise ioctl Chris Wilson
2016-08-05 19:10   ` Daniel Vetter
2016-08-05  9:14 ` [CI 16/19] drm/i915: Remove locking for get_tiling Chris Wilson
2016-08-05  9:14 ` [CI 17/19] drm/i915: Document and reject invalid tiling modes Chris Wilson
2016-08-05  9:14 ` [CI 18/19] drm/i915: Repack fence tiling mode and stride into a single integer Chris Wilson
2016-08-05  9:14 ` [CI 19/19] drm/i915: Assert that the request hasn't been retired Chris Wilson
2016-08-05  9:39 ` ✗ Ro.CI.BAT: failure for series starting with [CI,01/19] drm/i915: Introduce i915_gem_active_wait_unlocked() 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=1470388464-28458-1-git-send-email-chris@chris-wilson.co.uk \
    --to=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.