drm/xe/mtl: Map PPGTT as CPU:WC
authorMatt Roper <matthew.d.roper@intel.com>
Tue, 25 Jul 2023 00:34:34 +0000 (17:34 -0700)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 21 Dec 2023 16:37:54 +0000 (11:37 -0500)
On MTL and beyond, the GPU performs non-coherent accesses to the PPGTT
page tables.  These page tables should be mapped as CPU:WC.

Removes CAT errors triggered by xe_exec_basic@once-basic on MTL:

   xe 0000:00:02.0: [drm:__xe_pt_bind_vma [xe]] Preparing bind, with range [1a0000...1a0fff) engine 0000000000000000.
   xe 0000:00:02.0: [drm:xe_vm_dbg_print_entries [xe]] 1 entries to update
   xe 0000:00:02.0: [drm:xe_vm_dbg_print_entries [xe]]  0: Update level 3 at (0 + 1) [0...8000000000) f:0
   xe 0000:00:02.0: [drm] Engine memory cat error: guc_id=2
   xe 0000:00:02.0: [drm] Engine memory cat error: guc_id=2
   xe 0000:00:02.0: [drm] Timedout job: seqno=4294967169, guc_id=2, flags=0x4

v2:
 - Rename to XE_BO_PAGETABLE to make it more clear that this BO is the
   pagetable itself, rather than just being bound in the PPGTT.  (Lucas)

Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Acked-by: Nirmoy Das <nirmoy.das@intel.com>
Link: https://lore.kernel.org/r/20230725003433.1992137-3-matthew.d.roper@intel.com
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_bo.c
drivers/gpu/drm/xe/xe_bo.h
drivers/gpu/drm/xe/xe_pt.c

index a78ac158e967ecb30eba1269c6801d943293da4b..4b7678db88f397dc029381aa73f65ceed3369388 100644 (file)
@@ -301,6 +301,7 @@ static struct ttm_tt *xe_ttm_tt_create(struct ttm_buffer_object *ttm_bo,
        struct xe_device *xe = xe_bo_device(bo);
        struct xe_ttm_tt *tt;
        unsigned long extra_pages;
+       enum ttm_caching caching = ttm_cached;
        int err;
 
        tt = kzalloc(sizeof(*tt), GFP_KERNEL);
@@ -314,10 +315,17 @@ static struct ttm_tt *xe_ttm_tt_create(struct ttm_buffer_object *ttm_bo,
                extra_pages = DIV_ROUND_UP(xe_device_ccs_bytes(xe, bo->size),
                                           PAGE_SIZE);
 
-       /* TODO: Select caching mode */
-       err = ttm_tt_init(&tt->ttm, &bo->ttm, page_flags,
-                         bo->flags & XE_BO_SCANOUT_BIT ? ttm_write_combined : ttm_cached,
-                         extra_pages);
+       /*
+        * Display scanout is always non-coherent with the CPU cache.
+        *
+        * For Xe_LPG and beyond, PPGTT PTE lookups are also non-coherent and
+        * require a CPU:WC mapping.
+        */
+       if (bo->flags & XE_BO_SCANOUT_BIT ||
+           (xe->info.graphics_verx100 >= 1270 && bo->flags & XE_BO_PAGETABLE))
+               caching = ttm_write_combined;
+
+       err = ttm_tt_init(&tt->ttm, &bo->ttm, page_flags, caching, extra_pages);
        if (err) {
                kfree(tt);
                return NULL;
index 3e98f3c0b85e47486794c3866dda7516d08c21c5..12a291925fa9505e0963159986b31bcd3fb74cf1 100644 (file)
@@ -40,6 +40,7 @@
 #define XE_BO_DEFER_BACKING            BIT(9)
 #define XE_BO_SCANOUT_BIT              BIT(10)
 #define XE_BO_FIXED_PLACEMENT_BIT      BIT(11)
+#define XE_BO_PAGETABLE                        BIT(12)
 /* this one is trigger internally only */
 #define XE_BO_INTERNAL_TEST            BIT(30)
 #define XE_BO_INTERNAL_64K             BIT(31)
index d2df51910010803299db31e6635fa27fdc5bd3f6..48a87b50a040d50bd96d80c09827d4c3c9986111 100644 (file)
@@ -221,7 +221,8 @@ struct xe_pt *xe_pt_create(struct xe_vm *vm, struct xe_tile *tile,
                                  XE_BO_CREATE_VRAM_IF_DGFX(tile) |
                                  XE_BO_CREATE_IGNORE_MIN_PAGE_SIZE_BIT |
                                  XE_BO_CREATE_PINNED_BIT |
-                                 XE_BO_CREATE_NO_RESV_EVICT);
+                                 XE_BO_CREATE_NO_RESV_EVICT |
+                                 XE_BO_PAGETABLE);
        if (IS_ERR(bo)) {
                err = PTR_ERR(bo);
                goto err_kfree;