drm/xe: Restrict huge PTEs to 1GiB
authorThomas Hellström <thomas.hellstrom@linux.intel.com>
Sat, 9 Dec 2023 15:18:41 +0000 (16:18 +0100)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 21 Dec 2023 16:45:28 +0000 (11:45 -0500)
Add a define for the highest level for which we can encode a huge PTE,
and use it for page-table building. Also update an assert that checks that
we don't try to encode for larger sizes.

Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Brian Welty <brian.welty@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231209151843.7903-2-thomas.hellstrom@linux.intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_pt.c
drivers/gpu/drm/xe/xe_pt.h
drivers/gpu/drm/xe/xe_vm.c

index 3b485313804aa2731d607bd6a5c2bfcfc5261697..46ef9df34a2e3ed64caea9c577c0c85ba3ee8e82 100644 (file)
@@ -430,6 +430,9 @@ static bool xe_pt_hugepte_possible(u64 addr, u64 next, unsigned int level,
 {
        u64 size, dma;
 
+       if (level > MAX_HUGEPTE_LEVEL)
+               return false;
+
        /* Does the virtual range requested cover a huge pte? */
        if (!xe_pt_covers(addr, next, level, &xe_walk->base))
                return false;
index d5460e58dbbf9d18e977c20cd9bb6f6946127223..ba2f3325c84de7570592538a265d1159d32bdcf7 100644 (file)
@@ -18,6 +18,9 @@ struct xe_tile;
 struct xe_vm;
 struct xe_vma;
 
+/* Largest huge pte is currently 1GiB. May become device dependent. */
+#define MAX_HUGEPTE_LEVEL 2
+
 #define xe_pt_write(xe, map, idx, data) \
        xe_map_wr(xe, map, (idx) * sizeof(u64), u64, data)
 
index 11667529e40be3128e6891d4a2aeb816cb2b19f5..d589beb99fe69cbb43e01b1aa4220b5d876e3a05 100644 (file)
@@ -1258,7 +1258,7 @@ static u64 pte_encode_pat_index(struct xe_device *xe, u16 pat_index,
 
 static u64 pte_encode_ps(u32 pt_level)
 {
-       XE_WARN_ON(pt_level > 2);
+       XE_WARN_ON(pt_level > MAX_HUGEPTE_LEVEL);
 
        if (pt_level == 1)
                return XE_PDE_PS_2M;