[igt-dev] [RFC PATCH v7 2/5] lib: implement new engine discovery interface

Chris Wilson chris at chris-wilson.co.uk
Mon Feb 11 23:15:12 UTC 2019


Quoting Andi Shyti (2019-02-11 23:08:08)
> Kernel commits:
> 
> [1] ae8f4544dd8f ("drm/i915: Engine discovery query")
> [2] 31e7d35667a0 ("drm/i915: Allow a context to define its set of engines")
> 
> implement a new uapi for engine discovery that consist in first
> querying the driver about the engines in the gpu [1] and then
> binding a context to the set of engines that it can access [2].
> 
> In igt the classic way for discovering engines is done through
> the for_each_physical_engine() macro, that would be replaced by
> the new for_each_engine_ctx().
> 
> A new function gem_init_engine_list() is added in the library
> that initializes the active engine list by interrogating the
> driver. The list is stored in intel_active_engines2.
> 
> In case of missing GET/SETPARAM ioctl command
> intel_active_engines2 will point to the existing
> intel_execution_engines2 that has a static list of engines.
> 
> gem_init_engine_list() returns
> 
>  * '0' on success
>  * -EINVAL if GET/SETPARAM are not present in the running kernel
>  * errno in case of other failure cases
> 
> Signed-off-by: Andi Shyti <andi.shyti at intel.com>
> ---
>  lib/igt_gt.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++-
>  lib/igt_gt.h |  22 +++++++-
>  2 files changed, 163 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/igt_gt.c b/lib/igt_gt.c
> index 646696727ee4..6c2c46562760 100644
> --- a/lib/igt_gt.c
> +++ b/lib/igt_gt.c
> @@ -577,7 +577,7 @@ bool gem_can_store_dword(int fd, unsigned int engine)
>         return true;
>  }
>  
> -const struct intel_execution_engine2 intel_execution_engines2[] = {
> +struct intel_execution_engine2 intel_execution_engines2[] = {
>         { "rcs0", I915_ENGINE_CLASS_RENDER, 0 },
>         { "bcs0", I915_ENGINE_CLASS_COPY, 0 },
>         { "vcs0", I915_ENGINE_CLASS_VIDEO, 0 },
> @@ -586,6 +586,8 @@ const struct intel_execution_engine2 intel_execution_engines2[] = {
>         { }
>  };
>  
> +struct intel_execution_engine2 *intel_active_engines2;
> +
>  unsigned int
>  gem_class_instance_to_eb_flags(int gem_fd,
>                                enum drm_i915_gem_engine_class class,
> @@ -650,3 +652,143 @@ bool gem_ring_has_physical_engine(int fd, unsigned ring)
>  
>         return gem_has_ring(fd, ring);
>  }
> +
> +static int __gem_query(int fd, struct drm_i915_query *q)
> +{
> +       return igt_ioctl(fd, DRM_IOCTL_I915_QUERY, q) ? -errno : 0;
> +}
> +
> +void gem_query(int fd, struct drm_i915_query *q)
> +{
> +       igt_assert(!__gem_query(fd, q));
> +}
> +
> +static int __gem_get_set_param(int fd, unsigned long request,
> +                              struct drm_i915_gem_context_param *p)
> +{
> +       return igt_ioctl(fd, request, p) ?  -errno : 0;
> +}
> +
> +void gem_get_set_param(int fd, unsigned long request,
> +                      struct drm_i915_gem_context_param *p)

Sigh. gem_context_set_param et al. Which should remind you that this is
i915/ specific...
-Chris


More information about the igt-dev mailing list