]> git.hungrycats.org Git - linux/commitdiff
drm/xe/mmio: Map MMIO BAR using managed version of pci_iomap
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 22 Jun 2026 13:23:38 +0000 (15:23 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 23 Jun 2026 17:13:41 +0000 (19:13 +0200)
This will allow us to simplify our custom release action where we
will keep only zeroing of the xe->mmio.regs as we still rely on it
all checks during all xe_mmio operations. While around, add missing
kernel-doc for the function and update the error message.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patch.msgid.link/20260622132342.19600-3-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_mmio.c

index 7e0cefcd16bdef67097f84679a9d640f74555cf9..fce890b6410c78b20fb7866c35ec9846218b7957 100644 (file)
@@ -16,6 +16,7 @@
 #include "regs/xe_bars.h"
 #include "xe_device.h"
 #include "xe_gt_sriov_vf.h"
+#include "xe_printk.h"
 #include "xe_sriov.h"
 #include "xe_tile_printk.h"
 #include "xe_trace.h"
@@ -80,27 +81,30 @@ int xe_mmio_probe_tiles(struct xe_device *xe)
 static void mmio_fini(void *arg)
 {
        struct xe_device *xe = arg;
-       struct xe_tile *root_tile = xe_device_get_root_tile(xe);
 
-       pci_iounmap(to_pci_dev(xe->drm.dev), xe->mmio.regs);
        xe->mmio.regs = NULL;
-       root_tile->mmio.regs = NULL;
 }
 
+/**
+ * xe_mmio_probe_early() - Probe and initialize device's MMIO
+ * @xe: the &xe_device
+ *
+ * Map the entire GTTMMADR_BAR and initialize the first tile's MMIO instance.
+ *
+ * The first 16MB of the GTTMMADR_BAR always belongs to the root tile, and
+ * includes: registers (0-4MB), reserved space (4MB-8MB) and GGTT (8MB-16MB).
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
 int xe_mmio_probe_early(struct xe_device *xe)
 {
        struct xe_tile *root_tile = xe_device_get_root_tile(xe);
        struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
 
-       /*
-        * Map the entire BAR.
-        * The first 16MB of the BAR, belong to the root tile, and include:
-        * registers (0-4MB), reserved space (4MB-8MB) and GGTT (8MB-16MB).
-        */
        xe->mmio.size = pci_resource_len(pdev, GTTMMADR_BAR);
-       xe->mmio.regs = pci_iomap(pdev, GTTMMADR_BAR, 0);
+       xe->mmio.regs = pcim_iomap(pdev, GTTMMADR_BAR, 0);
        if (!xe->mmio.regs) {
-               drm_err(&xe->drm, "failed to map registers\n");
+               xe_err(xe, "Failed to map GTTMMADR_BAR\n");
                return -EIO;
        }