From: Ben Widawsky <ben@bwidawsk.net>
To: intel-gfx@lists.freedesktop.org
Cc: Ben Widawsky <ben@bwidawsk.net>,
Ben Widawsky <benjamin.widawsky@intel.com>
Subject: [PATCH 08/10] drm/i915: real wait seqno with timeout
Date: Fri, 20 Apr 2012 18:23:30 -0700 [thread overview]
Message-ID: <1334971412-4826-9-git-send-email-ben@bwidawsk.net> (raw)
In-Reply-To: <1334971412-4826-1-git-send-email-ben@bwidawsk.net>
Move the final interesting chunk from i915_wait_seqno into a timed
variant. The timed variant can take a NULL or 0 timeout argument to
preserve the old behavior, and this allowing the old (still useful
function) to call directly into the timed variant.
This code does not require struct_mutex, therefore it can wait on events
without holding the lock.
Signed-off-by: Ben Widawsky <benjamin.widawsky@intel.com>
---
drivers/gpu/drm/i915/i915_gem.c | 53 ++++++++++++++++++++++++++-------------
1 file changed, 36 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 7bfad04..e446d9c 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1879,6 +1879,40 @@ static int __wait_seqno(struct intel_ring_buffer *ring, u32 seqno,
}
}
+static int
+i915_seqno_wait_timed(struct intel_ring_buffer *ring, u32 seqno,
+ bool interruptible, long *timeout)
+{
+ bool wait_forever = false;
+ int ret = 0;
+
+ BUG_ON(seqno == ring->outstanding_lazy_request);
+
+ if (timeout == NULL || ((*timeout) < 0))
+ wait_forever = true;
+
+ if (!i915_seqno_passed(ring->get_seqno(ring), seqno)) {
+ trace_i915_gem_request_wait_begin(ring, seqno);
+
+ if (WARN_ON(!ring->irq_get(ring)))
+ return -EBUSY;
+
+ do {
+ long time = wait_forever ? SEQNO_WAIT_DEFAULT : *timeout;
+ ret = __wait_seqno(ring, seqno,
+ interruptible,
+ &time);
+ if (ret == 0 && timeout)
+ *timeout = time;
+ } while (ret == -ETIME && wait_forever);
+
+ ring->irq_put(ring);
+ trace_i915_gem_request_wait_end(ring, seqno);
+ }
+
+ return ret;
+}
+
/**
* Waits for a sequence number to be signaled, and cleans up the
* request and object lists appropriately for that event.
@@ -1920,23 +1954,8 @@ i915_wait_request(struct intel_ring_buffer *ring,
seqno = request->seqno;
}
-
- if (!i915_seqno_passed(ring->get_seqno(ring), seqno)) {
- trace_i915_gem_request_wait_begin(ring, seqno);
-
- if (WARN_ON(!ring->irq_get(ring)))
- return -EBUSY;
-
- do {
- long time = SEQNO_WAIT_DEFAULT;
- ret = __wait_seqno(ring, seqno,
- dev_priv->mm.interruptible,
- &time);
- } while (ret == -ETIME);
-
- ring->irq_put(ring);
- trace_i915_gem_request_wait_end(ring, seqno);
- }
+ ret = i915_seqno_wait_timed(ring, seqno, dev_priv->mm.interruptible,
+ NULL);
if (atomic_read(&dev_priv->mm.wedged))
ret = -EAGAIN;
--
1.7.10
next prev parent reply other threads:[~2012-04-21 1:25 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-21 1:23 [PATCH 00/10] wait for BO with timeout Ben Widawsky
2012-04-21 1:23 ` [PATCH 01/10] drm/i915: remove do_retire from i915_wait_request Ben Widawsky
2012-04-21 17:17 ` Daniel Vetter
2012-04-21 17:27 ` Ben Widawsky
2012-04-21 17:36 ` Daniel Vetter
2012-04-21 1:23 ` [PATCH 02/10] drm/i915: move vbetool invoked ier stuff Ben Widawsky
2012-04-21 9:26 ` Chris Wilson
2012-04-21 1:23 ` [PATCH 03/10] drm/i915: kill waiting_seqno Ben Widawsky
2012-04-22 13:46 ` Chris Wilson
2012-04-22 17:47 ` Ben Widawsky
2012-04-21 1:23 ` [PATCH 04/10] drm/i915: drop polled waits from i915_wait_request Ben Widawsky
2012-04-21 9:29 ` Chris Wilson
2012-04-21 16:14 ` Ben Widawsky
2012-04-21 1:23 ` [PATCH 05/10] drm/i915: extract __wait_seqno " Ben Widawsky
2012-04-21 1:23 ` [PATCH 06/10] drm/i915: use __wait_seqno for ring throttle Ben Widawsky
2012-04-22 14:17 ` Chris Wilson
2012-04-21 1:23 ` [PATCH 07/10] drm/i915: timeout parameter for seqno wait Ben Widawsky
2012-04-22 12:52 ` Daniel Vetter
2012-04-21 1:23 ` Ben Widawsky [this message]
2012-04-21 1:23 ` [PATCH 09/10] drm/i915: wait render timeout ioctl Ben Widawsky
2012-04-21 9:41 ` Chris Wilson
2012-04-21 16:12 ` Ben Widawsky
2012-04-21 20:37 ` Ben Widawsky
2012-04-22 9:37 ` Chris Wilson
2012-04-22 9:48 ` Chris Wilson
2012-04-22 10:11 ` Daniel Vetter
2012-04-22 12:45 ` Daniel Vetter
2012-04-23 15:28 ` Ben Widawsky
2012-04-22 14:14 ` Chris Wilson
2012-04-21 1:23 ` [PATCH 10/10] drm/i915: s/i915_wait_reqest/i915_wait_seqno/g Ben Widawsky
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=1334971412-4826-9-git-send-email-ben@bwidawsk.net \
--to=ben@bwidawsk.net \
--cc=benjamin.widawsky@intel.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox