[PATCH 03/22] manual-throttle

Chris Wilson chris at chris-wilson.co.uk
Sun Aug 25 14:20:02 UTC 2019


---
 .../drm/i915/gem/selftests/i915_gem_context.c | 32 ++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
index 3d9029d5d410..abe85ed0361f 100644
--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
@@ -356,6 +356,7 @@ static int igt_ctx_exec(void *arg)
 	for_each_engine(engine, i915, id) {
 		struct drm_i915_gem_object *obj = NULL;
 		unsigned long ncontexts, ndwords, dw;
+		struct i915_request *throttle[3] = {};
 		struct igt_live_test t;
 		struct drm_file *file;
 		IGT_TIMEOUT(end_time);
@@ -402,15 +403,36 @@ static int igt_ctx_exec(void *arg)
 			}
 
 			err = gpu_fill(ce, obj, dw);
-			intel_context_put(ce);
 
 			if (err) {
 				pr_err("Failed to fill dword %lu [%lu/%lu] with gpu (%s) in ctx %u [full-ppgtt? %s], err=%d\n",
 				       ndwords, dw, max_dwords(obj),
 				       engine->name, ctx->hw_id,
 				       yesno(!!ctx->vm), err);
+				intel_context_put(ce);
+				goto out_unlock;
+			}
+
+			if (throttle[2]) {
+				i915_request_wait(throttle[2], 0, MAX_SCHEDULE_TIMEOUT);
+				i915_request_put(throttle[2]);
+			}
+
+			throttle[2] = throttle[1];
+			throttle[1] = throttle[0];
+
+			throttle[0] = intel_context_create_request(ce);
+			if (IS_ERR(throttle[0])) {
+				if (throttle[2])
+					i915_request_put(throttle[2]);
+				if (throttle[1])
+					i915_request_put(throttle[1]);
+				err = PTR_ERR(throttle[0]);
+				intel_context_put(ce);
 				goto out_unlock;
 			}
+			i915_request_get(throttle[0]);
+			i915_request_add(throttle[0]);
 
 			if (++dw == max_dwords(obj)) {
 				obj = NULL;
@@ -419,7 +441,15 @@ static int igt_ctx_exec(void *arg)
 
 			ndwords++;
 			ncontexts++;
+
+			intel_context_put(ce);
 		}
+		if (throttle[2])
+			i915_request_put(throttle[2]);
+		if (throttle[1])
+			i915_request_put(throttle[1]);
+		if (throttle[0])
+			i915_request_put(throttle[0]);
 
 		pr_info("Submitted %lu contexts to %s, filling %lu dwords\n",
 			ncontexts, engine->name, ndwords);
-- 
2.23.0



More information about the Intel-gfx-trybot mailing list