[PATCH 2/9] i915_request_cancel rcu

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


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

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
 drivers/gpu/drm/i915/i915_request.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index 197e7bff5a26..fb9c5bb1fe41 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -655,13 +655,26 @@ void i915_request_cancel(struct i915_request *rq, int error)
 	if (i915_sw_fence_signaled(&rq->submit)) {
 		struct i915_dependency *p;
 
+restart:
+		rcu_read_lock();
 		for_each_waiter(p, rq) {
 			struct i915_request *w =
 				container_of(p->waiter, typeof(*w), sched);
 
-			/* Recursion is bounded by the number of engines */
+			if (__i915_request_is_complete(w) ||
+			    fatal_error(w->fence.error))
+				continue;
+
+			w = i915_request_get(w);
+			rcu_read_unlock();
+			/* Recursion bound by the number of engines */
 			i915_request_cancel(w, error);
+			i915_request_put(w);
+
+			/* Restart after having to drop rcu lock. */
+			goto restart;
 		}
+		rcu_read_unlock();
 	}
 
 	__cancel_request(rq);
-- 
2.27.0



More information about the Intel-gfx-trybot mailing list