drm/i915/breadcrumbs: Queue hangcheck before sleeping
authorChris Wilson <chris@chris-wilson.co.uk>
Sat, 9 Jul 2016 09:12:05 +0000 (10:12 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 11 Jul 2016 12:48:22 +0000 (13:48 +0100)
Never go to sleep waiting on the GPU without first ensuring that we will
get woken up.

We have a choice of queuing the hangcheck before every schedule() or the
first time we wakeup. In order to simply accommodate both the signaler
and the ordinary waiter, move the queuing to the common point of
enabling the irq. We lose the paranoid safety of ensuring that the
hangcheck is active before the sleep, but avoid code duplication (and
redundant hangcheck queuing).

Testcase: igt/prime_busy
Fixes: c81d46138da6 ("drm/i915: Convert trace-irq to the breadcrumb waiter")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1468055535-19740-2-git-send-email-chris@chris-wilson.co.uk
Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com>
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/intel_breadcrumbs.c

index 8f50919ba9b40e59b2db9c550abc29dd0dbb0356..7fd44980798fd048714e927e8a305b94795175a0 100644 (file)
@@ -1501,15 +1501,6 @@ int __i915_wait_request(struct drm_i915_gem_request *req,
                        break;
                }
 
-               /* Ensure that even if the GPU hangs, we get woken up.
-                *
-                * However, note that if no one is waiting, we never notice
-                * a gpu hang. Eventually, we will have to wait for a resource
-                * held by the GPU and so trigger a hangcheck. In the most
-                * pathological case, this will be upon memory starvation!
-                */
-               i915_queue_hangcheck(req->i915);
-
                timeout_remain = io_schedule_timeout(timeout_remain);
                if (timeout_remain == 0) {
                        ret = -ETIME;
index d89b2c963618298f5e8f3b23bfdddaca46473f5a..b074f3d6d127fded56cdc49ea9326ced2407d51a 100644 (file)
@@ -93,6 +93,15 @@ static void __intel_breadcrumbs_enable_irq(struct intel_breadcrumbs *b)
        if (!b->irq_enabled ||
            test_bit(engine->id, &i915->gpu_error.missed_irq_rings))
                mod_timer(&b->fake_irq, jiffies + 1);
+
+       /* Ensure that even if the GPU hangs, we get woken up.
+        *
+        * However, note that if no one is waiting, we never notice
+        * a gpu hang. Eventually, we will have to wait for a resource
+        * held by the GPU and so trigger a hangcheck. In the most
+        * pathological case, this will be upon memory starvation!
+        */
+       i915_queue_hangcheck(i915);
 }
 
 static void __intel_breadcrumbs_disable_irq(struct intel_breadcrumbs *b)