Re: [igt-dev] [PATCH i-g-t v21 01/35] lib/gem_submission: Add gem_has_relocations() check
From: Chris Wilson <hidden>
Date: 2021-03-04 14:09:18
Quoting Zbigniew Kempczyński (2021-03-01 16:13:29)
quoted hunk ↗ jump to hunk
Add check which probes kernel supports relocation or not for i915 device. Signed-off-by: Zbigniew Kempczyński <redacted> Signed-off-by: Chris Wilson <redacted> Cc: Dominik Grzegorzek <redacted> Cc: Petri Latvala <redacted> --- 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 <redacted> -Chris _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev