[PATCH 10/10] rq ref

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Fri Mar 12 13:26:23 UTC 2021


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
 drivers/gpu/drm/i915/selftests/i915_request.c | 27 ++++++++++++++-----
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/selftests/i915_request.c b/drivers/gpu/drm/i915/selftests/i915_request.c
index ef426847171a..e63609ec5b97 100644
--- a/drivers/gpu/drm/i915/selftests/i915_request.c
+++ b/drivers/gpu/drm/i915/selftests/i915_request.c
@@ -632,6 +632,7 @@ static int __cancel_inactive(struct intel_engine_cs *engine)
 
 	pr_debug("%s: Cancelling inactive request\n", engine->name);
 	i915_request_cancel(rq, -EINTR);
+	i915_request_get(rq);
 	i915_request_add(rq);
 
 	if (i915_request_wait(rq, 0, HZ / 5) < 0) {
@@ -640,7 +641,7 @@ static int __cancel_inactive(struct intel_engine_cs *engine)
 		pr_err("%s: Failed to cancel inactive request\n", engine->name);
 		intel_engine_dump(engine, &p, "%s\n", engine->name);
 		err = -ETIME;
-		goto out_ce;
+		goto out_rq;
 	}
 
 	if (rq->fence.error != -EINTR) {
@@ -649,6 +650,8 @@ static int __cancel_inactive(struct intel_engine_cs *engine)
 		err = -EINVAL;
 	}
 
+out_rq:
+	i915_request_put(rq);
 out_ce:
 	intel_context_put(ce);
 out_spin:
@@ -681,6 +684,7 @@ static int __cancel_active(struct intel_engine_cs *engine)
 	}
 
 	pr_debug("%s: Cancelling active request\n", engine->name);
+	i915_request_get(rq);
 	i915_request_add(rq);
 	if (!igt_wait_for_spinner(&spin, rq)) {
 		struct drm_printer p = drm_info_printer(engine->i915->drm.dev);
@@ -688,7 +692,7 @@ static int __cancel_active(struct intel_engine_cs *engine)
 		pr_err("Failed to start spinner on %s\n", engine->name);
 		intel_engine_dump(engine, &p, "%s\n", engine->name);
 		err = -ETIME;
-		goto out_ce;
+		goto out_rq;
 	}
 	i915_request_cancel(rq, -EINTR);
 
@@ -698,7 +702,7 @@ static int __cancel_active(struct intel_engine_cs *engine)
 		pr_err("%s: Failed to cancel active request\n", engine->name);
 		intel_engine_dump(engine, &p, "%s\n", engine->name);
 		err = -ETIME;
-		goto out_ce;
+		goto out_rq;
 	}
 
 	if (rq->fence.error != -EINTR) {
@@ -707,6 +711,8 @@ static int __cancel_active(struct intel_engine_cs *engine)
 		err = -EINVAL;
 	}
 
+out_rq:
+	i915_request_put(rq);
 out_ce:
 	intel_context_put(ce);
 out_spin:
@@ -737,13 +743,15 @@ static int __cancel_active_chain(struct intel_engine_cs *engine)
 		err = PTR_ERR(rq[0]);
 		goto out_ce;
 	}
+	i915_request_get(rq[0]);
 	i915_request_add(rq[0]);
 
 	rq[1] = intel_context_create_request(ce);
 	if (IS_ERR(rq[1])) {
 		err = PTR_ERR(rq[1]);
-		goto out_ce;
+		goto out_spinner;
 	}
+	i915_request_get(rq[1]);
 	i915_request_add(rq[1]);
 
 	pr_debug("%s: Cancelling active chain\n", engine->name);
@@ -757,7 +765,7 @@ static int __cancel_active_chain(struct intel_engine_cs *engine)
 		pr_err("%s: Failed to cancel chained request\n", engine->name);
 		intel_engine_dump(engine, &p, "%s\n", engine->name);
 		err = -ETIME;
-		goto out_ce;
+		goto out_waiter;
 	}
 
 	if (rq[0]->fence.error != -EINTR) {
@@ -772,6 +780,10 @@ static int __cancel_active_chain(struct intel_engine_cs *engine)
 		err = -EINVAL;
 	}
 
+out_waiter:
+	i915_request_put(rq[1]);
+out_spinner:
+	i915_request_put(rq[0]);
 out_ce:
 	intel_context_put(ce);
 out_spin:
@@ -804,11 +816,12 @@ static int __cancel_completed(struct intel_engine_cs *engine)
 		goto out_ce;
 	}
 	igt_spinner_end(&spin);
+	i915_request_get(rq);
 	i915_request_add(rq);
 
 	if (i915_request_wait(rq, 0, HZ / 5) < 0) {
 		err = -ETIME;
-		goto out_ce;
+		goto out_rq;
 	}
 
 	pr_debug("%s: Cancelling completed request\n", engine->name);
@@ -819,6 +832,8 @@ static int __cancel_completed(struct intel_engine_cs *engine)
 		err = -EINVAL;
 	}
 
+out_rq:
+	i915_request_put(rq);
 out_ce:
 	intel_context_put(ce);
 out_spin:
-- 
2.27.0



More information about the Intel-gfx-trybot mailing list