]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/i915: Assert breadcrumbs are correctly ordered in the signal handler
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 3 May 2019 15:22:14 +0000 (16:22 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Tue, 7 May 2019 10:59:27 +0000 (11:59 +0100)
Inside the signal handler, we expect the requests to be ordered by their
breadcrumb such that no later request may be complete if we find an
earlier incomplete. Add an assert to check that the next breadcrumb
should not be logically before the current.

v2: Move the overhanging line into its own function and reuse it after
doing the insertion.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190503152214.26517-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/gt/intel_breadcrumbs.c

index 3cbffd400b1bdb15fbb1d0604d41f1001a144f5b..fe455f01aa65cc201a6b861aa2de9663c1af2c0b 100644 (file)
@@ -80,6 +80,22 @@ static inline bool __request_completed(const struct i915_request *rq)
        return i915_seqno_passed(__hwsp_seqno(rq), rq->fence.seqno);
 }
 
+__maybe_unused static bool
+check_signal_order(struct intel_context *ce, struct i915_request *rq)
+{
+       if (!list_is_last(&rq->signal_link, &ce->signals) &&
+           i915_seqno_passed(rq->fence.seqno,
+                             list_next_entry(rq, signal_link)->fence.seqno))
+               return false;
+
+       if (!list_is_first(&rq->signal_link, &ce->signals) &&
+           i915_seqno_passed(list_prev_entry(rq, signal_link)->fence.seqno,
+                             rq->fence.seqno))
+               return false;
+
+       return true;
+}
+
 void intel_engine_breadcrumbs_irq(struct intel_engine_cs *engine)
 {
        struct intel_breadcrumbs *b = &engine->breadcrumbs;
@@ -99,6 +115,8 @@ void intel_engine_breadcrumbs_irq(struct intel_engine_cs *engine)
                        struct i915_request *rq =
                                list_entry(pos, typeof(*rq), signal_link);
 
+                       GEM_BUG_ON(!check_signal_order(ce, rq));
+
                        if (!__request_completed(rq))
                                break;
 
@@ -282,6 +300,7 @@ bool i915_request_enable_breadcrumb(struct i915_request *rq)
                list_add(&rq->signal_link, pos);
                if (pos == &ce->signals) /* catch transitions from empty list */
                        list_move_tail(&ce->signal_link, &b->signalers);
+               GEM_BUG_ON(!check_signal_order(ce, rq));
 
                set_bit(I915_FENCE_FLAG_SIGNAL, &rq->fence.flags);
        }