]> git.hungrycats.org Git - linux/commitdiff
drm/xe/mmio: Check MMIO BAR size when initializing tiles
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 22 Jun 2026 13:23:41 +0000 (15:23 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 23 Jun 2026 17:16:42 +0000 (19:16 +0200)
We initialized all remote tiles' xe_mmio structures with a new size
of 4MiB and offsets of 16MiB without sanity checks to see if mapped
GTTMMADR_BAR was actually at least that size.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patch.msgid.link/20260622132342.19600-6-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_mmio.c

index 58226cd8b39933d6e2990dd1f5128d7bc189170a..41e6b753634fa5c3953585e7e136e203dd0825e8 100644 (file)
@@ -48,21 +48,35 @@ static void mmio_multi_tile_setup(struct xe_device *xe, size_t tile_mmio_size)
        struct xe_tile *tile;
        u8 id;
 
-       /*
-        * Nothing to be done as tile 0 has already been setup earlier with the
-        * entire BAR mapped - see xe_mmio_probe_early()
-        */
-       if (xe->info.tile_count == 1)
-               return;
-
        for_each_remote_tile(tile, xe, id)
                xe_mmio_init(&tile->mmio, tile, xe->mmio.regs + id * tile_mmio_size, SZ_4M);
 }
 
+/**
+ * xe_mmio_probe_tiles() - Initialize all tiles' MMIO
+ * @xe: the &xe_device
+ *
+ * Initialize the remaining tiles' MMIO instances.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
 int xe_mmio_probe_tiles(struct xe_device *xe)
 {
        size_t tile_mmio_size = SZ_16M;
 
+       /*
+        * Nothing to be done as tile 0 has already been setup earlier with the
+        * entire BAR mapped - see xe_mmio_probe_early()
+        */
+       if (xe->info.tile_count == 1)
+               return 0;
+
+       if (xe->mmio.size < xe->info.tile_count * tile_mmio_size) {
+               xe_err(xe, "GTTMMADR_BAR is too small for %d tiles: %zu\n",
+                      xe->info.tile_count, xe->mmio.size);
+               return -EIO;
+       }
+
        mmio_multi_tile_setup(xe, tile_mmio_size);
        return 0;
 }