[PATCH 12/21] drm/i915/gem: Re-evaluate execbuf throttling after wait

Chris Wilson chris at chris-wilson.co.uk
Tue Dec 17 10:20:21 UTC 2019


Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 .../gpu/drm/i915/gem/i915_gem_execbuffer.c    | 31 ++++++++++---------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index f7f581ff8a29..5b5d1f5cc06c 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -2250,7 +2250,6 @@ static struct i915_request *eb_throttle(struct intel_context *ce)
 static int __eb_pin_engine(struct i915_execbuffer *eb, struct intel_context *ce)
 {
 	struct intel_timeline *tl;
-	struct i915_request *rq;
 	int err;
 
 	/*
@@ -2270,6 +2269,12 @@ static int __eb_pin_engine(struct i915_execbuffer *eb, struct intel_context *ce)
 	if (err)
 		return err;
 
+	tl = intel_context_timeline_lock(ce);
+	if (IS_ERR(tl)) {
+		err = PTR_ERR(tl);
+		goto err_unpin;
+	}
+
 	/*
 	 * Take a local wakeref for preparing to dispatch the execbuf as
 	 * we expect to access the hardware fairly frequently in the
@@ -2278,21 +2283,18 @@ static int __eb_pin_engine(struct i915_execbuffer *eb, struct intel_context *ce)
 	 * until the timeline is idle, which in turn releases the wakeref
 	 * taken on the engine, and the parent device.
 	 */
-	tl = intel_context_timeline_lock(ce);
-	if (IS_ERR(tl)) {
-		err = PTR_ERR(tl);
-		goto err_unpin;
-	}
-
 	intel_context_enter(ce);
-	rq = eb_throttle(ce);
-
-	intel_context_timeline_unlock(tl);
 
-	if (rq) {
-		bool nonblock = eb->file->filp->f_flags & O_NONBLOCK;
+	do {
+		const bool nonblock = eb->file->filp->f_flags & O_NONBLOCK;
+		struct i915_request *rq;
 		long timeout;
 
+		rq = eb_throttle(ce);
+		intel_context_timeline_unlock(tl);
+		if (!rq)
+			break;
+
 		timeout = MAX_SCHEDULE_TIMEOUT;
 		if (nonblock)
 			timeout = 0;
@@ -2301,12 +2303,13 @@ static int __eb_pin_engine(struct i915_execbuffer *eb, struct intel_context *ce)
 					    I915_WAIT_INTERRUPTIBLE,
 					    timeout);
 		i915_request_put(rq);
-
 		if (timeout < 0) {
 			err = nonblock ? -EWOULDBLOCK : timeout;
 			goto err_exit;
 		}
-	}
+
+		mutex_lock(&tl->mutex);
+	} while (1);
 
 	eb->engine = ce->engine;
 	eb->context = ce;
-- 
2.24.1



More information about the Intel-gfx-trybot mailing list