[Intel-gfx] [PATCH 09/13] drm/i915: Extend I915_CONTEXT_PARAM_SSEU to support local ctx->engine[]
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Fri Mar 8 16:31:51 UTC 2019
On 08/03/2019 14:12, Chris Wilson wrote:
> Allow the user to specify a local engine index (as opposed to
> class:index) that they can use to refer to a preset engine inside the
> ctx->engine[] array defined by an earlier I915_CONTEXT_PARAM_ENGINES.
> This will be useful for setting SSEU parameters on virtual engines that
> are local to the context and do not have a valid global class:instance
> lookup.
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> ---
> drivers/gpu/drm/i915/i915_gem_context.c | 24 ++++++++++++++++++++----
> include/uapi/drm/i915_drm.h | 3 ++-
> 2 files changed, 22 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> index 86d9bea6f275..a581c01ffff1 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -1313,6 +1313,7 @@ static int set_sseu(struct i915_gem_context *ctx,
> struct drm_i915_gem_context_param_sseu user_sseu;
> struct intel_engine_cs *engine;
> struct intel_sseu sseu;
> + unsigned long lookup;
Poor 32-bit builds. ;) And in lookup_user_engine as well.
> int ret;
>
> if (args->size < sizeof(user_sseu))
> @@ -1325,10 +1326,17 @@ static int set_sseu(struct i915_gem_context *ctx,
> sizeof(user_sseu)))
> return -EFAULT;
>
> - if (user_sseu.flags || user_sseu.rsvd)
> + if (user_sseu.rsvd)
> return -EINVAL;
>
> - engine = lookup_user_engine(ctx, 0,
> + if (user_sseu.flags & ~(I915_CONTEXT_SSEU_FLAG_ENGINE_INDEX))
> + return -EINVAL;
> +
> + lookup = 0;
> + if (user_sseu.flags & I915_CONTEXT_SSEU_FLAG_ENGINE_INDEX)
> + lookup |= LOOKUP_USER_INDEX;
> +
> + engine = lookup_user_engine(ctx, lookup,
> user_sseu.engine_class,
> user_sseu.engine_instance);
> if (!engine)
> @@ -1807,6 +1815,7 @@ static int get_sseu(struct i915_gem_context *ctx,
> struct drm_i915_gem_context_param_sseu user_sseu;
> struct intel_engine_cs *engine;
> struct intel_context *ce;
> + unsigned long lookup;
>
> if (args->size == 0)
> goto out;
> @@ -1817,10 +1826,17 @@ static int get_sseu(struct i915_gem_context *ctx,
> sizeof(user_sseu)))
> return -EFAULT;
>
> - if (user_sseu.flags || user_sseu.rsvd)
> + if (user_sseu.rsvd)
> return -EINVAL;
>
> - engine = lookup_user_engine(ctx, 0,
> + if (user_sseu.flags & ~(I915_CONTEXT_SSEU_FLAG_ENGINE_INDEX))
> + return -EINVAL;
> +
> + lookup = 0;
> + if (user_sseu.flags & I915_CONTEXT_SSEU_FLAG_ENGINE_INDEX)
> + lookup |= LOOKUP_USER_INDEX;
> +
> + engine = lookup_user_engine(ctx, lookup,
> user_sseu.engine_class,
> user_sseu.engine_instance);
> if (!engine)
> diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
> index 00147b990e63..a609619610f2 100644
> --- a/include/uapi/drm/i915_drm.h
> +++ b/include/uapi/drm/i915_drm.h
> @@ -1565,9 +1565,10 @@ struct drm_i915_gem_context_param_sseu {
> __u16 engine_instance;
>
> /*
> - * Unused for now. Must be cleared to zero.
> + * Unknown flags must be cleared to zero.
> */
> __u32 flags;
> +#define I915_CONTEXT_SSEU_FLAG_ENGINE_INDEX (1u << 0)
>
> /*
> * Mask of slices to enable for the context. Valid values are a subset
>
Looks okay. But one more thing is needed:
https://cgit.freedesktop.org/~tursulin/drm-intel/commit/?h=media&id=38266bfe99469de9e13774a13fa641c377988c67
If you don't disagree with this patch feel free to adopt it into your tree.
Regards,
Tvrtko
More information about the Intel-gfx
mailing list