[PATCH] shared-neglect

Chris Wilson chris at chris-wilson.co.uk
Thu Mar 4 23:31:19 UTC 2021


---
 drivers/gpu/drm/i915/i915_request.c | 39 +++++++++++------------------
 1 file changed, 15 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index e7b4c4bc41a6..715bf0f8923c 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -1393,40 +1393,31 @@ i915_request_await_object(struct i915_request *to,
 			  struct drm_i915_gem_object *obj,
 			  bool write)
 {
-	struct dma_fence *excl;
-	int ret = 0;
+	struct dma_fence *excl, **shared = !
+	unsigned int count;
+	int ret;
 
 	if (write) {
-		struct dma_fence **shared;
-		unsigned int count, i;
-
 		ret = dma_resv_get_fences_rcu(obj->base.resv,
-							&excl, &count, &shared);
-		if (ret)
-			return ret;
-
-		for (i = 0; i < count; i++) {
-			ret = i915_request_await_dma_fence(to, shared[i]);
-			if (ret)
-				break;
-
-			dma_fence_put(shared[i]);
-		}
-
-		for (; i < count; i++)
-			dma_fence_put(shared[i]);
-		kfree(shared);
+					      NULL, &count, &shared);
 	} else {
 		excl = dma_resv_get_excl_rcu(obj->base.resv);
+		count = !!excl;
+		ret = 0;
 	}
 
-	if (excl) {
-		if (ret == 0)
-			ret = i915_request_await_dma_fence(to, excl);
+	while (count--) {
+		struct dma_fence *fence = shared[count];
 
-		dma_fence_put(excl);
+		if (ret == 0 && !dma_fence_is_signaled(fence))
+			ret = i915_request_await_dma_fence(to, fence);
+
+		dma_fence_put(fence);
 	}
 
+	if (shared != &excl)
+		kfree(shared);
+
 	return ret;
 }
 
-- 
2.20.1



More information about the Intel-gfx-trybot mailing list