drm/i915/xelpg: Call Xe_LPG workaround functions based on IP version
authorjsg <jsg@openbsd.org>
Thu, 11 Apr 2024 03:06:59 +0000 (03:06 +0000)
committerjsg <jsg@openbsd.org>
Thu, 11 Apr 2024 03:06:59 +0000 (03:06 +0000)
From Matt Roper
18e77951e14a73f75d269e54b90c648b1e18b66e in linux-6.6.y/6.6.26
f7696ded7c9e358670dae1801660f442f059c7db in mainline linux

sys/dev/pci/drm/i915/gt/intel_gt.h
sys/dev/pci/drm/i915/gt/intel_workarounds.c

index 6c34547..15c2598 100644 (file)
 struct drm_i915_private;
 struct drm_printer;
 
+/*
+ * Check that the GT is a graphics GT and has an IP version within the
+ * specified range (inclusive).
+ */
+#define IS_GFX_GT_IP_RANGE(gt, from, until) ( \
+       BUILD_BUG_ON_ZERO((from) < IP_VER(2, 0)) + \
+       BUILD_BUG_ON_ZERO((until) < (from)) + \
+       ((gt)->type != GT_MEDIA && \
+        GRAPHICS_VER_FULL((gt)->i915) >= (from) && \
+        GRAPHICS_VER_FULL((gt)->i915) <= (until)))
+
 #define GT_TRACE(gt, fmt, ...) do {                                    \
        const struct intel_gt *gt__ __maybe_unused = (gt);              \
        GEM_TRACE("%s " fmt, dev_name(gt__->i915->drm.dev),             \
index 69973dc..4c24f38 100644 (file)
@@ -781,8 +781,8 @@ static void dg2_ctx_workarounds_init(struct intel_engine_cs *engine,
        wa_masked_en(wal, CACHE_MODE_1, MSAA_OPTIMIZATION_REDUC_DISABLE);
 }
 
-static void mtl_ctx_gt_tuning_init(struct intel_engine_cs *engine,
-                                  struct i915_wa_list *wal)
+static void xelpg_ctx_gt_tuning_init(struct intel_engine_cs *engine,
+                                    struct i915_wa_list *wal)
 {
        struct drm_i915_private *i915 = engine->i915;
 
@@ -793,12 +793,12 @@ static void mtl_ctx_gt_tuning_init(struct intel_engine_cs *engine,
                wa_add(wal, DRAW_WATERMARK, VERT_WM_VAL, 0x3FF, 0, false);
 }
 
-static void mtl_ctx_workarounds_init(struct intel_engine_cs *engine,
-                                    struct i915_wa_list *wal)
+static void xelpg_ctx_workarounds_init(struct intel_engine_cs *engine,
+                                      struct i915_wa_list *wal)
 {
        struct drm_i915_private *i915 = engine->i915;
 
-       mtl_ctx_gt_tuning_init(engine, wal);
+       xelpg_ctx_gt_tuning_init(engine, wal);
 
        if (IS_MTL_GRAPHICS_STEP(i915, M, STEP_A0, STEP_B0) ||
            IS_MTL_GRAPHICS_STEP(i915, P, STEP_A0, STEP_B0)) {
@@ -907,8 +907,8 @@ __intel_engine_init_ctx_wa(struct intel_engine_cs *engine,
        if (engine->class != RENDER_CLASS)
                goto done;
 
-       if (IS_METEORLAKE(i915))
-               mtl_ctx_workarounds_init(engine, wal);
+       if (IS_GFX_GT_IP_RANGE(engine->gt, IP_VER(12, 70), IP_VER(12, 71)))
+               xelpg_ctx_workarounds_init(engine, wal);
        else if (IS_PONTEVECCHIO(i915))
                ; /* noop; none at this time */
        else if (IS_DG2(i915))
@@ -1688,10 +1688,8 @@ xelpmp_gt_workarounds_init(struct intel_gt *gt, struct i915_wa_list *wal)
  */
 static void gt_tuning_settings(struct intel_gt *gt, struct i915_wa_list *wal)
 {
-       if (IS_METEORLAKE(gt->i915)) {
-               if (gt->type != GT_MEDIA)
-                       wa_mcr_write_or(wal, XEHP_L3SCQREG7, BLEND_FILL_CACHING_OPT_DIS);
-
+       if (IS_GFX_GT_IP_RANGE(gt, IP_VER(12, 70), IP_VER(12, 71))) {
+               wa_mcr_write_or(wal, XEHP_L3SCQREG7, BLEND_FILL_CACHING_OPT_DIS);
                wa_mcr_write_or(wal, XEHP_SQCM, EN_32B_ACCESS);
        }
 
@@ -1723,7 +1721,7 @@ gt_init_workarounds(struct intel_gt *gt, struct i915_wa_list *wal)
                return;
        }
 
-       if (GRAPHICS_VER_FULL(i915) >= IP_VER(12, 70))
+       if (IS_GFX_GT_IP_RANGE(gt, IP_VER(12, 70), IP_VER(12, 71)))
                xelpg_gt_workarounds_init(gt, wal);
        else if (IS_PONTEVECCHIO(i915))
                pvc_gt_workarounds_init(gt, wal);
@@ -2172,7 +2170,7 @@ static void pvc_whitelist_build(struct intel_engine_cs *engine)
        blacklist_trtt(engine);
 }
 
-static void mtl_whitelist_build(struct intel_engine_cs *engine)
+static void xelpg_whitelist_build(struct intel_engine_cs *engine)
 {
        struct i915_wa_list *w = &engine->whitelist;
 
@@ -2194,8 +2192,10 @@ void intel_engine_init_whitelist(struct intel_engine_cs *engine)
 
        wa_init_start(w, engine->gt, "whitelist", engine->name);
 
-       if (IS_METEORLAKE(i915))
-               mtl_whitelist_build(engine);
+       if (engine->gt->type == GT_MEDIA)
+               ; /* none yet */
+       else if (IS_GFX_GT_IP_RANGE(engine->gt, IP_VER(12, 70), IP_VER(12, 71)))
+               xelpg_whitelist_build(engine);
        else if (IS_PONTEVECCHIO(i915))
                pvc_whitelist_build(engine);
        else if (IS_DG2(i915))
@@ -2795,10 +2795,12 @@ ccs_engine_wa_init(struct intel_engine_cs *engine, struct i915_wa_list *wal)
  * function invoked by __intel_engine_init_ctx_wa().
  */
 static void
-add_render_compute_tuning_settings(struct drm_i915_private *i915,
+add_render_compute_tuning_settings(struct intel_gt *gt,
                                   struct i915_wa_list *wal)
 {
-       if (IS_METEORLAKE(i915) || IS_DG2(i915))
+       struct drm_i915_private *i915 = gt->i915;
+
+       if (IS_GFX_GT_IP_RANGE(gt, IP_VER(12, 70), IP_VER(12, 71)) || IS_DG2(i915))
                wa_mcr_write_clr_set(wal, RT_CTRL, STACKID_CTRL, STACKID_CTRL_512);
 
        /*
@@ -2828,7 +2830,7 @@ general_render_compute_wa_init(struct intel_engine_cs *engine, struct i915_wa_li
 {
        struct drm_i915_private *i915 = engine->i915;
 
-       add_render_compute_tuning_settings(i915, wal);
+       add_render_compute_tuning_settings(engine->gt, wal);
 
        if (GRAPHICS_VER(i915) >= 11) {
                /* This is not a Wa (although referred to as