Message ID | 20171026002839.20670-1-antonio.argenziano@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Oct 25, 2017 at 05:28:39PM -0700, Antonio Argenziano wrote: > This patch adds a context creation ioctl wrapper that returns the error > for the caller to consume. Multiple tests that implemented this already, > have been changed to use the new library function. > > v2: > - Add gem_require_contexts() to check for contexts support (Chris) > > v3: > - Add gem_has_contexts to check for contexts support and change > gem_require_contexts to skip if contests support is not available. > (Chris) > > Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com> > > Cc: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Michał Winiarski <michal.winiarski@intel.com> > --- > benchmarks/gem_exec_ctx.c | 6 ++--- > benchmarks/gem_exec_trace.c | 4 +-- > lib/i915/gem_context.c | 62 +++++++++++++++++++++++++++++++++++++-------- > lib/i915/gem_context.h | 3 +++ > tests/gem_ctx_create.c | 10 ++++---- > tests/gem_ctx_switch.c | 13 ---------- > tests/gem_eio.c | 13 +--------- > tests/gem_exec_await.c | 14 ++-------- > tests/gem_exec_nop.c | 13 ---------- > tests/gem_exec_parallel.c | 15 +++-------- > tests/gem_exec_reuse.c | 13 ---------- > tests/gem_exec_whisper.c | 13 ---------- > 12 files changed, 71 insertions(+), 108 deletions(-) > > diff --git a/benchmarks/gem_exec_ctx.c b/benchmarks/gem_exec_ctx.c > index 0eac04b0..a1c6e5d7 100644 > --- a/benchmarks/gem_exec_ctx.c > +++ b/benchmarks/gem_exec_ctx.c > @@ -64,7 +64,7 @@ static uint32_t batch(int fd) > return handle; > } > > -static uint32_t __gem_context_create(int fd) > +static uint32_t __gem_context_create_local(int fd) We only need this _local helper in negative parameters checks (in tests/gem_ctx_create - and perhaps we can open-code those two ioctl calls?). Both gem_exec_trace, gem_exec_ctx can use the helpers from lib. > { > struct drm_i915_gem_context_create create; > > @@ -101,7 +101,7 @@ static int loop(unsigned ring, > execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT; > execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC; > if (mode != DEFAULT) { > - execbuf.rsvd1 = __gem_context_create(fd); > + execbuf.rsvd1 = __gem_context_create_local(fd); > if (execbuf.rsvd1 == 0) > return 77; > } > @@ -125,7 +125,7 @@ static int loop(unsigned ring, > uint32_t ctx = 0; > > if (mode != DEFAULT && mode != NOP) { > - execbuf.rsvd1 = __gem_context_create(fd); > + execbuf.rsvd1 = __gem_context_create_local(fd); > ctx = gem_context_create(fd); > } > > diff --git a/benchmarks/gem_exec_trace.c b/benchmarks/gem_exec_trace.c > index 12577649..2724ee92 100644 > --- a/benchmarks/gem_exec_trace.c > +++ b/benchmarks/gem_exec_trace.c > @@ -105,7 +105,7 @@ static double elapsed(const struct timespec *start, const struct timespec *end) > return 1e3*(end->tv_sec - start->tv_sec) + 1e-6*(end->tv_nsec - start->tv_nsec); > } > > -static uint32_t __gem_context_create(int fd) > +static uint32_t __gem_context_create_local(int fd) > { > struct drm_i915_gem_context_create arg = {}; > drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &arg); > @@ -216,7 +216,7 @@ static double replay(const char *filename, long nop, long range) > num_ctx = new_ctx; > } > > - ctx[t->handle] = __gem_context_create(fd); > + ctx[t->handle] = __gem_context_create_local(fd); > break; > } > case DEL_CTX: > diff --git a/lib/i915/gem_context.c b/lib/i915/gem_context.c > index 6d9edf5e..a6c37051 100644 > --- a/lib/i915/gem_context.c > +++ b/lib/i915/gem_context.c > @@ -43,6 +43,22 @@ > * software features improving submission model (context priority). > */ > > +int __gem_context_create(int fd, uint32_t *ctx_id) > +{ > + struct drm_i915_gem_context_create create; > + int err = 0; > + > + memset(&create, 0, sizeof(create)); > + if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create) == 0) > + *ctx_id = create.ctx_id; > + else > + err = -errno; > + > + errno = 0; > + return err; > +} > + > + Stray newline > /** > * gem_context_create: > * @fd: open i915 drm file descriptor > @@ -55,18 +71,44 @@ > */ > uint32_t gem_context_create(int fd) > { > - struct drm_i915_gem_context_create create; > + uint32_t ctx_id; > + gem_require_contexts(fd); > > - memset(&create, 0, sizeof(create)); > - if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create)) { > - int err = -errno; > - igt_skip_on(err == -ENODEV || errno == -EINVAL); > - igt_assert_eq(err, 0); > - } > - igt_assert(create.ctx_id != 0); > - errno = 0; > + igt_assert_eq(__gem_context_create(fd, &ctx_id), 0); > + igt_assert(ctx_id != 0); > + > + return ctx_id; > +} > > - return create.ctx_id; > +/** > + * gem_has_contexts: > + * @fd: open i915 drm file descriptor > + * > + * Queries whether context creation is supported or not. > + * > + * Returns: Context creation availability. > + */ > +bool gem_has_contexts(int fd) > +{ > + uint32_t ctx_id = 0; > + > + __gem_context_create(fd, &ctx_id); > + if (ctx_id) > + gem_context_destroy(fd, ctx_id); > + > + return ctx_id; > +} > + > +/** > + * gem_require_contexts: > + * @fd: open i915 drm file descriptor > + * > + * This helper will automatically skip the test on platforms where context > + * support is not available. > + */ > +void gem_require_contexts(int fd) > +{ > + igt_require(gem_has_contexts(fd)); > } Since we're exporting all of the functions, perhaps we can move gem_request_contexts and gem_has_contexts, to keep create/destroy pair next to each other? > > int __gem_context_destroy(int fd, uint32_t ctx_id) > diff --git a/lib/i915/gem_context.h b/lib/i915/gem_context.h > index a2339c4b..efff96b6 100644 > --- a/lib/i915/gem_context.h > +++ b/lib/i915/gem_context.h > @@ -24,6 +24,7 @@ > #ifndef GEM_CONTEXT_H > #define GEM_CONTEXT_H > > +int __gem_context_create(int fd, uint32_t *ctx_id); > uint32_t gem_context_create(int fd); > void gem_context_destroy(int fd, uint32_t ctx_id); > int __gem_context_destroy(int fd, uint32_t ctx_id); Move __gem_context_create under gem_context_create to be consistent with gem_context_destroy, but that's just my OCD talking. > @@ -38,6 +39,8 @@ struct local_i915_gem_context_param { > #define LOCAL_CONTEXT_PARAM_BANNABLE 0x5 > uint64_t value; > }; > +bool gem_has_contexts(int fd); > +void gem_require_contexts(int fd); > void gem_context_require_bannable(int fd); > void gem_context_require_param(int fd, uint64_t param); > void gem_context_get_param(int fd, struct local_i915_gem_context_param *p); > diff --git a/tests/gem_ctx_create.c b/tests/gem_ctx_create.c > index ae0825a1..abe9a32e 100644 > --- a/tests/gem_ctx_create.c > +++ b/tests/gem_ctx_create.c > @@ -45,7 +45,7 @@ static unsigned all_nengine; > static unsigned ppgtt_engines[16]; > static unsigned ppgtt_nengine; > > -static int __gem_context_create(int fd, struct drm_i915_gem_context_create *arg) > +static int __gem_context_create_local(int fd, struct drm_i915_gem_context_create *arg) > { > int ret = 0; > if (drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, arg)) > @@ -255,7 +255,7 @@ static void maximum(int fd, int ncpus, unsigned mode) > > err = -ENOMEM; > if (avail_mem > (count + 1) * ctx_size) > - err = __gem_context_create(fd, &create); > + err = __gem_context_create_local(fd, &create); We can also use the helper from lib here. With that: Reviewed-by: Michał Winiarski <michal.winiarski@intel.com> -Michał
Quoting Michał Winiarski (2017-10-26 11:05:14) > On Wed, Oct 25, 2017 at 05:28:39PM -0700, Antonio Argenziano wrote: > > This patch adds a context creation ioctl wrapper that returns the error > > for the caller to consume. Multiple tests that implemented this already, > > have been changed to use the new library function. > > > > v2: > > - Add gem_require_contexts() to check for contexts support (Chris) > > > > v3: > > - Add gem_has_contexts to check for contexts support and change > > gem_require_contexts to skip if contests support is not available. > > (Chris) > > > > Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com> > > > > Cc: Chris Wilson <chris@chris-wilson.co.uk> > > Cc: Michał Winiarski <michal.winiarski@intel.com> > > --- > > benchmarks/gem_exec_ctx.c | 6 ++--- > > benchmarks/gem_exec_trace.c | 4 +-- > > lib/i915/gem_context.c | 62 +++++++++++++++++++++++++++++++++++++-------- > > lib/i915/gem_context.h | 3 +++ > > tests/gem_ctx_create.c | 10 ++++---- > > tests/gem_ctx_switch.c | 13 ---------- > > tests/gem_eio.c | 13 +--------- > > tests/gem_exec_await.c | 14 ++-------- > > tests/gem_exec_nop.c | 13 ---------- > > tests/gem_exec_parallel.c | 15 +++-------- > > tests/gem_exec_reuse.c | 13 ---------- > > tests/gem_exec_whisper.c | 13 ---------- > > 12 files changed, 71 insertions(+), 108 deletions(-) > > > > diff --git a/benchmarks/gem_exec_ctx.c b/benchmarks/gem_exec_ctx.c > > index 0eac04b0..a1c6e5d7 100644 > > --- a/benchmarks/gem_exec_ctx.c > > +++ b/benchmarks/gem_exec_ctx.c > > @@ -64,7 +64,7 @@ static uint32_t batch(int fd) > > return handle; > > } > > > > -static uint32_t __gem_context_create(int fd) > > +static uint32_t __gem_context_create_local(int fd) > > We only need this _local helper in negative parameters checks (in > tests/gem_ctx_create - and perhaps we can open-code those two ioctl calls?). > Both gem_exec_trace, gem_exec_ctx can use the helpers from lib. This benchmarks/, where life is a little different as most igt macros falter (as we aren't inside the test framework). It's a bit of a mess. -Chris
diff --git a/benchmarks/gem_exec_ctx.c b/benchmarks/gem_exec_ctx.c index 0eac04b0..a1c6e5d7 100644 --- a/benchmarks/gem_exec_ctx.c +++ b/benchmarks/gem_exec_ctx.c @@ -64,7 +64,7 @@ static uint32_t batch(int fd) return handle; } -static uint32_t __gem_context_create(int fd) +static uint32_t __gem_context_create_local(int fd) { struct drm_i915_gem_context_create create; @@ -101,7 +101,7 @@ static int loop(unsigned ring, execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT; execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC; if (mode != DEFAULT) { - execbuf.rsvd1 = __gem_context_create(fd); + execbuf.rsvd1 = __gem_context_create_local(fd); if (execbuf.rsvd1 == 0) return 77; } @@ -125,7 +125,7 @@ static int loop(unsigned ring, uint32_t ctx = 0; if (mode != DEFAULT && mode != NOP) { - execbuf.rsvd1 = __gem_context_create(fd); + execbuf.rsvd1 = __gem_context_create_local(fd); ctx = gem_context_create(fd); } diff --git a/benchmarks/gem_exec_trace.c b/benchmarks/gem_exec_trace.c index 12577649..2724ee92 100644 --- a/benchmarks/gem_exec_trace.c +++ b/benchmarks/gem_exec_trace.c @@ -105,7 +105,7 @@ static double elapsed(const struct timespec *start, const struct timespec *end) return 1e3*(end->tv_sec - start->tv_sec) + 1e-6*(end->tv_nsec - start->tv_nsec); } -static uint32_t __gem_context_create(int fd) +static uint32_t __gem_context_create_local(int fd) { struct drm_i915_gem_context_create arg = {}; drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &arg); @@ -216,7 +216,7 @@ static double replay(const char *filename, long nop, long range) num_ctx = new_ctx; } - ctx[t->handle] = __gem_context_create(fd); + ctx[t->handle] = __gem_context_create_local(fd); break; } case DEL_CTX: diff --git a/lib/i915/gem_context.c b/lib/i915/gem_context.c index 6d9edf5e..a6c37051 100644 --- a/lib/i915/gem_context.c +++ b/lib/i915/gem_context.c @@ -43,6 +43,22 @@ * software features improving submission model (context priority). */ +int __gem_context_create(int fd, uint32_t *ctx_id) +{ + struct drm_i915_gem_context_create create; + int err = 0; + + memset(&create, 0, sizeof(create)); + if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create) == 0) + *ctx_id = create.ctx_id; + else + err = -errno; + + errno = 0; + return err; +} + + /** * gem_context_create: * @fd: open i915 drm file descriptor @@ -55,18 +71,44 @@ */ uint32_t gem_context_create(int fd) { - struct drm_i915_gem_context_create create; + uint32_t ctx_id; + gem_require_contexts(fd); - memset(&create, 0, sizeof(create)); - if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create)) { - int err = -errno; - igt_skip_on(err == -ENODEV || errno == -EINVAL); - igt_assert_eq(err, 0); - } - igt_assert(create.ctx_id != 0); - errno = 0; + igt_assert_eq(__gem_context_create(fd, &ctx_id), 0); + igt_assert(ctx_id != 0); + + return ctx_id; +} - return create.ctx_id; +/** + * gem_has_contexts: + * @fd: open i915 drm file descriptor + * + * Queries whether context creation is supported or not. + * + * Returns: Context creation availability. + */ +bool gem_has_contexts(int fd) +{ + uint32_t ctx_id = 0; + + __gem_context_create(fd, &ctx_id); + if (ctx_id) + gem_context_destroy(fd, ctx_id); + + return ctx_id; +} + +/** + * gem_require_contexts: + * @fd: open i915 drm file descriptor + * + * This helper will automatically skip the test on platforms where context + * support is not available. + */ +void gem_require_contexts(int fd) +{ + igt_require(gem_has_contexts(fd)); } int __gem_context_destroy(int fd, uint32_t ctx_id) diff --git a/lib/i915/gem_context.h b/lib/i915/gem_context.h index a2339c4b..efff96b6 100644 --- a/lib/i915/gem_context.h +++ b/lib/i915/gem_context.h @@ -24,6 +24,7 @@ #ifndef GEM_CONTEXT_H #define GEM_CONTEXT_H +int __gem_context_create(int fd, uint32_t *ctx_id); uint32_t gem_context_create(int fd); void gem_context_destroy(int fd, uint32_t ctx_id); int __gem_context_destroy(int fd, uint32_t ctx_id); @@ -38,6 +39,8 @@ struct local_i915_gem_context_param { #define LOCAL_CONTEXT_PARAM_BANNABLE 0x5 uint64_t value; }; +bool gem_has_contexts(int fd); +void gem_require_contexts(int fd); void gem_context_require_bannable(int fd); void gem_context_require_param(int fd, uint64_t param); void gem_context_get_param(int fd, struct local_i915_gem_context_param *p); diff --git a/tests/gem_ctx_create.c b/tests/gem_ctx_create.c index ae0825a1..abe9a32e 100644 --- a/tests/gem_ctx_create.c +++ b/tests/gem_ctx_create.c @@ -45,7 +45,7 @@ static unsigned all_nengine; static unsigned ppgtt_engines[16]; static unsigned ppgtt_nengine; -static int __gem_context_create(int fd, struct drm_i915_gem_context_create *arg) +static int __gem_context_create_local(int fd, struct drm_i915_gem_context_create *arg) { int ret = 0; if (drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, arg)) @@ -255,7 +255,7 @@ static void maximum(int fd, int ncpus, unsigned mode) err = -ENOMEM; if (avail_mem > (count + 1) * ctx_size) - err = __gem_context_create(fd, &create); + err = __gem_context_create_local(fd, &create); if (err) { igt_info("Created %lu contexts, before failing with '%s' [%d]\n", count, strerror(-err), -err); @@ -322,7 +322,7 @@ igt_main igt_require_gem(fd); memset(&create, 0, sizeof(create)); - igt_require(__gem_context_create(fd, &create) == 0); + igt_require(__gem_context_create_local(fd, &create) == 0); gem_context_destroy(fd, create.ctx_id); for_each_engine(fd, engine) { @@ -347,7 +347,7 @@ igt_main memset(&create, 0, sizeof(create)); create.ctx_id = rand(); create.pad = 0; - igt_assert_eq(__gem_context_create(fd, &create), 0); + igt_assert_eq(__gem_context_create_local(fd, &create), 0); igt_assert(create.ctx_id != 0); gem_context_destroy(fd, create.ctx_id); } @@ -356,7 +356,7 @@ igt_main memset(&create, 0, sizeof(create)); create.ctx_id = rand(); create.pad = 1; - igt_assert_eq(__gem_context_create(fd, &create), -EINVAL); + igt_assert_eq(__gem_context_create_local(fd, &create), -EINVAL); } igt_subtest("maximum-mem") diff --git a/tests/gem_ctx_switch.c b/tests/gem_ctx_switch.c index fdd67202..285fc1a1 100644 --- a/tests/gem_ctx_switch.c +++ b/tests/gem_ctx_switch.c @@ -45,19 +45,6 @@ #define INTERRUPTIBLE 1 -static int __gem_context_create(int fd, uint32_t *ctx_id) -{ - struct drm_i915_gem_context_create arg; - int ret = 0; - - memset(&arg, 0, sizeof(arg)); - if (drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &arg)) - ret = -errno; - - *ctx_id = arg.ctx_id; - return ret; -} - static double elapsed(const struct timespec *start, const struct timespec *end) { return ((end->tv_sec - start->tv_sec) + diff --git a/tests/gem_eio.c b/tests/gem_eio.c index 2d4c95f4..bc1cfcd8 100644 --- a/tests/gem_eio.c +++ b/tests/gem_eio.c @@ -252,17 +252,6 @@ static void test_inflight_suspend(int fd) trigger_reset(fd); } -static uint32_t __gem_context_create(int fd) -{ - struct drm_i915_gem_context_create create; - - memset(&create, 0, sizeof(create)); - if (ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create)) - return 0; - - return create.ctx_id; -} - static void test_inflight_contexts(int fd) { struct drm_i915_gem_execbuffer2 execbuf; @@ -274,7 +263,7 @@ static void test_inflight_contexts(int fd) igt_require(gem_has_exec_fence(fd)); - ctx[0] = __gem_context_create(fd); + ctx[0] = gem_context_create(fd); igt_require(ctx[0]); for (unsigned int n = 1; n < ARRAY_SIZE(ctx); n++) ctx[n] = gem_context_create(fd); diff --git a/tests/gem_exec_await.c b/tests/gem_exec_await.c index 9c446792..ca0badaa 100644 --- a/tests/gem_exec_await.c +++ b/tests/gem_exec_await.c @@ -55,15 +55,6 @@ static bool ignore_engine(int fd, unsigned engine) return false; } -static uint32_t __gem_context_create(int fd) -{ - struct drm_i915_gem_context_create arg; - - memset(&arg, 0, sizeof(arg)); - drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &arg); - return arg.ctx_id; -} - static void xchg_obj(void *array, unsigned i, unsigned j) { struct drm_i915_gem_exec_object2 *obj = array; @@ -130,8 +121,7 @@ static void wide(int fd, int ring_size, int timeout, unsigned int flags) LOCAL_I915_EXEC_HANDLE_LUT); if (flags & CONTEXTS) { - exec[e].execbuf.rsvd1 = __gem_context_create(fd); - igt_require(exec[e].execbuf.rsvd1); + exec[e].execbuf.rsvd1 = gem_context_create(fd); } exec[e].exec[0].handle = gem_create(fd, 4096); @@ -174,7 +164,7 @@ static void wide(int fd, int ring_size, int timeout, unsigned int flags) if (flags & CONTEXTS) { gem_context_destroy(fd, exec[e].execbuf.rsvd1); - exec[e].execbuf.rsvd1 = __gem_context_create(fd); + exec[e].execbuf.rsvd1 = gem_context_create(fd); } exec[e].reloc.presumed_offset = exec[e].exec[1].offset; diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c index c9280795..c917ea55 100644 --- a/tests/gem_exec_nop.c +++ b/tests/gem_exec_nop.c @@ -358,19 +358,6 @@ static void xchg(void *array, unsigned i, unsigned j) u[j] = tmp; } -static int __gem_context_create(int fd, uint32_t *ctx_id) -{ - struct drm_i915_gem_context_create arg; - int ret = 0; - - memset(&arg, 0, sizeof(arg)); - if (drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &arg)) - ret = -errno; - - *ctx_id = arg.ctx_id; - return ret; -} - static void sequential(int fd, uint32_t handle, unsigned flags, int timeout) { const int ncpus = flags & FORKED ? sysconf(_SC_NPROCESSORS_ONLN) : 1; diff --git a/tests/gem_exec_parallel.c b/tests/gem_exec_parallel.c index 1c53bd64..5c0b027b 100644 --- a/tests/gem_exec_parallel.c +++ b/tests/gem_exec_parallel.c @@ -55,20 +55,11 @@ static void check_bo(int fd, uint32_t handle, int pass) munmap(map, 4096); } -static uint32_t __gem_context_create(int fd) -{ - struct drm_i915_gem_context_create arg; - - memset(&arg, 0, sizeof(arg)); - if (drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &arg) == 0) - gem_context_destroy(fd, arg.ctx_id); - - return arg.ctx_id; -} - static void gem_require_context(int fd) { - igt_require(__gem_context_create(fd)); + uint32_t ctx_id = 0; + __gem_context_create(fd, &ctx_id); + igt_require(ctx_id); } static bool ignore_engine(int fd, unsigned engine) diff --git a/tests/gem_exec_reuse.c b/tests/gem_exec_reuse.c index 4e3907cf..11185de1 100644 --- a/tests/gem_exec_reuse.c +++ b/tests/gem_exec_reuse.c @@ -56,19 +56,6 @@ static void noop(struct noop *n, gem_execbuf(n->fd, &execbuf); } -static int __gem_context_create(int fd, uint32_t *ctx_id) -{ - struct drm_i915_gem_context_create arg; - int ret = 0; - - memset(&arg, 0, sizeof(arg)); - if (drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &arg)) - ret = -errno; - - *ctx_id = arg.ctx_id; - return ret; -} - static int fls(uint64_t x) { int t; diff --git a/tests/gem_exec_whisper.c b/tests/gem_exec_whisper.c index 51921ba3..90527b54 100644 --- a/tests/gem_exec_whisper.c +++ b/tests/gem_exec_whisper.c @@ -79,19 +79,6 @@ static void verify_reloc(int fd, uint32_t handle, } } -static int __gem_context_create(int fd, uint32_t *ctx_id) -{ - struct drm_i915_gem_context_create arg; - int ret = 0; - - memset(&arg, 0, sizeof(arg)); - if (drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &arg)) - ret = -errno; - - *ctx_id = arg.ctx_id; - return ret; -} - static bool ignore_engine(int fd, unsigned engine) { if (engine == 0)
This patch adds a context creation ioctl wrapper that returns the error for the caller to consume. Multiple tests that implemented this already, have been changed to use the new library function. v2: - Add gem_require_contexts() to check for contexts support (Chris) v3: - Add gem_has_contexts to check for contexts support and change gem_require_contexts to skip if contests support is not available. (Chris) Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Michał Winiarski <michal.winiarski@intel.com> --- benchmarks/gem_exec_ctx.c | 6 ++--- benchmarks/gem_exec_trace.c | 4 +-- lib/i915/gem_context.c | 62 +++++++++++++++++++++++++++++++++++++-------- lib/i915/gem_context.h | 3 +++ tests/gem_ctx_create.c | 10 ++++---- tests/gem_ctx_switch.c | 13 ---------- tests/gem_eio.c | 13 +--------- tests/gem_exec_await.c | 14 ++-------- tests/gem_exec_nop.c | 13 ---------- tests/gem_exec_parallel.c | 15 +++-------- tests/gem_exec_reuse.c | 13 ---------- tests/gem_exec_whisper.c | 13 ---------- 12 files changed, 71 insertions(+), 108 deletions(-)