[PATCH i-g-t 4/7] lib/xe: Ensure GT loops iterate over all GTs properly
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Wed Jul 2 11:32:00 UTC 2025
On Mon, Jun 30, 2025 at 09:35:34AM -0700, Matt Roper wrote:
> 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].
>
> Signed-off-by: Matt Roper <matthew.d.roper 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..4aeff639a 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 = ffs(igt_unique(__mask)) - 1, igt_unique(__mask) != 0; \
> + igt_unique(__mask) &= ~BIT(__gt))
Replace ffs to ffsl, then:
Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
--
Zbigniew
> #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