Skip to contentSkip to conversation

drm/xe: Store GMD_ID subunit during GT init

PATCH Superseded Pallavi Mishra 1 participant 3 messages Nov 9

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover drm/xe: Store GMD_ID subunit during GT init

Replace the separate GMD_ID and subunit fields with struct xe_gmdid, then initialize that struct from the value already read during probe.

This is v3 of:

https://patchwork.freedesktop.org/patch/763681/

v2:
- Store GMD_ID in struct xe_gmdid instead of a u32 plus a separate subip field.(Gustavo)
- Initialize the struct from xe_probed_info in xe_info_init() instead of reading GMD_ID again during GT init.(Gustavo)

v3:
- Rebase.

Pallavi Mishra (2):
drm/xe: Store GMD_ID as a struct
drm/xe: Initialize GT GMD_ID from probed info

 drivers/gpu/drm/xe/xe_device.c   |  6 ++--
 drivers/gpu/drm/xe/xe_gt.c       |  6 ----
 drivers/gpu/drm/xe/xe_gt_types.h | 17 +++++++++--
 drivers/gpu/drm/xe/xe_guc.c      | 12 ++++----
 drivers/gpu/drm/xe/xe_pci.c      | 50 +++++++++++++++++++++++++-------
 drivers/gpu/drm/xe/xe_query.c    | 11 ++++---
 6 files changed, 68 insertions(+), 34 deletions(-)

base-commit: d72707a042b6aff601449a9cf87e5fe55decbc5c

Signature · 1 line
2.43.0
#1 lore raw

PATCH v3 1/2 drm/xe: Store GMD_ID as a struct

Replace gt->info.gmdid with struct xe_gmdid so the register value and subunit stay together. Read GMD_ID once before GuC upload and use the stored subunit instead of another MMIO read. Platforms without the register store zero.

---
 drivers/gpu/drm/xe/xe_device.c   |  6 +++---
 drivers/gpu/drm/xe/xe_gt.c       | 21 +++++++++++++++------
 drivers/gpu/drm/xe/xe_gt_types.h | 17 +++++++++++++++--
 drivers/gpu/drm/xe/xe_guc.c      | 12 +++++-------
 drivers/gpu/drm/xe/xe_query.c    | 11 +++++------
 5 files changed, 43 insertions(+), 24 deletions(-)
drivers/gpu/drm/xe/xe_device.c +3 -3
index 273e2c45fea9..36d659b4eabd 100644
@@ -1321,9 +1321,9 @@ void xe_device_snapshot_print(struct xe_device *xe, struct drm_printer *p)
 		drm_printf(p, "\tType: %s\n",
 			   gt->info.type == XE_GT_TYPE_MAIN ? "main" : "media");
 		drm_printf(p, "\tIP ver: %u.%u.%u\n",
-			   REG_FIELD_GET(GMD_ID_ARCH_MASK, gt->info.gmdid),
-			   REG_FIELD_GET(GMD_ID_RELEASE_MASK, gt->info.gmdid),
-			   REG_FIELD_GET(GMD_ID_REVID, gt->info.gmdid));
+			   REG_FIELD_GET(GMD_ID_ARCH_MASK, gt->info.gmdid.value),
+			   REG_FIELD_GET(GMD_ID_RELEASE_MASK, gt->info.gmdid.value),
+			   REG_FIELD_GET(GMD_ID_REVID, gt->info.gmdid.value));
 		drm_printf(p, "\tCS reference clock: %u\n", gt->info.reference_clock);
 	}
 }
drivers/gpu/drm/xe/xe_gt.c +15 -6
index 671b87f1b9e9..becc82566457 100644
@@ -534,6 +534,19 @@ static void dump_pat_on_error(struct xe_gt *gt)
 	xe_pat_dump(gt, &p);
 }
 
