]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/xe/mmio: move mmio_fini over to devm
authorMatthew Auld <matthew.auld@intel.com>
Wed, 22 May 2024 10:21:57 +0000 (11:21 +0100)
committerMatthew Auld <matthew.auld@intel.com>
Wed, 22 May 2024 12:22:40 +0000 (13:22 +0100)
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 <matthew.auld@intel.com>
Cc: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240522102143.128069-32-matthew.auld@intel.com
drivers/gpu/drm/xe/xe_mmio.c

index 548dc37e5893de8478f8e1d9ed15fe0cd32c2d3c..a87961ac6359d88488c8c24722b8e9e36595588a 100644 (file)
@@ -390,13 +390,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;
 }
 
 int xe_mmio_init(struct xe_device *xe)
@@ -421,7 +424,7 @@ int xe_mmio_init(struct xe_device *xe)
        root_tile->mmio.size = SZ_16M;
        root_tile->mmio.regs = xe->mmio.regs;
 
-       return drmm_add_action_or_reset(&xe->drm, mmio_fini, xe);
+       return devm_add_action_or_reset(xe->drm.dev, mmio_fini, xe);
 }
 
 u8 xe_mmio_read8(struct xe_gt *gt, struct xe_reg reg)