Skip to contentSkip to conversation

lib: Move __gem_context_create to common ioctl wrapper library.

PATCH In review Antonio Argenziano 3 participants 4 messages Feb 7, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 lib: Move __gem_context_create to common ioctl wrapper library.

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)

Cc Chris Wilson <[email protected]>
Cc Michał Winiarski <[email protected]>
---
 benchmarks/gem_exec_ctx.c   |  6 ++---
 benchmarks/gem_exec_trace.c |  4 +--
 lib/i915/gem_context.c      | 60 +++++++++++++++++++++++++++++++++++++--------
 lib/i915/gem_context.h      |  5 ++++
 tests/amdgpu/amd_prime.c    |  4 ++-
 tests/gem_ctx_bad_destroy.c |  2 ++
 tests/gem_ctx_create.c      | 18 ++++++--------
 tests/gem_ctx_exec.c        |  6 ++---
 tests/gem_ctx_param.c       |  2 ++
 tests/gem_ctx_switch.c      | 18 +++-----------
 tests/gem_ctx_thrash.c      |  6 +++++
 tests/gem_eio.c             | 14 ++---------
 tests/gem_exec_await.c      | 18 ++++----------
 tests/gem_exec_fence.c      | 24 +++++++++---------
 tests/gem_exec_latency.c    |  1 +
 tests/gem_exec_nop.c        | 16 +++---------
 tests/gem_exec_parallel.c   | 18 +-------------
 tests/gem_exec_reuse.c      | 18 +++-----------
 tests/gem_exec_schedule.c   |  3 +++
 tests/gem_exec_whisper.c    | 19 ++------------
 tests/gem_mocs_settings.c   |  3 +++
 tests/gem_request_retire.c  |  3 ++-
 tests/gem_reset_stats.c     |  3 +++
 tests/gem_sync.c            |  1 +
 tests/gem_workarounds.c     |  5 +++-
 tests/perf_pmu.c            |  4 ++-
 26 files changed, 133 insertions(+), 148 deletions(-)
benchmarks/gem_exec_ctx.c +3 -3
index 0eac04b0..a1c6e5d7 100644
@@ -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);
 			}
 
benchmarks/gem_exec_trace.c +2 -2
index 12577649..2724ee92 100644
@@ -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:
lib/i915/gem_context.c +50 -10

74 lines not on this page · raw message

lib/i915/gem_context.h +5 -0
index 96106b71..aef68dda 100644
@@ -25,10 +25,15 @@
 #define GEM_CONTEXT_H
 
 uint32_t gem_context_create(int fd);
+int __gem_context_create(int fd, uint32_t *ctx_id);
 void gem_context_destroy(int fd, uint32_t ctx_id);
 int __gem_context_destroy(int fd, uint32_t ctx_id);
+
+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 drm_i915_gem_context_param *p);
 void gem_context_set_param(int fd, struct drm_i915_gem_context_param *p);
 int __gem_context_set_param(int fd, struct drm_i915_gem_context_param *p);
tests/amdgpu/amd_prime.c +3 -1
index 54a11105..b2f326b4 100644
@@ -416,8 +416,10 @@ igt_main
 		igt_require(err == 0);
 	}
 
-	igt_subtest("i915-to-amd")
+	igt_subtest("i915-to-amd") {
+		gem_require_contexts(i915);
 		i915_to_amd(i915, amd, device);
+	}
 
 	igt_subtest("amd-to-i915")
 		amd_to_i915(i915, amd, device);
tests/gem_ctx_bad_destroy.c +2 -0
index fd6d988b..50bb9aa0 100644
@@ -45,6 +45,8 @@ igt_main
 	igt_fixture {
 		fd = drm_open_driver_render(DRIVER_INTEL);
 
+		gem_require_contexts(fd);
+
 		ctx_id = gem_context_create(fd);
 		/* Make sure a proper destroy works first */
 		gem_context_destroy(fd, ctx_id);
tests/gem_ctx_create.c +7 -11
index ae0825a1..058445b6 100644
@@ -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))
@@ -233,7 +233,6 @@ static uint64_t total_avail_mem(unsigned mode)
 
 static void maximum(int fd, int ncpus, unsigned mode)
 {
-	struct drm_i915_gem_context_create create;
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	struct drm_i915_gem_execbuffer2 execbuf;
 	struct drm_i915_gem_exec_object2 obj[2];
@@ -241,8 +240,8 @@ static void maximum(int fd, int ncpus, unsigned mode)
 	unsigned ctx_size = context_size(fd);
 	uint32_t *contexts = NULL;
 	unsigned long count = 0;
+	uint32_t ctx_id;
 
-	memset(&create, 0, sizeof(create));
 	do {
 		int err;
 
@@ -255,14 +254,14 @@ 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(fd, &ctx_id);
 		if (err) {
 			igt_info("Created %lu contexts, before failing with '%s' [%d]\n",
 				 count, strerror(-err), -err);
 			break;
 		}
 
-		contexts[count++] = create.ctx_id;
+		contexts[count++] = ctx_id;
 	} while (1);
 	igt_require(count);
 
@@ -320,10 +319,7 @@ igt_main
 
 		fd = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(fd);
-
-		memset(&create, 0, sizeof(create));
-		igt_require(__gem_context_create(fd, &create) == 0);
-		gem_context_destroy(fd, create.ctx_id);
+		gem_require_contexts(fd);
 
 		for_each_engine(fd, engine) {
 			if (engine == 0)
@@ -347,7 +343,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 +352,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")
tests/gem_ctx_exec.c +2 -4
index 15937cf3..fa864a21 100644
@@ -158,11 +158,9 @@ igt_main
 		fd = drm_open_driver_render(DRIVER_INTEL);
 		igt_require_gem(fd);
 
-		handle = gem_create(fd, 4096);
+		gem_require_contexts(fd);
 
-		/* check that we can create contexts. */
-		ctx_id = gem_context_create(fd);
-		gem_context_destroy(fd, ctx_id);
+		handle = gem_create(fd, 4096);
 		gem_write(fd, handle, 0, batch, sizeof(batch));
 	}
 
tests/gem_ctx_param.c +2 -0
index c20ae1ee..db68f57b 100644
@@ -38,6 +38,8 @@ igt_main
 
 	igt_fixture {
 		fd = drm_open_driver_render(DRIVER_INTEL);
+
+		gem_require_contexts(fd);
 		ctx = gem_context_create(fd);
 	}
 
tests/gem_ctx_switch.c +3 -15
index fdd67202..4db902b1 100644
@@ -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));
 
tests/gem_ctx_thrash.c +6 -0
index c0740b9f..b5d334f4 100644
@@ -124,6 +124,8 @@ static void single(const char *name, bool all_engines)
 	igt_require_gem(fd);
 	igt_require(gem_can_store_dword(fd, 0));
 
+	gem_require_contexts(fd);
+
 	gen = intel_gen(intel_get_drm_devid(fd));
 
 	num_engines = 0;
@@ -371,6 +373,10 @@ static void threads(void)
 	struct thread data;
 
 	data.fd = drm_open_driver_render(DRIVER_INTEL);
+	igt_require_gem(data.fd);
+
+	gem_require_contexts(data.fd);
+
 	data.num_ctx = get_num_contexts(data.fd, false);
 	data.all_ctx = malloc(data.num_ctx * sizeof(uint32_t));
 	igt_assert(data.all_ctx);
tests/gem_eio.c +2 -12
index 6d5a10f2..16a89ecd 100644
@@ -273,17 +273,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;
@@ -294,8 +283,9 @@ static void test_inflight_contexts(int fd)
 	int fence[64];
 
 	igt_require(gem_has_exec_fence(fd));
+	gem_require_contexts(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);
tests/gem_exec_await.c +5 -13
index 28b280ff..e19363c4 100644
@@ -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;
@@ -358,8 +348,10 @@ igt_main
 	igt_subtest("wide-all")
 		wide(device, ring_size, 20, 0);
 
