[PATCH] nowait

Chris Wilson chris at chris-wilson.co.uk
Fri Feb 5 15:46:40 UTC 2021


---
 drivers/gpu/drm/i915/gt/intel_ring.c | 36 ++++++++++------------------
 1 file changed, 13 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_ring.c b/drivers/gpu/drm/i915/gt/intel_ring.c
index aee0a77c77e0..8007828ff26d 100644
--- a/drivers/gpu/drm/i915/gt/intel_ring.c
+++ b/drivers/gpu/drm/i915/gt/intel_ring.c
@@ -182,42 +182,32 @@ void intel_ring_free(struct kref *ref)
 	kfree(ring);
 }
 
-static noinline int
+static int
 wait_for_space(struct intel_ring *ring,
 	       struct intel_timeline *tl,
 	       unsigned int bytes)
 {
-	struct i915_request *target;
-	long timeout;
+	struct i915_request *rq, *rn;
 
 	if (intel_ring_update_space(ring) >= bytes)
 		return 0;
 
+	/* Only do as much work in retiring requests as we need */
 	GEM_BUG_ON(list_empty(&tl->requests));
-	list_for_each_entry(target, &tl->requests, link) {
-		if (target->ring != ring)
+	list_for_each_entry_safe(rq, rn, &tl->requests, link) {
+		if (rq->ring != ring)
 			continue;
 
-		/* Would completion of this request free enough space? */
-		if (bytes <= __intel_ring_space(target->postfix,
-						ring->emit, ring->size))
-			break;
+		if (!__i915_request_is_complete(rq))
+			return -EWOULDBLOCK;
+
+		/* Does completion of this request free enough space? */
+		i915_request_retire(rq);
+		if (intel_ring_update_space(ring) >= bytes)
+			return 0;
 	}
 
-	if (GEM_WARN_ON(&target->link == &tl->requests))
-		return -ENOSPC;
-
-	timeout = i915_request_wait(target,
-				    I915_WAIT_INTERRUPTIBLE,
-				    MAX_SCHEDULE_TIMEOUT);
-	if (timeout < 0)
-		return timeout;
-
-	i915_request_retire_upto(target);
-
-	intel_ring_update_space(ring);
-	GEM_BUG_ON(ring->space < bytes);
-	return 0;
+	return -ENOSPC;
 }
 
 u32 *intel_ring_begin(struct i915_request *rq, unsigned int num_dwords)
-- 
2.20.1



More information about the Intel-gfx-trybot mailing list