From 2baf7ece5b6d2faccedc56527ec91623f41a85e4 Mon Sep 17 00:00:00 2001 From: Antonio Argenziano Date: Tue, 6 Feb 2018 16:27:14 -0800 Subject: lib: Move __gem_context_create to common ioctl wrapper library. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) v4: - Cosmetic changes and use lib function in gem_ctx_create where possible. (Michal) v5: - Use gem_contexts_require() in tests and fixtures. (Chris) Signed-off-by: Antonio Argenziano Cc: Chris Wilson Cc: Michał Winiarski Reviewed-by: Michał Winiarski Signed-off-by: Chris Wilson --- tests/gem_ctx_switch.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'tests/gem_ctx_switch.c') diff --git a/tests/gem_ctx_switch.c b/tests/gem_ctx_switch.c index fdd67202..4db902b1 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) + @@ -78,8 +65,7 @@ static void single(int fd, uint32_t handle, gem_require_ring(fd, e->exec_id | e->flags); - igt_require(__gem_context_create(fd, &contexts[0]) == 0); - for (n = 1; n < 64; n++) + for (n = 0; n < 64; n++) contexts[n] = gem_context_create(fd); memset(&obj, 0, sizeof(obj)); @@ -153,6 +139,8 @@ igt_main fd = drm_open_driver(DRIVER_INTEL); igt_require_gem(fd); + gem_require_contexts(fd); + light = gem_create(fd, 4096); gem_write(fd, light, 0, &bbe, sizeof(bbe)); -- cgit v1.2.3