Re: [v2,2/4] lib/xe: add xe_engine_class_supports_multi_lrc()

Daniel Charles
2026-04-06T22:32:30Z

On 4/3/2026 12:13 AM, Xin Wang wrote:
> Add xe_engine_class_supports_multi_lrc() to query whether an engine
> class supports multi-LRC submission. When the kernel exposes the
> information via the debugfs info node it is used directly; otherwise
> fall back to a hardcoded default to keep compatibility with older KMD.
>
> Signed-off-by: Xin Wang <x.wang@intel.com>
> ---
> lib/xe/xe_query.c | 30 ++++++++++++++++++++++++++++++
> lib/xe/xe_query.h | 1 +
> 2 files changed, 31 insertions(+)
>
> diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
> index 441e95794..e13d5e143 100644
> --- a/lib/xe/xe_query.c
> +++ b/lib/xe/xe_query.c
> @@ -308,6 +308,36 @@ static struct xe_device *find_in_cache(int fd)
> return xe_dev;
> }
>
> +/**
> + * xe_engine_class_supports_multi_lrc:
> + * @fd: xe device fd
> + * @engine_class: engine class
> + *
> + * Returns true if multi LRC supported by engine class or false.
> + * Uses the kernel-reported bitmask from debugfs when available, otherwise
> + * falls back to the hardcoded per-class default.
> + */
> +bool xe_engine_class_supports_multi_lrc(int fd, uint32_t engine_class)
> +{
> + struct xe_device *xe_dev = find_in_cache(fd);
> +
> + if (xe_dev && xe_dev->multi_lrc_mask != UINT16_MAX)
> + return !!(xe_dev->multi_lrc_mask & BIT(engine_class));
> +
> + switch (engine_class) {
> + case DRM_XE_ENGINE_CLASS_COPY:
> + case DRM_XE_ENGINE_CLASS_COMPUTE:
> + case DRM_XE_ENGINE_CLASS_RENDER:
> + return false;
> + case DRM_XE_ENGINE_CLASS_VIDEO_DECODE:
> + case DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE:
> + return true;
> + default:
> + igt_warn("Engine class 0x%x unknown\n", engine_class);
> + return false;
> + }
> +}
> +
> static void xe_device_free(struct xe_device *xe_dev)
> {
> free(xe_dev->config);
> diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
> index f33562bda..5c26a3e88 100644
> --- a/lib/xe/xe_query.h
> +++ b/lib/xe/xe_query.h
> @@ -162,6 +162,7 @@ uint32_t xe_va_bits(int fd);
> uint16_t xe_dev_id(int fd);
> int xe_supports_faults(int fd);
> bool xe_engine_class_supports_multi_queue(uint32_t engine_class);
> +bool xe_engine_class_supports_multi_lrc(int fd, uint32_t engine_class);
> const char *xe_engine_class_string(uint32_t engine_class);
> const char *xe_engine_class_short_string(uint32_t engine_class);
> bool xe_has_engine_class(int fd, uint16_t engine_class);

Reviewed-by:Daniel Charles <daniel.charles@intel.com>