drm/xe/pci: Convert register access to use xe_mmio
authorMatt Roper <matthew.d.roper@intel.com>
Tue, 10 Sep 2024 23:47:38 +0000 (16:47 -0700)
committerMatt Roper <matthew.d.roper@intel.com>
Wed, 11 Sep 2024 22:32:49 +0000 (15:32 -0700)
Stop using GT pointers for register access.

v2:
 - Clarify comment about manual GSI offset handling.  (Rodrigo)

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240910234719.3335472-63-matthew.d.roper@intel.com
drivers/gpu/drm/xe/xe_pci.c

index d045ea6..a1d08e2 100644 (file)
@@ -468,13 +468,15 @@ enum xe_gmdid_type {
 
 static void read_gmdid(struct xe_device *xe, enum xe_gmdid_type type, u32 *ver, u32 *revid)
 {
-       struct xe_gt *gt = xe_root_mmio_gt(xe);
+       struct xe_mmio *mmio = xe_root_tile_mmio(xe);
        struct xe_reg gmdid_reg = GMD_ID;
        u32 val;
 
        KUNIT_STATIC_STUB_REDIRECT(read_gmdid, xe, type, ver, revid);
 
        if (IS_SRIOV_VF(xe)) {
+               struct xe_gt *gt = xe_root_mmio_gt(xe);
+
                /*
                 * To get the value of the GMDID register, VFs must obtain it
                 * from the GuC using MMIO communication.
@@ -510,14 +512,17 @@ static void read_gmdid(struct xe_device *xe, enum xe_gmdid_type type, u32 *ver,
                gt->info.type = XE_GT_TYPE_UNINITIALIZED;
        } else {
                /*
-                * We need to apply the GSI offset explicitly here as at this
-                * point the xe_gt is not fully uninitialized and only basic
-                * access to MMIO registers is possible.
+                * GMD_ID is a GT register, but at this point in the driver
+                * init we haven't fully initialized the GT yet so we need to
+                * read the register with the tile's MMIO accessor.  That means
+                * we need to apply the GSI offset manually since it won't get
+                * automatically added as it would if we were using a GT mmio
+                * accessor.
                 */
                if (type == GMDID_MEDIA)
                        gmdid_reg.addr += MEDIA_GT_GSI_OFFSET;
 
-               val = xe_mmio_read32(gt, gmdid_reg);
+               val = xe_mmio_read32(mmio, gmdid_reg);
        }
 
        *ver = REG_FIELD_GET(GMD_ID_ARCH_MASK, val) * 100 + REG_FIELD_GET(GMD_ID_RELEASE_MASK, val);