From 9720a035fff9e938e883907ae4dacf1cae49cd01 Mon Sep 17 00:00:00 2001 From: Matthew Auld Date: Wed, 22 May 2024 11:21:57 +0100 Subject: [PATCH] drm/xe/mmio: move mmio_fini over to devm BugLink: https://bugs.launchpad.net/bugs/2084005 [ Upstream commit a0b834c8957a7d2848face008a12382a0ad11ffc ] Not valid to touch mmio once the device is removed, so make sure we unmap on removal and not just when driver instance goes away. Also set the mmio pointers to NULL to hopefully catch such issues more easily. Signed-off-by: Matthew Auld Cc: Andrzej Hajda Cc: Rodrigo Vivi Reviewed-by: Andrzej Hajda Link: https://patchwork.freedesktop.org/patch/msgid/20240522102143.128069-32-matthew.auld@intel.com Stable-dep-of: 15939ca77d44 ("drm/xe: Fix tile fini sequence") Signed-off-by: Sasha Levin Signed-off-by: Koichiro Den Signed-off-by: Stefan Bader --- drivers/gpu/drm/xe/xe_mmio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_mmio.c b/drivers/gpu/drm/xe/xe_mmio.c index 02f7808f28ca..5738f8fdce2c 100644 --- a/drivers/gpu/drm/xe/xe_mmio.c +++ b/drivers/gpu/drm/xe/xe_mmio.c @@ -350,13 +350,16 @@ add_mmio_ext: } } -static void mmio_fini(struct drm_device *drm, void *arg) +static void mmio_fini(void *arg) { struct xe_device *xe = arg; pci_iounmap(to_pci_dev(xe->drm.dev), xe->mmio.regs); if (xe->mem.vram.mapping) iounmap(xe->mem.vram.mapping); + + xe->mem.vram.mapping = NULL; + xe->mmio.regs = NULL; } static int xe_verify_lmem_ready(struct xe_device *xe) @@ -394,7 +397,7 @@ int xe_mmio_init(struct xe_device *xe) return -EIO; } - return drmm_add_action_or_reset(&xe->drm, mmio_fini, xe); + return devm_add_action_or_reset(xe->drm.dev, mmio_fini, xe); } int xe_mmio_root_tile_init(struct xe_device *xe)