drm/i915/guc: stop calling execlists_set_default_submission
authorDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Wed, 13 Jan 2021 02:12:36 +0000 (18:12 -0800)
committerChris Wilson <chris@chris-wilson.co.uk>
Wed, 13 Jan 2021 11:22:00 +0000 (11:22 +0000)
Initialize all required entries from guc_set_default_submission, instead
of calling the execlists function. The previously inherited setup has
been copied over from the execlist code and simplified by removing the
execlists submission-specific parts.

v2: move setting of relative_mmio flag to engine_setup_common (Chris)

Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: John Harrison <john.c.harrison@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> #v1
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20210113021236.8164-5-daniele.ceraolospurio@intel.com
drivers/gpu/drm/i915/gt/intel_engine_cs.c
drivers/gpu/drm/i915/gt/intel_execlists_submission.c
drivers/gpu/drm/i915/gt/intel_execlists_submission.h
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c

index 6b4483b..f531207 100644 (file)
@@ -727,6 +727,9 @@ static int engine_setup_common(struct intel_engine_cs *engine)
        intel_engine_init_whitelist(engine);
        intel_engine_init_ctx_wa(engine);
 
+       if (INTEL_GEN(engine->i915) >= 12)
+               engine->flags |= I915_ENGINE_HAS_RELATIVE_MMIO;
+
        return 0;
 
 err_status:
index 10e9940..d7d5a58 100644 (file)
@@ -3100,7 +3100,7 @@ static bool can_preempt(struct intel_engine_cs *engine)
        return engine->class != RENDER_CLASS;
 }
 
-void intel_execlists_set_default_submission(struct intel_engine_cs *engine)
+static void execlists_set_default_submission(struct intel_engine_cs *engine)
 {
        engine->submit_request = execlists_submit_request;
        engine->schedule = i915_schedule;
@@ -3124,9 +3124,6 @@ void intel_execlists_set_default_submission(struct intel_engine_cs *engine)
                }
        }
 
-       if (INTEL_GEN(engine->i915) >= 12)
-               engine->flags |= I915_ENGINE_HAS_RELATIVE_MMIO;
-
        if (intel_engine_has_preemption(engine))
                engine->emit_bb_start = gen8_emit_bb_start;
        else
@@ -3168,7 +3165,7 @@ logical_ring_default_vfuncs(struct intel_engine_cs *engine)
                engine->emit_fini_breadcrumb = gen12_emit_fini_breadcrumb_xcs;
                engine->emit_flush = gen12_emit_flush_xcs;
        }
-       engine->set_default_submission = intel_execlists_set_default_submission;
+       engine->set_default_submission = execlists_set_default_submission;
 
        if (INTEL_GEN(engine->i915) < 11) {
                engine->irq_enable = gen8_logical_ring_enable_irq;
@@ -3924,7 +3921,7 @@ bool
 intel_engine_in_execlists_submission_mode(const struct intel_engine_cs *engine)
 {
        return engine->set_default_submission ==
-              intel_execlists_set_default_submission;
+              execlists_set_default_submission;
 }
 
 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
index 0c675bb..a8fd7ad 100644 (file)
@@ -22,8 +22,6 @@ enum {
 
 int intel_execlists_submission_setup(struct intel_engine_cs *engine);
 
-void intel_execlists_set_default_submission(struct intel_engine_cs *engine);
-
 void intel_execlists_show_requests(struct intel_engine_cs *engine,
                                   struct drm_printer *m,
                                   void (*show_request)(struct drm_printer *m,
index b2615bb..23dc0ae 100644 (file)
@@ -10,7 +10,6 @@
 #include "gt/intel_breadcrumbs.h"
 #include "gt/intel_context.h"
 #include "gt/intel_engine_pm.h"
-#include "gt/intel_execlists_submission.h" /* XXX */
 #include "gt/intel_gt.h"
 #include "gt/intel_gt_pm.h"
 #include "gt/intel_lrc.h"
@@ -513,6 +512,34 @@ static int guc_request_alloc(struct i915_request *request)
        return 0;
 }
 
+static inline void queue_request(struct intel_engine_cs *engine,
+                                struct i915_request *rq,
+                                int prio)
+{
+       GEM_BUG_ON(!list_empty(&rq->sched.link));
+       list_add_tail(&rq->sched.link,
+                     i915_sched_lookup_priolist(engine, prio));
+       set_bit(I915_FENCE_FLAG_PQUEUE, &rq->fence.flags);
+}
+
+static void guc_submit_request(struct i915_request *rq)
+{
+       struct intel_engine_cs *engine = rq->engine;
+       unsigned long flags;
+
+       /* Will be called from irq-context when using foreign fences. */
+       spin_lock_irqsave(&engine->active.lock, flags);
+
+       queue_request(engine, rq, rq_prio(rq));
+
+       GEM_BUG_ON(RB_EMPTY_ROOT(&engine->execlists.queue.rb_root));
+       GEM_BUG_ON(list_empty(&rq->sched.link));
+
+       tasklet_hi_schedule(&engine->execlists.tasklet);
+
+       spin_unlock_irqrestore(&engine->active.lock, flags);
+}
+
 static void sanitize_hwsp(struct intel_engine_cs *engine)
 {
        struct intel_timeline *tl;
@@ -581,31 +608,28 @@ static int guc_resume(struct intel_engine_cs *engine)
 
 static void guc_set_default_submission(struct intel_engine_cs *engine)
 {
-       /*
-        * We inherit a bunch of functions from execlists that we'd like
-        * to keep using:
-        *
-        *    engine->submit_request = execlists_submit_request;
-        *    engine->cancel_requests = execlists_cancel_requests;
-        *    engine->schedule = execlists_schedule;
-        *
-        * But we need to override the actual submission backend in order
-        * to talk to the GuC.
-        */
-       intel_execlists_set_default_submission(engine);
-
+       engine->submit_request = guc_submit_request;
+       engine->schedule = i915_schedule;
        engine->execlists.tasklet.func = guc_submission_tasklet;
 
-       /* do not use execlists park/unpark */
-       engine->park = engine->unpark = NULL;
-
        engine->reset.prepare = guc_reset_prepare;
        engine->reset.rewind = guc_reset_rewind;
        engine->reset.cancel = guc_reset_cancel;
        engine->reset.finish = guc_reset_finish;
 
-       engine->flags &= ~I915_ENGINE_SUPPORTS_STATS;
        engine->flags |= I915_ENGINE_NEEDS_BREADCRUMB_TASKLET;
+       engine->flags |= I915_ENGINE_HAS_PREEMPTION;
+
+       /*
+        * TODO: GuC supports timeslicing and semaphores as well, but they're
+        * handled by the firmware so some minor tweaks are required before
+        * enabling.
+        *
+        * engine->flags |= I915_ENGINE_HAS_TIMESLICES;
+        * engine->flags |= I915_ENGINE_HAS_SEMAPHORES;
+        */
+
+       engine->emit_bb_start = gen8_emit_bb_start;
 
        /*
         * For the breadcrumb irq to work we need the interrupts to stay