Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Roper <matthew.d.roper@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: matthew.d.roper@intel.com
Subject: [PATCH v3 6/6] drm/xe/xe_query: Use separate iterator while filling GT list
Date: Mon, 30 Jun 2025 10:34:45 -0700	[thread overview]
Message-ID: <20250630173438.2342706-14-matthew.d.roper@intel.com> (raw)
In-Reply-To: <20250630173438.2342706-8-matthew.d.roper@intel.com>

The 'id' value updated by for_each_gt() is the uapi GT ID of the GTs
being iterated over, and may skip over values if a GT is not present on
the device.  Use a separate iterator for GT list array assignments to
ensure that the array will be filled properly on future platforms where
index in the GT query list may not match the uapi ID.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---
 drivers/gpu/drm/xe/xe_query.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_query.c b/drivers/gpu/drm/xe/xe_query.c
index e615b0916217..c3e0a22f09f0 100644
--- a/drivers/gpu/drm/xe/xe_query.c
+++ b/drivers/gpu/drm/xe/xe_query.c
@@ -368,6 +368,7 @@ static int query_gt_list(struct xe_device *xe, struct drm_xe_device_query *query
 	struct drm_xe_query_gt_list __user *query_ptr =
 		u64_to_user_ptr(query->data);
 	struct drm_xe_query_gt_list *gt_list;
+	int iter = 0;
 	u8 id;
 
 	if (query->size == 0) {
@@ -385,12 +386,12 @@ static int query_gt_list(struct xe_device *xe, struct drm_xe_device_query *query
 
 	for_each_gt(gt, xe, id) {
 		if (xe_gt_is_media_type(gt))
-			gt_list->gt_list[id].type = DRM_XE_QUERY_GT_TYPE_MEDIA;
+			gt_list->gt_list[iter].type = DRM_XE_QUERY_GT_TYPE_MEDIA;
 		else
-			gt_list->gt_list[id].type = DRM_XE_QUERY_GT_TYPE_MAIN;
-		gt_list->gt_list[id].tile_id = gt_to_tile(gt)->id;
-		gt_list->gt_list[id].gt_id = gt->info.id;
-		gt_list->gt_list[id].reference_clock = gt->info.reference_clock;
+			gt_list->gt_list[iter].type = DRM_XE_QUERY_GT_TYPE_MAIN;
+		gt_list->gt_list[iter].tile_id = gt_to_tile(gt)->id;
+		gt_list->gt_list[iter].gt_id = gt->info.id;
+		gt_list->gt_list[iter].reference_clock = gt->info.reference_clock;
 		/*
 		 * The mem_regions indexes in the mask below need to
 		 * directly identify the struct
@@ -406,18 +407,18 @@ static int query_gt_list(struct xe_device *xe, struct drm_xe_device_query *query
 		 * assumption.
 		 */
 		if (!IS_DGFX(xe))
-			gt_list->gt_list[id].near_mem_regions = 0x1;
+			gt_list->gt_list[iter].near_mem_regions = 0x1;
 		else
-			gt_list->gt_list[id].near_mem_regions =
+			gt_list->gt_list[iter].near_mem_regions =
 				BIT(gt_to_tile(gt)->id) << 1;
-		gt_list->gt_list[id].far_mem_regions = xe->info.mem_region_mask ^
-			gt_list->gt_list[id].near_mem_regions;
+		gt_list->gt_list[iter].far_mem_regions = xe->info.mem_region_mask ^
+			gt_list->gt_list[iter].near_mem_regions;
 
-		gt_list->gt_list[id].ip_ver_major =
+		gt_list->gt_list[iter].ip_ver_major =
 			REG_FIELD_GET(GMD_ID_ARCH_MASK, gt->info.gmdid);
-		gt_list->gt_list[id].ip_ver_minor =
+		gt_list->gt_list[iter].ip_ver_minor =
 			REG_FIELD_GET(GMD_ID_RELEASE_MASK, gt->info.gmdid);
-		gt_list->gt_list[id].ip_ver_rev =
+		gt_list->gt_list[iter].ip_ver_rev =
 			REG_FIELD_GET(GMD_ID_REVID, gt->info.gmdid);
 	}
 
-- 
2.49.0


  parent reply	other threads:[~2025-06-30 17:34 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-30 17:34 [PATCH v3 0/6] Future-proof for multi-tile + multi-GT cases Matt Roper
2025-06-30 17:34 ` [PATCH v3 1/6] drm/xe: Export xe_step_name for kunit tests Matt Roper
2025-06-30 23:54   ` Lucas De Marchi
2025-06-30 17:34 ` [PATCH v3 2/6] drm/xe: Track maximum GTs per tile on a per-platform basis Matt Roper
2025-07-01  5:05   ` Riana Tauro
2025-07-01 16:55     ` Matt Roper
2025-07-02  4:50       ` Riana Tauro
2025-06-30 17:34 ` [PATCH v3 3/6] drm/xe/tests/pci: Ensure all platforms have a valid GT/tile count Matt Roper
2025-06-30 17:34 ` [PATCH v3 4/6] drm/xe: Assign GT IDs properly on multi-tile + multi-GT platforms Matt Roper
2025-06-30 22:08   ` Cavitt, Jonathan
2025-06-30 17:34 ` [PATCH v3 5/6] drm/xe: Don't compare GT ID to GT count when determining valid GTs Matt Roper
2025-06-30 22:08   ` Cavitt, Jonathan
2025-06-30 17:34 ` Matt Roper [this message]
2025-06-30 22:08   ` [PATCH v3 6/6] drm/xe/xe_query: Use separate iterator while filling GT list Cavitt, Jonathan
2025-06-30 22:14     ` Matt Roper
2025-06-30 22:15   ` [PATCH v3.1 " Matt Roper
2025-07-01 14:05     ` Cavitt, Jonathan
2025-07-01  7:31 ` ✗ CI.checkpatch: warning for Future-proof for multi-tile + multi-GT cases (rev4) Patchwork
2025-07-01  7:32 ` ✓ CI.KUnit: success " Patchwork
2025-07-01  8:10 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-07-01 16:18 ` ✗ CI.checkpatch: warning for Future-proof for multi-tile + multi-GT cases (rev5) Patchwork
2025-07-01 16:19 ` ✓ CI.KUnit: success " Patchwork
2025-07-02 22:41 ` ✗ Xe.CI.Full: failure for Future-proof for multi-tile + multi-GT cases (rev4) Patchwork
2025-07-02 23:14   ` Matt Roper
2025-07-02 23:22     ` Matt Roper
2025-07-03 10:23 ` ✗ Xe.CI.Full: failure for Future-proof for multi-tile + multi-GT cases (rev5) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250630173438.2342706-14-matthew.d.roper@intel.com \
    --to=matthew.d.roper@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox