Prepare to allow the GuC submission to be run from underneath a
hardirq timer context (and not just the current softirq context) as is
required for fast preemption resets and context switches.

Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_guc_submission.c | 30 ++++++++++++++-------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_guc_submission.c 
b/drivers/gpu/drm/i915/intel_guc_submission.c
index 62828e39ee26..97bd52fbd4e4 100644
--- a/drivers/gpu/drm/i915/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/intel_guc_submission.c
@@ -669,7 +669,7 @@ static inline int port_prio(const struct execlist_port 
*port)
        return rq_prio(port_request(port));
 }
 
-static void guc_dequeue(struct intel_engine_cs *engine)
+static bool __guc_dequeue(struct intel_engine_cs *engine)
 {
        struct intel_engine_execlists * const execlists = &engine->execlists;
        struct execlist_port *port = execlists->port;
@@ -679,7 +679,8 @@ static void guc_dequeue(struct intel_engine_cs *engine)
        bool submit = false;
        struct rb_node *rb;
 
-       spin_lock_irq(&engine->timeline.lock);
+       lockdep_assert_held(&engine->timeline.lock);
+
        rb = execlists->first;
        GEM_BUG_ON(rb_first(&execlists->queue) != rb);
 
@@ -694,13 +695,13 @@ static void guc_dequeue(struct intel_engine_cs *engine)
                                                     EXECLISTS_ACTIVE_PREEMPT);
                                queue_work(engine->i915->guc.preempt_wq,
                                           &preempt_work->work);
-                               goto unlock;
+                               return false;
                        }
                }
 
                port++;
                if (port_isset(port))
-                       goto unlock;
+                       return false;
        }
        GEM_BUG_ON(port_isset(port));
 
@@ -738,19 +739,30 @@ static void guc_dequeue(struct intel_engine_cs *engine)
 done:
        execlists->queue_priority = rb ? to_priolist(rb)->priority : INT_MIN;
        execlists->first = rb;
-       if (submit) {
+       if (submit)
                port_assign(port, last);
+       if (last)
                execlists_user_begin(execlists, execlists->port);
-               guc_submit(engine);
-       }
 
        /* We must always keep the beast fed if we have work piled up */
        GEM_BUG_ON(port_isset(execlists->port) &&
                   !execlists_is_active(execlists, EXECLISTS_ACTIVE_USER));
        GEM_BUG_ON(execlists->first && !port_isset(execlists->port));
 
-unlock:
-       spin_unlock_irq(&engine->timeline.lock);
+       return submit;
+}
+
+static void guc_dequeue(struct intel_engine_cs *engine)
+{
+       unsigned long flags;
+       bool submit;
+
+       spin_lock_irqsave(&engine->timeline.lock, flags);
+       submit = __guc_dequeue(engine);
+       spin_unlock_irqrestore(&engine->timeline.lock, flags);
+
+       if (submit)
+               guc_submit(engine);
 }
 
 static void guc_submission_tasklet(unsigned long data)
-- 
2.17.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to