-	igt_subtest("wide-contexts")
+	igt_subtest("wide-contexts") {
+		gem_require_contexts(device);
 		wide(device, ring_size, 20, CONTEXTS);
+	}
 
 	igt_fixture {
 		igt_stop_hang_detector();
tests/gem_exec_fence.c +12 -12
index 6ee944ff..bd7b1263 100644
@@ -1528,22 +1528,22 @@ igt_main
 		}
 	}
 
-	igt_subtest("long-history") {
-		long ring_size = measure_ring_size(i915) - 1;
+	igt_subtest_group {
+		long ring_size = 0;
 
-		igt_info("Ring size: %ld batches\n", ring_size);
-		igt_require(ring_size);
-
-		test_long_history(i915, ring_size, 0);
-	}
+		igt_fixture {
+			ring_size = measure_ring_size(i915) - 1;
+			igt_info("Ring size: %ld batches\n", ring_size);
+			igt_require(ring_size);
 
-	igt_subtest("expired-history") {
-		long ring_size = measure_ring_size(i915) - 1;
+			gem_require_contexts(i915);
+		}
 
-		igt_info("Ring size: %ld batches\n", ring_size);
-		igt_require(ring_size);
+		igt_subtest("long-history")
+			test_long_history(i915, ring_size, 0);
 
-		test_long_history(i915, ring_size, EXPIRED);
+		igt_subtest("expired-history")
+			test_long_history(i915, ring_size, EXPIRED);
 	}
 
 	igt_subtest("flip") {
tests/gem_exec_latency.c +1 -0
index 850404b9..74044bf4 100644
@@ -486,6 +486,7 @@ igt_main
 
 				igt_subtest_group {
 					igt_fixture {
+						gem_require_contexts(device);
 						igt_require(gem_scheduler_has_preemption(device));
 					}
 
tests/gem_exec_nop.c +3 -13
index 668dcb94..d3e9a3e0 100644
@@ -357,19 +357,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;
@@ -381,6 +368,8 @@ static void sequential(int fd, uint32_t handle, unsigned flags, int timeout)
 	double time, sum;
 	unsigned n;
 
+	gem_require_contexts(fd);
+
 	results = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
 	igt_assert(results != MAP_FAILED);
 
@@ -699,6 +688,7 @@ igt_main
 
 	igt_subtest_group {
 		igt_fixture {
+			gem_require_contexts(device);
 			igt_require(gem_scheduler_has_ctx_priority(device));
 			igt_require(gem_scheduler_has_preemption(device));
 		}
tests/gem_exec_parallel.c +1 -17
index 1c53bd64..11b6e775 100644
@@ -55,22 +55,6 @@ 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));
-}
-
 static bool ignore_engine(int fd, unsigned engine)
 {
 	if (engine == 0)
@@ -189,7 +173,7 @@ static void all(int fd, unsigned engine, unsigned flags)
 	int i;
 
 	if (flags & CONTEXTS)
-		gem_require_context(fd);
+		gem_require_contexts(fd);
 
 	if (flags & FDS)
 		igt_require(gen > 5);
tests/gem_exec_reuse.c +3 -15
index 4e3907cf..8ee38d2b 100644
@@ -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;
@@ -215,8 +202,9 @@ igt_main
 		const unsigned int ncontexts = 1024;
 		uint32_t contexts[ncontexts];
 
-		igt_require(__gem_context_create(no.fd, &contexts[0]) == 0);
-		for (n = 1; n < ncontexts; n++)
+		gem_require_contexts(no.fd);
+
+		for (n = 0; n < ncontexts; n++)
 			contexts[n] = gem_context_create(no.fd);
 
 		igt_until_timeout(timeout) {
tests/gem_exec_schedule.c +3 -0
index b8a67350..aeb7610b 100644
@@ -1001,8 +1001,11 @@ igt_main
 		fd = drm_open_driver_master(DRIVER_INTEL);
 		gem_submission_print_method(fd);
 		gem_scheduler_print_capability(fd);
+
 		igt_require_gem(fd);
 		gem_require_mmap_wc(fd);
+		gem_require_contexts(fd);
+
 		igt_fork_hang_detector(fd);
 	}
 
tests/gem_exec_whisper.c +2 -17
index 51921ba3..5f9fedf5 100644
@@ -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)
@@ -244,10 +231,8 @@ static void whisper(int fd, unsigned engine, unsigned flags)
 	if (flags & FDS)
 		igt_require(gen >= 6);
 
-	if (flags & CONTEXTS) {
-		igt_require(__gem_context_create(fd, &contexts[0]) == 0);
-		gem_context_destroy(fd, contexts[0]);
-	}
+	if (flags & CONTEXTS)
+		gem_require_contexts(fd);
 
 	if (flags & HANG)
 		init_hang(&hang);
tests/gem_mocs_settings.c +3 -0
index 29788b64..9705fbfd 100644
@@ -453,6 +453,9 @@ igt_main
 					      flags & MOCS_NON_DEFAULT_CTX ? "-ctx": "",
 					      flags & MOCS_DIRTY_VALUES ? "-dirty" : "",
 					      e->name) {
+					if (flags & (MOCS_NON_DEFAULT_CTX | MOCS_DIRTY_VALUES))
+						gem_require_contexts(fd);
+
 					run_test(fd, e->exec_id | e->flags, flags, mode);
 				}
 			}
