All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Lock signaler timeline while navigating
@ 2019-09-17  7:43 Chris Wilson
  2019-09-17  8:15 ` ✓ Fi.CI.BAT: success for " Patchwork
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Chris Wilson @ 2019-09-17  7:43 UTC (permalink / raw)
  To: intel-gfx

As we need to take a walk back along the signaler timeline to find the
fence before upon which we want to wait, we need to lock that timeline
to prevent it being modified as we walk. Similarly, we also need to
acquire a reference to the earlier fence while it still exists!

Though we lack the correct locking today, we are saved by the
overarching struct_mutex -- but that protection is being removed.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_request.c | 30 +++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index f12358150097..452ad7a8ff0c 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -767,16 +767,34 @@ i915_request_create(struct intel_context *ce)
 static int
 i915_request_await_start(struct i915_request *rq, struct i915_request *signal)
 {
-	if (list_is_first(&signal->link, &signal->timeline->requests))
+	struct intel_timeline *tl = signal->timeline;
+	struct dma_fence *fence;
+	int err;
+
+	if (list_is_first(&signal->link, &tl->requests))
 		return 0;
 
-	signal = list_prev_entry(signal, link);
-	if (intel_timeline_sync_is_later(rq->timeline, &signal->fence))
+	if (mutex_lock_interruptible_nested(&tl->mutex, SINGLE_DEPTH_NESTING))
+		return -EINTR;
+
+	if (list_is_first(&signal->link, &tl->requests)) {
+		fence = NULL;
+	} else {
+		signal = list_prev_entry(signal, link);
+		fence = dma_fence_get_rcu(&signal->fence);
+	}
+	mutex_unlock(&tl->mutex);
+	if (!fence)
 		return 0;
 
-	return i915_sw_fence_await_dma_fence(&rq->submit,
-					     &signal->fence, 0,
-					     I915_FENCE_GFP);
+	err = 0;
+	if (!intel_timeline_sync_is_later(rq->timeline, fence))
+		err = i915_sw_fence_await_dma_fence(&rq->submit,
+						    fence, 0,
+						    I915_FENCE_GFP);
+	dma_fence_put(fence);
+
+	return err;
 }
 
 static intel_engine_mask_t
-- 
2.23.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-09-18 13:58 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-17  7:43 [PATCH] drm/i915: Lock signaler timeline while navigating Chris Wilson
2019-09-17  8:15 ` ✓ Fi.CI.BAT: success for " Patchwork
2019-09-17 11:44 ` ✓ Fi.CI.IGT: " Patchwork
2019-09-17 14:51 ` [PATCH] " Tvrtko Ursulin
2019-09-17 15:04   ` Chris Wilson
2019-09-17 15:22     ` Tvrtko Ursulin
2019-09-17 15:09 ` [PATCH v2] " Chris Wilson
2019-09-17 15:20   ` Tvrtko Ursulin
2019-09-17 15:39 ` [PATCH v3] " Chris Wilson
2019-09-18 13:38   ` Tvrtko Ursulin
2019-09-18 13:44     ` Chris Wilson
2019-09-18 13:58       ` Tvrtko Ursulin
2019-09-17 17:40 ` ✓ Fi.CI.BAT: success for drm/i915: Lock signaler timeline while navigating (rev3) Patchwork
2019-09-18  7:36 ` ✓ Fi.CI.IGT: " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.