[PATCH i-g-t] lib/xe/xe_query: xe_find_engine_by_class helper
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Tue Oct 15 10:17:07 UTC 2024
On Tue, Oct 15, 2024 at 02:27:23PM +0530, Pravalika Gurram wrote:
> Added "xe_find_engine_by_class" helper function
> to query the required engine class instance id is available or not.
>
> Also use the compute engine first in LR mode,
> if compute engine is not available use render.
Please describe what's for is this patch. Above paragraphs are verbal
description of the code. For example sth like this:
'''
Spinner which has to run in LR mode should be executed on compute
or render command streamer. Stop assuming engine id is equal to 1
and use helper to find engine by its class.
'''
or similar.
>
> Signed-off-by: Pravalika Gurram <pravalika.gurram at intel.com>
> ---
> lib/xe/xe_query.c | 21 +++++++++++++++++++++
> lib/xe/xe_query.h | 1 +
> tests/intel/xe_exec_compute_mode.c | 10 +++++++++-
> 3 files changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
> index 8694fa3f9..22f3b5329 100644
> --- a/lib/xe/xe_query.c
> +++ b/lib/xe/xe_query.c
> @@ -731,6 +731,27 @@ bool xe_has_engine_class(int fd, uint16_t engine_class)
> return false;
> }
>
> +/**
> + * xe_find_engine_by_class
> + * @fd: xe device fd
> + * @engine_class: engine class
> + *
> + * Returns engine @class instance id otherwise -1.
> + */
> +uint32_t xe_find_engine_by_class(int fd, uint16_t engine_class)
This should rather return pointer to engine or NULL instead of index.
See how xe_engine() is implemented and return same pointer type.
> +{
> + struct xe_device *xe_dev;
> +
> + xe_dev = find_in_cache(fd);
> + igt_assert(xe_dev);
> +
> + for (int i = 0; i < xe_dev->engines->num_engines; i++)
> + if (xe_dev->engines->engines[i].instance.engine_class == engine_class)
> + return xe_dev->engines->engines[i].instance.engine_class;
> +
> + return -1;
> +
> +}
> /**
> * xe_has_media_gt:
> * @fd: xe device fd
> diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
> index fd1155f7f..e96f0d648 100644
> --- a/lib/xe/xe_query.h
> +++ b/lib/xe/xe_query.h
> @@ -108,6 +108,7 @@ uint16_t xe_dev_id(int fd);
> int 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);
> +uint32_t xe_find_engine_by_class(int fd, uint16_t engine_class);
> bool xe_has_media_gt(int fd);
> bool xe_is_media_gt(int fd, int gt);
> uint16_t xe_gt_get_tile_id(int fd, int gt);
Do above in separate patch.
> diff --git a/tests/intel/xe_exec_compute_mode.c b/tests/intel/xe_exec_compute_mode.c
> index 82e607848..7160b48d1 100644
> --- a/tests/intel/xe_exec_compute_mode.c
> +++ b/tests/intel/xe_exec_compute_mode.c
> @@ -457,11 +457,19 @@ static void lr_mode_workload(int fd)
> uint64_t ahnd;
> uint32_t bo;
> uint32_t ts_1, ts_2;
> + uint32_t num_engines, idx;
>
> vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
> ahnd = intel_allocator_open(fd, 0, INTEL_ALLOCATOR_RELOC);
> bo_size = xe_bb_size(fd, sizeof(*spin));
> - engine = xe_engine(fd, 1);
> +
> + num_engines = xe_number_engines(fd);
> + idx = xe_find_engine_by_class(fd, DRM_XE_ENGINE_CLASS_COMPUTE);
> + if (idx == -1)
> + idx = xe_find_engine_by_class(fd, DRM_XE_ENGINE_CLASS_RENDER);
> + igt_skip_on_f((idx == -1), "idx %d num_engines %d\n", idx, num_engines);
> + engine = xe_engine(fd, idx);
According to changes in the helper calling xe_engine() won't be
necessary here.
--
Zbigniew
> +
> bo = xe_bo_create(fd, vm, bo_size, vram_if_possible(fd, engine->instance.gt_id), 0);
> spin = xe_bo_map(fd, bo, bo_size);
>
> --
> 2.34.1
>
More information about the igt-dev
mailing list