summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Wajdeczko <michal.wajdeczko@intel.com>2026-06-22 15:23:41 +0200
committerMichal Wajdeczko <michal.wajdeczko@intel.com>2026-06-23 19:16:42 +0200
commit699ca9d4ec71e74c40e394bfa7616b56c82279fa (patch)
tree6f85764727b1cd8741377e96488f065cdf5d3d3f
parent82b117980acdc1651b51ccb1f2af6becb350daf7 (diff)
downloadlinux-699ca9d4ec71e74c40e394bfa7616b56c82279fa.tar.gz
linux-699ca9d4ec71e74c40e394bfa7616b56c82279fa.zip
drm/xe/mmio: Check MMIO BAR size when initializing tiles
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
-rw-r--r--drivers/gpu/drm/xe/xe_mmio.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/drivers/gpu/drm/xe/xe_mmio.c b/drivers/gpu/drm/xe/xe_mmio.c
index 58226cd8b399..41e6b753634f 100644
--- a/drivers/gpu/drm/xe/xe_mmio.c
+++ b/drivers/gpu/drm/xe/xe_mmio.c
@@ -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;
}