[igt-dev] [PATCH i-g-t 1/2] xe/xe_query: Add engine class checker

Dandamudi, Priyanka priyanka.dandamudi at intel.com
Fri May 26 05:59:46 UTC 2023



> -----Original Message-----
> From: igt-dev <igt-dev-bounces at lists.freedesktop.org> On Behalf Of
> Zbigniew Kempczynski
> Sent: 26 May 2023 01:04 AM
> To: igt-dev at lists.freedesktop.org
> Subject: [igt-dev] [PATCH i-g-t 1/2] xe/xe_query: Add engine class checker
> 
> Some platforms might be not equipped with some engine classes so check
> before execution is reasonable choice. Add simple engine check to use in
> igt_require() constructs.
> 
> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Cc: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> ---
>  lib/xe/xe_query.c | 21 +++++++++++++++++++++  lib/xe/xe_query.h |  1 +
>  2 files changed, 22 insertions(+)
> 
> diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c index
> bd5eb1d189..47be8f301a 100644
> --- a/lib/xe/xe_query.c
> +++ b/lib/xe/xe_query.c
> @@ -536,6 +536,27 @@ xe_dev_FN(xe_va_bits, va_bits, uint32_t);
>   */
>  xe_dev_FN(xe_dev_id, dev_id, uint16_t);
> 
> +/**
> + * xe_has_engine_class:
> + * @fd: xe device fd
> + * @engine_class: engine class
> + *
> + * Returns true if device @fd has hardware engine @class otherwise false.
> + */
> +bool xe_has_engine_class(int fd, uint16_t engine_class) {
> +	struct xe_device *xe_dev;
> +
> +	xe_dev = find_in_cache(fd);
> +	igt_assert(xe_dev);
> +
> +	for (int i = 0; i < xe_dev->number_hw_engines; i++)
> +		if (xe_dev->hw_engines[i].engine_class == engine_class)
> +			return true;
> +
> +	return false;
> +}
> +
>  igt_constructor
>  {
>  	xe_device_cache_init();
> diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h index
> cc6e7cefdc..943ca558a5 100644
> --- a/lib/xe/xe_query.h
> +++ b/lib/xe/xe_query.h
> @@ -94,6 +94,7 @@ uint32_t xe_va_bits(int fd);  uint16_t xe_dev_id(int fd);
> bool xe_supports_faults(int fd);  const char *xe_engine_class_string(uint32_t
> engine_class);
> +bool xe_has_engine_class(int fd, uint16_t engine_class);
> 
>  struct xe_device *xe_device_get(int fd);  void xe_device_put(int fd);
> --
> 2.34.1
LGTM
Reviewed-by: Priyanka Dandamudi <priyanka.dandamudi at intel.com>



More information about the igt-dev mailing list