]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
drm/i915: Report both waiters and success from intel_engine_wakeup()
authorChris Wilson <chris@chris-wilson.co.uk>
Mon, 27 Feb 2017 20:58:47 +0000 (20:58 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 27 Feb 2017 21:57:19 +0000 (21:57 +0000)
The two users of the return value from intel_engine_wakeup() are
expecting different results. In the breadcrumbs hangcheck, we are using
it to determine whether wake_up_process() detected the waiter was
currently running (and if so we presume that it hasn't yet missed the
interrupt). However, in the fake_irq path, we are using the return value
as a check as to whether there are any waiters, and so we may
incorrectly stop the fake-irq if that waiter was currently running.

To handle the two different needs, return both bits of information! We
uninline it from the irq path in preparation for the next patch which
makes the irq hotpath special and relegates intel_engine_wakeup() to the
slow fixup paths.

v2: s/ret/result/

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170227205850.2828-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/intel_breadcrumbs.c
drivers/gpu/drm/i915/intel_ringbuffer.h

index 027c93e34c97eb2efef0b48ba28a4b93ae291acc..c8361f35035067b144d7abd6b8b7c0eab3eb201c 100644 (file)
 
 #include "i915_drv.h"
 
+unsigned int intel_engine_wakeup(struct intel_engine_cs *engine)
+{
+       unsigned int result = 0;
+
+       /* Note that for this not to dangerously chase a dangling pointer,
+        * we must hold the rcu_read_lock here.
+        *
+        * Also note that tsk is likely to be in !TASK_RUNNING state so an
+        * early test for tsk->state != TASK_RUNNING before wake_up_process()
+        * is unlikely to be beneficial.
+        */
+       if (intel_engine_has_waiter(engine)) {
+               struct task_struct *tsk;
+
+               result = ENGINE_WAKEUP_WAITER;
+
+               rcu_read_lock();
+               tsk = rcu_dereference(engine->breadcrumbs.irq_seqno_bh);
+               if (tsk && !wake_up_process(tsk))
+                       result |= ENGINE_WAKEUP_ACTIVE;
+               rcu_read_unlock();
+       }
+
+       return result;
+}
+
 static unsigned long wait_timeout(void)
 {
        return round_jiffies_up(jiffies + DRM_I915_HANGCHECK_JIFFIES);
@@ -49,7 +75,7 @@ static void intel_breadcrumbs_hangcheck(unsigned long data)
         * to process the pending interrupt (e.g, low priority task on a loaded
         * system) and wait until it sleeps before declaring a missed interrupt.
         */
-       if (!intel_engine_wakeup(engine)) {
+       if (intel_engine_wakeup(engine) & ENGINE_WAKEUP_ACTIVE) {
                mod_timer(&b->hangcheck, wait_timeout());
                return;
        }
index 0f29e07a9581b3c000a39a0db241b391f5962089..7d753dc1b89dc0b7b4c37ae04309ced56580b3d0 100644 (file)
@@ -642,29 +642,9 @@ static inline bool intel_engine_has_waiter(const struct intel_engine_cs *engine)
        return rcu_access_pointer(engine->breadcrumbs.irq_seqno_bh);
 }
 
-static inline bool intel_engine_wakeup(const struct intel_engine_cs *engine)
-{
-       bool wakeup = false;
-
-       /* Note that for this not to dangerously chase a dangling pointer,
-        * we must hold the rcu_read_lock here.
-        *
-        * Also note that tsk is likely to be in !TASK_RUNNING state so an
-        * early test for tsk->state != TASK_RUNNING before wake_up_process()
-        * is unlikely to be beneficial.
-        */
-       if (intel_engine_has_waiter(engine)) {
-               struct task_struct *tsk;
-
-               rcu_read_lock();
-               tsk = rcu_dereference(engine->breadcrumbs.irq_seqno_bh);
-               if (tsk)
-                       wakeup = wake_up_process(tsk);
-               rcu_read_unlock();
-       }
-
-       return wakeup;
-}
+unsigned int intel_engine_wakeup(struct intel_engine_cs *engine);
+#define ENGINE_WAKEUP_WAITER BIT(0)
+#define ENGINE_WAKEUP_ACTIVE BIT(1)
 
 void intel_engine_reset_breadcrumbs(struct intel_engine_cs *engine);
 void intel_engine_fini_breadcrumbs(struct intel_engine_cs *engine);