From: Michal Wajdeczko Date: Mon, 22 Jun 2026 13:23:41 +0000 (+0200) Subject: drm/xe/mmio: Check MMIO BAR size when initializing tiles X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=699ca9d4ec71e74c40e394bfa7616b56c82279fa;p=linux 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 Reviewed-by: Matthew Auld Link: https://patch.msgid.link/20260622132342.19600-6-michal.wajdeczko@intel.com --- diff --git a/drivers/gpu/drm/xe/xe_mmio.c b/drivers/gpu/drm/xe/xe_mmio.c index 58226cd8b3993..41e6b753634fa 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; }