drm/xe: Add Wa_14019821291
authorMatt Roper <matthew.d.roper@intel.com>
Thu, 2 Nov 2023 12:48:55 +0000 (05:48 -0700)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 21 Dec 2023 16:43:33 +0000 (11:43 -0500)
This workaround is primarily implemented by the BIOS.  However if the
BIOS applies the workaround it will reserve a small piece of our DSM
(which should be at the top, right below the WOPCM); we just need to
keep that region reserved so that nothing else attempts to re-use it.

v2 (Gustavo):
  - Check for NULL media_gt
  - Mask bits [5:0] to avoid potential issues in future platforms

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>
Link: https://lore.kernel.org/r/20231102124855.1940491-1-lucas.demarchi@intel.com
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/Makefile
drivers/gpu/drm/xe/regs/xe_gt_regs.h
drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
drivers/gpu/drm/xe/xe_wa_oob.rules

index 32eee57..1d39784 100644 (file)
@@ -40,7 +40,7 @@ quiet_cmd_wa_oob = GEN     $(notdir $(generated_oob))
 $(generated_oob) &: $(obj)/xe_gen_wa_oob $(srctree)/$(src)/xe_wa_oob.rules
        $(call cmd,wa_oob)
 
-$(obj)/xe_guc.o $(obj)/xe_migrate.o $(obj)/xe_ring_ops.o $(obj)/xe_vm.o $(obj)/xe_wa.o: $(generated_oob)
+$(obj)/xe_guc.o $(obj)/xe_migrate.o $(obj)/xe_ring_ops.o $(obj)/xe_vm.o $(obj)/xe_wa.o $(obj)/xe_ttm_stolen_mgr.o: $(generated_oob)
 
 # Please keep these build lists sorted!
 
index 7a6407e..902c605 100644 (file)
 #define XEHP_SQCM                              XE_REG_MCR(0x8724)
 #define   EN_32B_ACCESS                                REG_BIT(30)
 
+#define GSCPSMI_BASE                           XE_REG(0x880c)
+
 #define        MIRROR_FUSE3                            XE_REG(0x9118)
 #define   XE2_NODE_ENABLE_MASK                 REG_GENMASK(31, 16)
 #define   L3BANK_PAIR_COUNT                    4
index 79fbd74..0c533d3 100644 (file)
@@ -11,6 +11,8 @@
 #include <drm/ttm/ttm_placement.h>
 #include <drm/ttm/ttm_range_manager.h>
 
+#include "generated/xe_wa_oob.h"
+#include "regs/xe_gt_regs.h"
 #include "regs/xe_regs.h"
 #include "xe_bo.h"
 #include "xe_device.h"
@@ -19,6 +21,7 @@
 #include "xe_res_cursor.h"
 #include "xe_ttm_stolen_mgr.h"
 #include "xe_ttm_vram_mgr.h"
+#include "xe_wa.h"
 
 struct xe_ttm_stolen_mgr {
        struct xe_ttm_vram_mgr base;
@@ -112,6 +115,7 @@ static u32 get_wopcm_size(struct xe_device *xe)
 static u32 detect_bar2_integrated(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
 {
        struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
+       struct xe_gt *media_gt = xe_device_get_root_tile(xe)->media_gt;
        u32 stolen_size, wopcm_size;
        u32 ggc, gms;
 
@@ -154,6 +158,27 @@ static u32 detect_bar2_integrated(struct xe_device *xe, struct xe_ttm_stolen_mgr
 
        stolen_size -= wopcm_size;
 
+       if (media_gt && XE_WA(media_gt, 14019821291)) {
+               u64 gscpsmi_base = xe_mmio_read64_2x32(media_gt, GSCPSMI_BASE)
+                       & ~GENMASK_ULL(5, 0);
+
+               /*
+                * This workaround is primarily implemented by the BIOS.  We
+                * just need to figure out whether the BIOS has applied the
+                * workaround (meaning the programmed address falls within
+                * the DSM) and, if so, reserve that part of the DSM to
+                * prevent accidental reuse.  The DSM location should be just
+                * below the WOPCM.
+                */
+               if (gscpsmi_base >= mgr->io_base &&
+                   gscpsmi_base < mgr->io_base + stolen_size) {
+                       xe_gt_dbg(media_gt,
+                                 "Reserving %llu bytes of DSM for Wa_14019821291\n",
+                                 mgr->io_base + stolen_size - gscpsmi_base);
+                       stolen_size = gscpsmi_base - mgr->io_base;
+               }
+       }
+
        if (drm_WARN_ON(&xe->drm, stolen_size + SZ_8M > pci_resource_len(pdev, 2)))
                return 0;
 
index f3ff774..752842d 100644 (file)
@@ -19,3 +19,4 @@
                SUBPLATFORM(DG2, G12)
 16017236439    PLATFORM(PVC)
 22010954014    PLATFORM(DG2)
+14019821291    MEDIA_VERSION_RANGE(1300, 2000)