[PATCH i-g-t 1/7] lib/xe: Track valid GT IDs

Matt Roper matthew.d.roper at intel.com
Mon Jun 30 16:35:31 UTC 2025


Although current Intel platforms always have GTs with consecutive IDs,
we should rely on this being true in the future.  During initial device
query, build a bitmask of valid GT IDs that userspace may use.

Signed-off-by: Matt Roper <matthew.d.roper at intel.com>
---
 lib/xe/xe_query.c | 5 +++++
 lib/xe/xe_query.h | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
index 0d2e4805c..ac7b3110b 100644
--- a/lib/xe/xe_query.c
+++ b/lib/xe/xe_query.c
@@ -346,6 +346,11 @@ struct xe_device *xe_device_get(int fd)
 	xe_dev->va_bits = xe_dev->config->info[DRM_XE_QUERY_CONFIG_VA_BITS];
 	xe_dev->dev_id = xe_dev->config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] & 0xffff;
 	xe_dev->gt_list = xe_query_gt_list_new(fd);
+
+	/* GT IDs may be non-consecutive; keep a mask of valid IDs */
+	for (int gt = 0; gt < xe_dev->gt_list->num_gt; gt++)
+		xe_dev->gt_mask |= (1 << xe_dev->gt_list->gt_list[gt].gt_id);
+
 	xe_dev->memory_regions = __memory_regions(xe_dev->gt_list);
 	xe_dev->engines = xe_query_engines(fd);
 	xe_dev->mem_regions = xe_query_mem_regions_new(fd);
diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
index 1224a723a..37b0cf31e 100644
--- a/lib/xe/xe_query.h
+++ b/lib/xe/xe_query.h
@@ -36,6 +36,9 @@ struct xe_device {
 	/** @gt_list: gt info */
 	struct drm_xe_query_gt_list *gt_list;
 
+	/** @gt_mask: bitmask of GT IDs */
+	uint64_t gt_mask;
+
 	/** @memory_regions: bitmask of all memory regions */
 	uint64_t memory_regions;
 
-- 
2.49.0



More information about the igt-dev mailing list