drm/i915/xehp: Define context scheduling attributes in lrc descriptor
authorMatt Roper <matthew.d.roper@intel.com>
Tue, 1 Mar 2022 23:15:43 +0000 (15:15 -0800)
committerMatt Roper <matthew.d.roper@intel.com>
Wed, 2 Mar 2022 14:45:21 +0000 (06:45 -0800)
In Dual Context mode the EUs are shared between render and compute
command streamers. The hardware provides a field in the lrc descriptor
to indicate the prioritization of the thread dispatch associated to the
corresponding context.

The context priority is set to 'low' at creation time and relies on the
existing context priority to set it to low/normal/high.

Bspec: 46145, 46260
Original-author: Michel Thierry
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Signed-off-by: Aravind Iddamsetty <aravind.iddamsetty@intel.com>
Signed-off-by: Prasad Nallani <prasad.nallani@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220301231549.1817978-8-matthew.d.roper@intel.com
drivers/gpu/drm/i915/gt/intel_engine_cs.c
drivers/gpu/drm/i915/gt/intel_engine_types.h
drivers/gpu/drm/i915/gt/intel_execlists_submission.c
drivers/gpu/drm/i915/gt/intel_lrc.h

index b0982a9..2136c56 100644 (file)
@@ -435,8 +435,10 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id,
                engine->props.preempt_timeout_ms = 0;
 
        /* features common between engines sharing EUs */
-       if (engine->class == RENDER_CLASS || engine->class == COMPUTE_CLASS)
+       if (engine->class == RENDER_CLASS || engine->class == COMPUTE_CLASS) {
                engine->flags |= I915_ENGINE_HAS_RCS_REG_STATE;
+               engine->flags |= I915_ENGINE_HAS_EU_PRIORITY;
+       }
 
        engine->defaults = engine->props; /* never to change again */
 
index 5fa5f21..19ff875 100644 (file)
@@ -525,6 +525,7 @@ struct intel_engine_cs {
 #define I915_ENGINE_REQUIRES_CMD_PARSER BIT(7)
 #define I915_ENGINE_WANT_FORCED_PREEMPTION BIT(8)
 #define I915_ENGINE_HAS_RCS_REG_STATE  BIT(9)
+#define I915_ENGINE_HAS_EU_PRIORITY    BIT(10)
        unsigned int flags;
 
        /*
index 47fca5e..c8407cc 100644 (file)
@@ -665,9 +665,13 @@ static inline void execlists_schedule_out(struct i915_request *rq)
 static u64 execlists_update_context(struct i915_request *rq)
 {
        struct intel_context *ce = rq->context;
-       u64 desc = ce->lrc.desc;
+       u64 desc;
        u32 tail, prev;
 
+       desc = ce->lrc.desc;
+       if (rq->engine->flags & I915_ENGINE_HAS_EU_PRIORITY)
+               desc |= lrc_desc_priority(rq_prio(rq));
+
        /*
         * WaIdleLiteRestore:bdw,skl
         *
index bb0e6c5..6e4f9f5 100644 (file)
@@ -6,6 +6,9 @@
 #ifndef __INTEL_LRC_H__
 #define __INTEL_LRC_H__
 
+#include "i915_priolist_types.h"
+
+#include <linux/bitfield.h>
 #include <linux/types.h>
 
 struct drm_i915_gem_object;
@@ -90,6 +93,10 @@ enum {
 #define GEN8_CTX_L3LLC_COHERENT                        (1 << 5)
 #define GEN8_CTX_PRIVILEGE                     (1 << 8)
 #define GEN8_CTX_ADDRESSING_MODE_SHIFT         3
+#define GEN12_CTX_PRIORITY_MASK                        GENMASK(10, 9)
+#define GEN12_CTX_PRIORITY_HIGH                        FIELD_PREP(GEN12_CTX_PRIORITY_MASK, 2)
+#define GEN12_CTX_PRIORITY_NORMAL              FIELD_PREP(GEN12_CTX_PRIORITY_MASK, 1)
+#define GEN12_CTX_PRIORITY_LOW                 FIELD_PREP(GEN12_CTX_PRIORITY_MASK, 0)
 #define GEN8_CTX_ID_SHIFT                      32
 #define GEN8_CTX_ID_WIDTH                      21
 #define GEN11_SW_CTX_ID_SHIFT                  37
@@ -103,4 +110,14 @@ enum {
 #define XEHP_SW_COUNTER_SHIFT                  58
 #define XEHP_SW_COUNTER_WIDTH                  6
 
+static inline u32 lrc_desc_priority(int prio)
+{
+       if (prio > I915_PRIORITY_NORMAL)
+               return GEN12_CTX_PRIORITY_HIGH;
+       else if (prio < I915_PRIORITY_NORMAL)
+               return GEN12_CTX_PRIORITY_LOW;
+       else
+               return GEN12_CTX_PRIORITY_NORMAL;
+}
+
 #endif /* __INTEL_LRC_H__ */