OSDN Git Service

drm/i915: Initialise basic fence before acquiring seqno
authorChris Wilson <chris@chris-wilson.co.uk>
Mon, 3 Feb 2020 09:41:48 +0000 (09:41 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 3 Feb 2020 11:27:00 +0000 (11:27 +0000)
Inside the intel_timeline_get_seqno(), we currently track the retirement
of the old cachelines by listening to the new request. This requires
that the new request is ready to be used and so requires a minimum bit
of initialisation prior to getting the new seqno.

Fixes: b1e3177bd1d8 ("drm/i915: Coordinate i915_active with its own mutex")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200203094152.4150550-2-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_request.c

index 78a5f5d..f56b046 100644 (file)
@@ -595,6 +595,8 @@ static void __i915_request_ctor(void *arg)
        i915_sw_fence_init(&rq->submit, submit_notify);
        i915_sw_fence_init(&rq->semaphore, semaphore_notify);
 
+       dma_fence_init(&rq->fence, &i915_fence_ops, &rq->lock, 0, 0);
+
        rq->file_priv = NULL;
        rq->capture_list = NULL;
 
@@ -653,25 +655,30 @@ __i915_request_create(struct intel_context *ce, gfp_t gfp)
                }
        }
 
-       ret = intel_timeline_get_seqno(tl, rq, &seqno);
-       if (ret)
-               goto err_free;
-
        rq->i915 = ce->engine->i915;
        rq->context = ce;
        rq->engine = ce->engine;
        rq->ring = ce->ring;
        rq->execution_mask = ce->engine->mask;
 
+       kref_init(&rq->fence.refcount);
+       rq->fence.flags = 0;
+       rq->fence.error = 0;
+       INIT_LIST_HEAD(&rq->fence.cb_list);
+
+       ret = intel_timeline_get_seqno(tl, rq, &seqno);
+       if (ret)
+               goto err_free;
+
+       rq->fence.context = tl->fence_context;
+       rq->fence.seqno = seqno;
+
        RCU_INIT_POINTER(rq->timeline, tl);
        RCU_INIT_POINTER(rq->hwsp_cacheline, tl->hwsp_cacheline);
        rq->hwsp_seqno = tl->hwsp_seqno;
 
        rq->rcustate = get_state_synchronize_rcu(); /* acts as smp_mb() */
 
-       dma_fence_init(&rq->fence, &i915_fence_ops, &rq->lock,
-                      tl->fence_context, seqno);
-
        /* We bump the ref for the fence chain */
        i915_sw_fence_reinit(&i915_request_get(rq)->submit);
        i915_sw_fence_reinit(&i915_request_get(rq)->semaphore);