drm/i915: Postpone fake breadcrumb interrupt until real interrupts cease
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 17 Feb 2017 15:13:00 +0000 (15:13 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 17 Feb 2017 15:30:50 +0000 (15:30 +0000)
When the timer expires for checking on interrupt processing, check to
see if any interrupts arrived within the last time period. If real
interrupts are still being delivered, we can be reassured that we
haven't missed the final interrupt as the waiter will still be woken.
Only once all activity ceases, do we have to worry about the waiter
never being woken and so need to install a timer to kick the waiter for
a slow arrival of a seqno.

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: http://patchwork.freedesktop.org/patch/msgid/20170217151304.16665-2-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_irq.c
drivers/gpu/drm/i915/intel_breadcrumbs.c
drivers/gpu/drm/i915/intel_ringbuffer.h

index 0d8ebd147da67f05f89337230c6a68bce50b4796..0657ac44a58270b862113b8c304d1a7e1cc69aaa 100644 (file)
@@ -1033,6 +1033,7 @@ static void ironlake_rps_change_irq_handler(struct drm_i915_private *dev_priv)
 
 static void notify_ring(struct intel_engine_cs *engine)
 {
+       atomic_inc(&engine->irq_count);
        set_bit(ENGINE_IRQ_BREADCRUMB, &engine->irq_posted);
        if (intel_engine_wakeup(engine))
                trace_i915_gem_request_notify(engine);
index 74cb7b91b5dbd26c988ba5ad9b220d2c5ff99a88..4395b177493e0d4d48a761a750a367e063514f7c 100644 (file)
 
 #include "i915_drv.h"
 
+static unsigned long wait_timeout(void)
+{
+       return round_jiffies_up(jiffies + DRM_I915_HANGCHECK_JIFFIES);
+}
+
 static void intel_breadcrumbs_hangcheck(unsigned long data)
 {
        struct intel_engine_cs *engine = (struct intel_engine_cs *)data;
@@ -34,8 +39,9 @@ static void intel_breadcrumbs_hangcheck(unsigned long data)
        if (!b->irq_enabled)
                return;
 
-       if (time_before(jiffies, b->timeout)) {
-               mod_timer(&b->hangcheck, b->timeout);
+       if (b->hangcheck_interrupts != atomic_read(&engine->irq_count)) {
+               b->hangcheck_interrupts = atomic_read(&engine->irq_count);
+               mod_timer(&b->hangcheck, wait_timeout());
                return;
        }
 
@@ -55,11 +61,6 @@ static void intel_breadcrumbs_hangcheck(unsigned long data)
        i915_queue_hangcheck(engine->i915);
 }
 
-static unsigned long wait_timeout(void)
-{
-       return round_jiffies_up(jiffies + DRM_I915_HANGCHECK_JIFFIES);
-}
-
 static void intel_breadcrumbs_fake_irq(unsigned long data)
 {
        struct intel_engine_cs *engine = (struct intel_engine_cs *)data;
@@ -140,8 +141,7 @@ static void __intel_breadcrumbs_enable_irq(struct intel_breadcrumbs *b)
                i915_queue_hangcheck(i915);
        } else {
                /* Ensure we never sleep indefinitely */
-               GEM_BUG_ON(!time_after(b->timeout, jiffies));
-               mod_timer(&b->hangcheck, b->timeout);
+               mod_timer(&b->hangcheck, wait_timeout());
        }
 }
 
@@ -258,7 +258,6 @@ static bool __intel_engine_add_wait(struct intel_engine_cs *engine,
                GEM_BUG_ON(!next && !first);
                if (next && next != &wait->node) {
                        GEM_BUG_ON(first);
-                       b->timeout = wait_timeout();
                        b->first_wait = to_wait(next);
                        rcu_assign_pointer(b->irq_seqno_bh, b->first_wait->tsk);
                        /* As there is a delay between reading the current
@@ -286,7 +285,6 @@ static bool __intel_engine_add_wait(struct intel_engine_cs *engine,
 
        if (first) {
                GEM_BUG_ON(rb_first(&b->waiters) != &wait->node);
-               b->timeout = wait_timeout();
                b->first_wait = wait;
                rcu_assign_pointer(b->irq_seqno_bh, wait->tsk);
                /* After assigning ourselves as the new bottom-half, we must
@@ -396,7 +394,6 @@ void intel_engine_remove_wait(struct intel_engine_cs *engine,
                         * the interrupt, or if we have to handle an
                         * exception rather than a seqno completion.
                         */
-                       b->timeout = wait_timeout();
                        b->first_wait = to_wait(next);
                        rcu_assign_pointer(b->irq_seqno_bh, b->first_wait->tsk);
                        if (b->first_wait->seqno != wait->seqno)
@@ -627,7 +624,6 @@ void intel_engine_reset_breadcrumbs(struct intel_engine_cs *engine)
 
        __intel_breadcrumbs_disable_irq(b);
        if (intel_engine_has_waiter(engine)) {
-               b->timeout = wait_timeout();
                __intel_breadcrumbs_enable_irq(b);
                if (test_bit(ENGINE_IRQ_BREADCRUMB, &engine->irq_posted))
                        wake_up_process(b->first_wait->tsk);
index 4ca5308e12bb8f3394cdaf93ce0f42b02b37e6c9..4091c97be6ecc73d84ce75f5409f446afa3c9e31 100644 (file)
@@ -213,6 +213,7 @@ struct intel_engine_cs {
 
        struct intel_render_state *render_state;
 
+       atomic_t irq_count;
        unsigned long irq_posted;
 #define ENGINE_IRQ_BREADCRUMB 0
 #define ENGINE_IRQ_EXECLIST 1
@@ -245,7 +246,7 @@ struct intel_engine_cs {
                struct timer_list fake_irq; /* used after a missed interrupt */
                struct timer_list hangcheck; /* detect missed interrupts */
 
-               unsigned long timeout;
+               unsigned int hangcheck_interrupts;
 
                bool irq_enabled : 1;
                bool rpm_wakelock : 1;