[igt-dev] [RFC v2 05/43] lib/i915: Helper func for engine class to exec_flag

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Fri Jun 21 10:49:40 UTC 2019


On 21/06/2019 11:03, Ramalingam C wrote:
> Helper function is defined to get the execbuf flag for a engine of a
> class mapped for a ctx.

We need matching on both class and instance. You can take 
https://patchwork.freedesktop.org/patch/312751/?series=62454 from Andi 
who wrote it in the meantime.

Regards,

Tvrtko

> Signed-off-by: Ramalingam C <ramalingam.c at intel.com>
> ---
>   lib/i915/gem_engine_topology.c | 22 ++++++++++++++++++++++
>   lib/i915/gem_engine_topology.h |  2 ++
>   2 files changed, 24 insertions(+)
> 
> diff --git a/lib/i915/gem_engine_topology.c b/lib/i915/gem_engine_topology.c
> index fdd1b951672b..c64f7a4d05bb 100644
> --- a/lib/i915/gem_engine_topology.c
> +++ b/lib/i915/gem_engine_topology.c
> @@ -289,3 +289,25 @@ bool gem_has_engine_topology(int fd)
>   
>   	return !__gem_context_get_param(fd, &param);
>   }
> +
> +/* Return -EINVAL when the Engine with mentioned class is not found */
> +int gem_engine_class_to_execbuf_flags(int fd, uint32_t ctx_id, int class)
> +{
> +	const struct intel_execution_engine2 *e;
> +	DEFINE_CONTEXT_ENGINES_PARAM(engines, param, ctx_id, GEM_MAX_ENGINES);
> +	int i;
> +
> +	if (gem_topology_get_param(fd, &param)) {
> +		__for_each_static_engine(e) {
> +			if (e->class == class)
> +				return e->flags;
> +		}
> +		return -EINVAL;
> +	}
> +
> +	for (i = 0; i < param.size; i++)
> +		if (engines.engines[i].engine_class == class)
> +			return i;
> +
> +	return -EINVAL;
> +}
> diff --git a/lib/i915/gem_engine_topology.h b/lib/i915/gem_engine_topology.h
> index 2415fd1e379b..aa934622cab0 100644
> --- a/lib/i915/gem_engine_topology.h
> +++ b/lib/i915/gem_engine_topology.h
> @@ -53,6 +53,8 @@ int gem_context_lookup_engine(int fd, uint64_t engine, uint32_t ctx_id,
>   
>   void gem_context_set_all_engines(int fd, uint32_t ctx);
>   
> +int gem_engine_class_to_execbuf_flags(int fd, uint32_t ctx_id, int class);
> +
>   #define __for_each_static_engine(e__) \
>   	for ((e__) = intel_execution_engines2; (e__)->name; (e__)++)
>   
> 


More information about the igt-dev mailing list