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
This commit is contained in:
Michal Wajdeczko
2026-06-22 15:23:41 +02:00
parent 82b117980a
commit 699ca9d4ec

View File

@@ -48,20 +48,34 @@ static void mmio_multi_tile_setup(struct xe_device *xe, size_t tile_mmio_size)
struct xe_tile *tile;
u8 id;
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;
return 0;
for_each_remote_tile(tile, xe, id)
xe_mmio_init(&tile->mmio, tile, xe->mmio.regs + id * tile_mmio_size, SZ_4M);
}
int xe_mmio_probe_tiles(struct xe_device *xe)
{
size_t tile_mmio_size = SZ_16M;
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;