+/*
+ * Store GMD_ID before GuC upload. Main GAMCTRL consumes the stored subunit
+ * field during upload. Pre-MTL platforms do not implement the register, so
+ * the read returns zero.
+ */
+static void xe_gt_read_gmdid(struct xe_gt *gt)
+{
+	u32 raw = xe_mmio_read32(&gt->mmio, GMD_ID);
+
+	gt->info.gmdid.value = raw;
+	gt->info.gmdid.subip = REG_FIELD_GET(GMD_ID_SUBIP_FLAG_MASK, raw);
+}
+
 static int gt_init_with_gt_forcewake(struct xe_gt *gt)
 {
 	int err;
@@ -542,6 +555,8 @@ static int gt_init_with_gt_forcewake(struct xe_gt *gt)
 	if (!fw_ref.domains)
 		return -ETIMEDOUT;
 
+	xe_gt_read_gmdid(gt);
+
 	err = xe_uc_init(&gt->uc);
 	if (err)
 		return err;
@@ -580,12 +595,6 @@ static int gt_init_with_gt_forcewake(struct xe_gt *gt)
 	if (err)
 		return err;
 
-	/*
-	 * Stash hardware-reported version.  Since this register does not exist
-	 * on pre-MTL platforms, reading it there will (correctly) return 0.
-	 */
-	gt->info.gmdid = xe_mmio_read32(&gt->mmio, GMD_ID);
-
 	if (GRAPHICS_VER(gt_to_xe(gt)) >= 20 && xe_gt_is_main_type(gt))
 		gt->info.has_wmtp_disabled = !!(xe_mmio_read32(&gt->mmio, XEHP_FUSE4) &
 			CFEG_WMTP_DISABLE);
drivers/gpu/drm/xe/xe_gt_types.h +15 -2
index c00a7c171f80..7bfcd806aac6 100644
@@ -120,6 +120,19 @@ enum xe_steering_type {
 		 const struct xe_gt * : (const struct xe_device *)(gt_to_tile(gt__)->xe),	\
 		 struct xe_gt * : gt_to_tile(gt__)->xe)
 
+/**
+ * struct xe_gmdid - GMD_ID register contents
+ *
+ * Zero on platforms that do not implement GMD_ID, matching a read of the
+ * unimplemented register.
+ */
+struct xe_gmdid {
+	/** @value: GMD_ID register value */
+	u32 value;
+	/** @subip: GMD_ID[13:6]; subunit indicator on media version 35, else reserved */
+	u8 subip;
+};
+
 /**
  * struct xe_gt - A "Graphics Technology" unit of the GPU
  *
@@ -151,8 +164,8 @@ struct xe_gt {
 		 * See @user_engines.mask
 		 */
 		u64 engine_mask;
-		/** @info.gmdid: raw GMD_ID value from hardware */
-		u32 gmdid;
+		/** @info.gmdid: GMD_ID register contents for this GT */
+		struct xe_gmdid gmdid;
 		/**
 		 * @info.multi_queue_engine_class_mask: Bitmask of engine classes with
 		 * multi queue support enabled.
drivers/gpu/drm/xe/xe_guc.c +5 -7
index 300126e6624f..9b060aa2890e 100644
@@ -1888,18 +1888,16 @@ bool xe_guc_using_main_gamctrl_queues(struct xe_guc *guc)
 	/*
 	 * For Xe3p media gt (35), the GuC and the CS subunits may be still Xe3
 	 * that lacks the Main GAMCTRL support. Reserved bits from the GMD_ID
-	 * inform the IP version of the subunits.
+	 * inform the IP version of the subunits. Those bits are stored in
+	 * gt->info.gmdid.subip and are reserved on other IPs.
 	 */
 	if (xe_gt_is_media_type(gt) && MEDIA_VER(gt_to_xe(gt)) == 35) {
-		u32 val = xe_mmio_read32(&gt->mmio, GMD_ID);
-		u32 subip = REG_FIELD_GET(GMD_ID_SUBIP_FLAG_MASK, val);
-
-		if (!subip)
+		if (!gt->info.gmdid.subip)
 			return true;
 
-		xe_gt_WARN(gt, subip != 1,
+		xe_gt_WARN(gt, gt->info.gmdid.subip != 1,
 			   "GMD_ID has unknown value in the SUBIP_FLAG field - 0x%x\n",
-			   subip);
+			   gt->info.gmdid.subip);
 
 		return false;
 	}
drivers/gpu/drm/xe/xe_query.c +5 -6
index dc975f595368..ec621be77a18 100644
@@ -424,12 +424,11 @@ static int query_gt_list(struct xe_device *xe, struct drm_xe_device_query *query
 			gt_list->gt_list[iter].near_mem_regions;
 
 		gt_list->gt_list[iter].ip_ver_major =
-			REG_FIELD_GET(GMD_ID_ARCH_MASK, gt->info.gmdid);
-		gt_list->gt_list[iter].ip_ver_minor =
-			REG_FIELD_GET(GMD_ID_RELEASE_MASK, gt->info.gmdid);
-		gt_list->gt_list[iter].ip_ver_rev =
-			REG_FIELD_GET(GMD_ID_REVID, gt->info.gmdid);
-
+				REG_FIELD_GET(GMD_ID_ARCH_MASK, gt->info.gmdid.value);
+			gt_list->gt_list[iter].ip_ver_minor =
+				REG_FIELD_GET(GMD_ID_RELEASE_MASK, gt->info.gmdid.value);
+			gt_list->gt_list[iter].ip_ver_rev =
+				REG_FIELD_GET(GMD_ID_REVID, gt->info.gmdid.value);
 		iter++;
 	}
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH v3 2/2 drm/xe: Initialize GT GMD_ID from probed info

In reply to Pallavi Mishra

GMD_ID is already read while probing IP versions. Stash that value in xe_probed_info and use it to fill gt->info.gmdid from xe_info_init(), instead of reading the register again during GT initialization.

---
 drivers/gpu/drm/xe/xe_gt.c  | 15 -----------
 drivers/gpu/drm/xe/xe_pci.c | 50 +++++++++++++++++++++++++++++--------
 2 files changed, 40 insertions(+), 25 deletions(-)
drivers/gpu/drm/xe/xe_gt.c +0 -15
index becc82566457..674e0ef8b034 100644
@@ -534,19 +534,6 @@ static void dump_pat_on_error(struct xe_gt *gt)
 	xe_pat_dump(gt, &p);
 }
 
-/*
- * Store GMD_ID before GuC upload. Main GAMCTRL consumes the stored subunit
- * field during upload. Pre-MTL platforms do not implement the register, so
- * the read returns zero.
- */
-static void xe_gt_read_gmdid(struct xe_gt *gt)
-{
-	u32 raw = xe_mmio_read32(&gt->mmio, GMD_ID);
-
-	gt->info.gmdid.value = raw;
-	gt->info.gmdid.subip = REG_FIELD_GET(GMD_ID_SUBIP_FLAG_MASK, raw);
-}
-
 static int gt_init_with_gt_forcewake(struct xe_gt *gt)
 {
 	int err;
@@ -555,8 +542,6 @@ static int gt_init_with_gt_forcewake(struct xe_gt *gt)
 	if (!fw_ref.domains)
 		return -ETIMEDOUT;
 
-	xe_gt_read_gmdid(gt);
-
 	err = xe_uc_init(&gt->uc);
 	if (err)
 		return err;
drivers/gpu/drm/xe/xe_pci.c +40 -10

134 lines not on this page · raw message

Signature · 1 line
2.43.0