[PATCH i-g-t v2 4/7] lib/xe: Ensure GT loops iterate over all GTs properly
Matt Roper
matthew.d.roper at intel.com
Wed Jul 2 19:32:59 UTC 2025
There's no guarantee that GT IDs will be consecutive on future
platforms. Ensure that the GT loops visit each GT in the GT ID mask,
rather than [0, num_gt - 1].
v2:
- s/ffs/ffsll/ (Zbigniew)
- Replace BIT() with 1ull shift.
Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
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.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
index 9a2ceb4c8..d18ca2b56 100644
--- a/lib/xe/xe_query.h
+++ b/lib/xe/xe_query.h
@@ -77,8 +77,9 @@ struct xe_device {
for (__class = 0; __class < DRM_XE_ENGINE_CLASS_COMPUTE + 1; \
++__class)
#define xe_for_each_gt(__fd, __gt) \
- for (__gt = 0; __gt < xe_number_gt(__fd); ++__gt)
-
+ for (uint64_t igt_unique(__mask) = xe_device_get(__fd)->gt_mask; \
+ __gt = ffsll(igt_unique(__mask)) - 1, igt_unique(__mask) != 0; \
+ igt_unique(__mask) &= ~(1ull << __gt))
#define xe_for_each_mem_region(__fd, __memreg, __r) \
for (uint64_t igt_unique(__i) = 0; igt_unique(__i) < igt_fls(__memreg); igt_unique(__i)++) \
for_if(__r = (__memreg & (1ull << igt_unique(__i))))
--
2.49.0
More information about the igt-dev
mailing list