[igt-dev] [PATCH i-g-t v21 01/35] lib/gem_submission: Add gem_has_relocations() check
Chris Wilson
chris at chris-wilson.co.uk
Thu Mar 4 14:09:13 UTC 2021
Quoting Zbigniew Kempczyński (2021-03-01 16:13:29)
> Add check which probes kernel supports relocation or not
> for i915 device.
>
> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
> Cc: Petri Latvala <petri.latvala at intel.com>
> ---
> lib/i915/gem_submission.c | 30 ++++++++++++++++++++++++++++++
> lib/i915/gem_submission.h | 1 +
> 2 files changed, 31 insertions(+)
>
> diff --git a/lib/i915/gem_submission.c b/lib/i915/gem_submission.c
> index 320340a5d..051f9d046 100644
> --- a/lib/i915/gem_submission.c
> +++ b/lib/i915/gem_submission.c
> @@ -398,3 +398,33 @@ unsigned int gem_submission_measure(int i915, unsigned int engine)
>
> return size;
> }
> +
> +/**
> + * gem_has_relocations:
> + * @fd: opened i915 drm file descriptor
> + *
> + * Feature test macro to query whether kernel allows for generation to
> + * use relocations.
> + *
> + * Returns: true if we can use relocations, otherwise false
> + */
> +
> +bool gem_has_relocations(int i915)
> +{
> + struct drm_i915_gem_relocation_entry reloc = {};
> + struct drm_i915_gem_exec_object2 obj = {
> + .handle = gem_create(i915, 4096),
> + .relocs_ptr = to_user_pointer(&reloc),
> + .relocation_count = 1,
> + };
> + struct drm_i915_gem_execbuffer2 execbuf = {
> + .buffers_ptr = to_user_pointer(&obj),
> + .buffer_count = 1,
> + };
> + bool has_relocs;
> +
> + has_relocs = __gem_execbuf(i915, &execbuf) == -ENOENT;
> + gem_close(i915, obj.handle);
Everything but for the relocation, so the first error we hit will be the
validation of that relocation.
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris
More information about the igt-dev
mailing list