[PATCH i-g-t 6/7] lib/xe: Add xe_dev_max_gt()
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Wed Jul 2 11:36:01 UTC 2025
On Mon, Jun 30, 2025 at 09:35:36AM -0700, Matt Roper wrote:
> 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>
> ---
> 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 9bfad0cc2..6f2edf0de 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 4aeff639a..5ba481c63 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
>
Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
--
Zbigniew
More information about the igt-dev
mailing list