[PATCH i-g-t v2 6/7] lib/xe: Add xe_dev_max_gt()
Matt Roper
matthew.d.roper at intel.com
Wed Jul 2 19:33:01 UTC 2025
Tests may need to allocate storage space to hold data by GT ID. Add a
helper function to ensure they can easily determine the maximum possible
ID (which may be higher than the number of GTs reported by
xe_number_gt()).
Signed-off-by: Matt Roper <matthew.d.roper at intel.com>
Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
lib/xe/xe_query.c | 14 ++++++++++++++
lib/xe/xe_query.h | 1 +
2 files changed, 15 insertions(+)
diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
index 8afcfe8db..3d628cb3f 100644
--- a/lib/xe/xe_query.c
+++ b/lib/xe/xe_query.c
@@ -469,6 +469,20 @@ _TYPE _NAME(int fd) \
*/
xe_dev_FN(xe_number_gt, gt_list->num_gt, unsigned int);
+/**
+ * xe_max_gt:
+ * @fd: xe device fd
+ *
+ * Return maximum GT ID in xe device's GT list.
+ */
+unsigned int xe_dev_max_gt(int fd)
+{
+ struct xe_device *xe_dev = find_in_cache(fd);
+
+ igt_assert(xe_dev);
+ return igt_fls(xe_dev->gt_mask) - 1;
+}
+
/**
* all_memory_regions:
* @fd: xe device fd
diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
index d18ca2b56..ca0b3235e 100644
--- a/lib/xe/xe_query.h
+++ b/lib/xe/xe_query.h
@@ -94,6 +94,7 @@ struct xe_device {
#define XE_MAX_ENGINE_INSTANCE 9
unsigned int xe_number_gt(int fd);
+unsigned int xe_dev_max_gt(int fd);
uint64_t all_memory_regions(int fd);
uint64_t system_memory(int fd);
const struct drm_xe_gt *drm_xe_get_gt(struct xe_device *xe_dev, int gt_id);
--
2.49.0
More information about the igt-dev
mailing list