tests/gem_request_retire.c +2 -1
index 6c0251c0..ea1c7327 100644
@@ -227,7 +227,8 @@ int main(int argc, char **argv)
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(fd);
-		igt_assert(fd >= 0);
+
+		gem_require_contexts(fd);
 	}
 
 	igt_subtest("retire-vma-not-inactive")
tests/gem_reset_stats.c +3 -0
index 17a9b648..74ba2656 100644
@@ -114,7 +114,10 @@ static int has_engine(int fd,
 static void check_context(const struct intel_execution_engine *e)
 {
 	int fd = drm_open_driver(DRIVER_INTEL);
+
+	gem_require_contexts(fd);
 	igt_require(has_engine(fd, gem_context_create(fd), e));
+
 	close(fd);
 }
 
tests/gem_sync.c +1 -0
index 36180aee..ad43b1a3 100644
@@ -839,6 +839,7 @@ igt_main
 
 	igt_subtest_group {
 		igt_fixture {
+			gem_require_contexts(fd);
 			igt_require(gem_scheduler_has_ctx_priority(fd));
 			igt_require(gem_scheduler_has_preemption(fd));
 		}
tests/gem_workarounds.c +4 -1
index 7b999612..78478ad2 100644
@@ -182,8 +182,11 @@ static void check_workarounds(int fd, enum operation op, unsigned int flags)
 
 	if (flags & FD)
 		fd = reopen(fd);
-	if (flags & CONTEXT)
+
+	if (flags & CONTEXT) {
+		gem_require_contexts(fd);
 		ctx = gem_context_create(fd);
+	}
 
 	igt_assert_eq(workaround_fail_count(fd, ctx), 0);
 
tests/perf_pmu.c +3 -1
index 60cff4ee..407ca58c 100644
@@ -1456,8 +1456,10 @@ igt_main
 			 * Check that reported usage is correct when PMU is
 			 * enabled after two batches are running.
 			 */
-			igt_subtest_f("busy-double-start-%s", e->name)
+			igt_subtest_f("busy-double-start-%s", e->name) {
+				gem_require_contexts(fd);
 				busy_double_start(fd, e);
+			}
 
 			/**
 			 * Check that the PMU can be safely enabled in face of
Signature · 6 lines
2.14.2

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for lib: Move __gem_context_create to common ioctl wrapper library. (rev4)

== Series Details ==

== Series Details ==

Series: lib: Move __gem_context_create to common ioctl wrapper library. (rev4)
URL : https://patchwork.freedesktop.org/series/37571/
State : success

== Summary ==

IGT patchset tested on top of latest successful build 3fd9b578b3138b04178b4ce8ee4a60e74a16ec91 tests/perf_pmu: Use short batches from hotplug test

with latest DRM-Tip kernel build CI_DRM_3728
078873da3835 drm-tip: 2018y-02m-06d-11h-21m-36s UTC integration manifest

No testlist changes.

Test gem_mmap_gtt:

        Subgroup basic-small-bo-tiledx:
                fail       -> PASS       (fi-gdg-551) fdo#102575
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                pass       -> INCOMPLETE (fi-snb-2520m) fdo#103713

fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:421s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:427s
fi-blb-e6850     total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:375s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:494s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:488s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:485s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:471s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:461s
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:571s
fi-cnl-y3        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:579s
fi-elk-e7500     total:288  pass:229  dwarn:0   dfail:0   fail:0   skip:59  time:411s
fi-gdg-551       total:288  pass:180  dwarn:0   dfail:0   fail:0   skip:108 time:289s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:513s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:392s
fi-hsw-4770r     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:400s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:413s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:462s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:416s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:458s
fi-kbl-7560u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:497s
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:449s
fi-kbl-r         total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:503s
fi-pnv-d510      total:288  pass:222  dwarn:1   dfail:0   fail:0   skip:65  time:601s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:432s
fi-skl-6600u     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:509s
fi-skl-6700hq    total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:531s
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:494s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:484s
fi-skl-guc       total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:416s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:430s
fi-snb-2520m     total:245  pass:211  dwarn:0   dfail:0   fail:0   skip:33 
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:409s

Blacklisted hosts:
fi-glk-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:474s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_874/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#2 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for lib: Move __gem_context_create to common ioctl wrapper library. (rev4)

In reply to Antonio Argenziano
== Series Details ==

== Series Details ==

Series: lib: Move __gem_context_create to common ioctl wrapper library. (rev4)
URL : https://patchwork.freedesktop.org/series/37571/
State : success

== Summary ==

Test perf:

        Subgroup buffer-fill:
                fail       -> PASS       (shard-apl) fdo#103755
        Subgroup enable-disable:
                fail       -> PASS       (shard-apl) fdo#103715
Test gem_eio:
        Subgroup in-flight:
                fail       -> PASS       (shard-hsw) fdo#104676
Test kms_flip:
        Subgroup 2x-wf_vblank-ts-check-interruptible:
                pass       -> FAIL       (shard-hsw) fdo#103928
        Subgroup plain-flip-ts-check-interruptible:
                pass       -> FAIL       (shard-apl) fdo#100368 +1
Test kms_mmap_write_crc:
                skip       -> PASS       (shard-apl)
Test gem_exec_schedule:
        Subgroup reorder-wide-vebox:
                incomplete -> PASS       (shard-apl) fdo#102848

fdo#103755 https://bugs.freedesktop.org/show_bug.cgi?id=103755
fdo#103715 https://bugs.freedesktop.org/show_bug.cgi?id=103715
fdo#104676 https://bugs.freedesktop.org/show_bug.cgi?id=104676
fdo#103928 https://bugs.freedesktop.org/show_bug.cgi?id=103928
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#102848 https://bugs.freedesktop.org/show_bug.cgi?id=102848

shard-apl        total:3384 pass:1749 dwarn:1   dfail:0   fail:22  skip:1611 time:12276s
shard-hsw        total:3442 pass:1758 dwarn:1   dfail:0   fail:11  skip:1671 time:11586s
shard-snb        total:3442 pass:1351 dwarn:1   dfail:0   fail:10  skip:2080 time:6629s

Blacklisted hosts:
shard-kbl total:3440 pass:1910 dwarn:1 dfail:0 fail:21 skip:1507 time:9101s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_874/shards.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw
In reply to Antonio Argenziano

Quoting Antonio Argenziano (2018-02-07 00:27:14)

Quoted 19 lines

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)

Quoted 6 lines
Cc Chris Wilson <[email protected]>
Cc Michał Winiarski <[email protected]>

Pushed while it was still hot. Thanks for fixing up the requires, that has been bugging me for a few years!
-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev