All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Ekstrand <jason@jlekstrand.net>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 27/77] tests/i915/gem_ctx_shared: Convert to intel_ctx_t
Date: Mon, 14 Jun 2021 11:36:42 -0500	[thread overview]
Message-ID: <20210614163704.365989-28-jason@jlekstrand.net> (raw)
In-Reply-To: <20210614163704.365989-1-jason@jlekstrand.net>

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
---
 tests/i915/gem_ctx_shared.c | 262 ++++++++++++++++++++----------------
 1 file changed, 145 insertions(+), 117 deletions(-)

diff --git a/tests/i915/gem_ctx_shared.c b/tests/i915/gem_ctx_shared.c
index aedf389c6..b78d95504 100644
--- a/tests/i915/gem_ctx_shared.c
+++ b/tests/i915/gem_ctx_shared.c
@@ -40,6 +40,7 @@
 #include "i915/gem.h"
 #include "i915/gem_create.h"
 #include "i915/gem_engine_topology.h"
+#include "i915/gem_vm.h"
 #include "igt.h"
 #include "igt_rand.h"
 #include "igt_vgem.h"
@@ -109,11 +110,13 @@ static void create_shared_gtt(int i915, unsigned int flags)
 	gem_close(i915, obj.handle);
 }
 
-static void disjoint_timelines(int i915)
+static void disjoint_timelines(int i915, const intel_ctx_cfg_t *cfg)
 {
 	IGT_CORK_HANDLE(cork);
+	intel_ctx_cfg_t vm_cfg;
+	const intel_ctx_t *ctx[2];
 	igt_spin_t *spin[2];
-	uint32_t plug, child;
+	uint32_t plug;
 
 	igt_require(gem_has_execlists(i915));
 
@@ -122,11 +125,15 @@ static void disjoint_timelines(int i915)
 	 * distinct timelines. A request queued to one context should be
 	 * independent of any shared contexts.
 	 */
-	child = gem_context_clone(i915, 0, I915_CONTEXT_CLONE_VM, 0);
+	vm_cfg = *cfg;
+	vm_cfg.vm = gem_vm_create(i915);
+	ctx[0] = intel_ctx_create(i915, &vm_cfg);
+	ctx[1] = intel_ctx_create(i915, &vm_cfg);
+
 	plug = igt_cork_plug(&cork, i915);
 
-	spin[0] = __igt_spin_new(i915, .ctx_id = 0, .dependency = plug);
-	spin[1] = __igt_spin_new(i915, .ctx_id = child);
+	spin[0] = __igt_spin_new(i915, .ctx = ctx[0], .dependency = plug);
+	spin[1] = __igt_spin_new(i915, .ctx = ctx[1]);
 
 	/* Wait for the second spinner, will hang if stuck behind the first */
 	igt_spin_end(spin[1]);
@@ -136,6 +143,10 @@ static void disjoint_timelines(int i915)
 
 	igt_spin_free(i915, spin[1]);
 	igt_spin_free(i915, spin[0]);
+
+	intel_ctx_destroy(i915, ctx[0]);
+	intel_ctx_destroy(i915, ctx[1]);
+	gem_vm_destroy(i915, vm_cfg.vm);
 }
 
 static void exhaust_shared_gtt(int i915, unsigned int flags)
@@ -185,7 +196,8 @@ static void exhaust_shared_gtt(int i915, unsigned int flags)
 	igt_waitchildren();
 }
 
-static void exec_shared_gtt(int i915, unsigned int ring)
+static void exec_shared_gtt(int i915, const intel_ctx_cfg_t *cfg,
+			    unsigned int ring)
 {
 	const unsigned int gen = intel_gen(intel_get_drm_devid(i915));
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
@@ -195,14 +207,18 @@ static void exec_shared_gtt(int i915, unsigned int ring)
 		.buffer_count = 1,
 		.flags = ring,
 	};
-	uint32_t clone;
+	intel_ctx_cfg_t vm_cfg;
+	const intel_ctx_t *ctx[2];
 	uint32_t scratch, *s;
 	uint32_t batch, cs[16];
 	uint64_t offset;
 	int timeline;
 	int i;
 
-	clone = gem_context_clone(i915, 0, I915_CONTEXT_CLONE_VM, 0);
+	vm_cfg = *cfg;
+	vm_cfg.vm = gem_vm_create(i915);
+	ctx[0] = intel_ctx_create(i915, &vm_cfg);
+	ctx[1] = intel_ctx_create(i915, &vm_cfg);
 
 	/* Find a hole big enough for both objects later */
 	scratch = gem_create(i915, 16384);
@@ -210,9 +226,9 @@ static void exec_shared_gtt(int i915, unsigned int ring)
 	obj.handle = scratch;
 	gem_execbuf(i915, &execbuf);
 	obj.flags |= EXEC_OBJECT_PINNED; /* reuse this address */
-	execbuf.rsvd1 = clone; /* and bind the second context image */
+	execbuf.rsvd1 = ctx[1]->id; /* and bind the second context image */
 	gem_execbuf(i915, &execbuf);
-	execbuf.rsvd1 = 0;
+	execbuf.rsvd1 = ctx[0]->id;
 	gem_close(i915, scratch);
 
 	timeline = sw_sync_timeline_create();
@@ -256,7 +272,7 @@ static void exec_shared_gtt(int i915, unsigned int ring)
 
 	obj.handle = batch;
 	obj.offset += 8192; /* make sure we don't cause an eviction! */
-	execbuf.rsvd1 = clone;
+	execbuf.rsvd1 = ctx[1]->id;
 	if (gen > 3 && gen < 6)
 		execbuf.flags |= I915_EXEC_SECURE;
 	gem_execbuf(i915, &execbuf);
@@ -288,10 +304,13 @@ static void exec_shared_gtt(int i915, unsigned int ring)
 	munmap(s, 4096);
 	gem_close(i915, scratch);
 
-	gem_context_destroy(i915, clone);
+	intel_ctx_destroy(i915, ctx[0]);
+	intel_ctx_destroy(i915, ctx[1]);
+	gem_vm_destroy(i915, vm_cfg.vm);
 }
 
-static int nop_sync(int i915, uint32_t ctx, unsigned int ring, int64_t timeout)
+static int nop_sync(int i915, const intel_ctx_t *ctx, unsigned int ring,
+		    int64_t timeout)
 {
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	struct drm_i915_gem_exec_object2 obj = {
@@ -301,7 +320,7 @@ static int nop_sync(int i915, uint32_t ctx, unsigned int ring, int64_t timeout)
 		.buffers_ptr = to_user_pointer(&obj),
 		.buffer_count = 1,
 		.flags = ring,
-		.rsvd1 = ctx,
+		.rsvd1 = ctx->id,
 	};
 	int err;
 
@@ -317,22 +336,24 @@ static bool has_single_timeline(int i915)
 {
 	uint32_t ctx = 0;
 
-	__gem_context_clone(i915, 0, 0,
-			    I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE,
-			    &ctx);
+	__gem_context_create_ext(i915,
+				 I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE,
+				 0, /* extensions */ &ctx);
 	if (ctx)
 		gem_context_destroy(i915, ctx);
 
 	return ctx != 0;
 }
 
-static void single_timeline(int i915)
+static void single_timeline(int i915, const intel_ctx_cfg_t *cfg)
 {
 	const struct intel_execution_engine2 *e;
 	struct sync_fence_info rings[64];
 	struct sync_file_info sync_file_info = {
 		.num_fences = 1,
 	};
+	intel_ctx_cfg_t st_cfg;
+	const intel_ctx_t *ctx;
 	igt_spin_t *spin;
 	int n;
 
@@ -347,11 +368,12 @@ static void single_timeline(int i915)
 	 * to, it reports the same timeline name and fence context. However,
 	 * the fence context is not reported through the sync_fence_info.
 	 */
-	spin->execbuf.rsvd1 =
-		gem_context_clone(i915, 0, 0,
-				  I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE);
+	st_cfg = *cfg;
+	st_cfg.flags |= I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE;
+	ctx = intel_ctx_create(i915, &st_cfg);
+	spin->execbuf.rsvd1 = ctx->id;
 	n = 0;
-	____for_each_physical_engine(i915, spin->execbuf.rsvd1, e) {
+	for_each_ctx_engine(i915, ctx, e) {
 		spin->execbuf.flags = e->flags | I915_EXEC_FENCE_OUT;
 
 		gem_execbuf_wr(i915, &spin->execbuf);
@@ -370,32 +392,35 @@ static void single_timeline(int i915)
 		igt_assert(!strcmp(rings[0].driver_name, rings[i].driver_name));
 		igt_assert(!strcmp(rings[0].obj_name, rings[i].obj_name));
 	}
+	intel_ctx_destroy(i915, ctx);
 }
 
-static void exec_single_timeline(int i915, unsigned int engine)
+static void exec_single_timeline(int i915, const intel_ctx_cfg_t *cfg,
+				 unsigned int engine)
 {
 	const struct intel_execution_engine2 *e;
 	igt_spin_t *spin;
-	uint32_t ctx;
+	intel_ctx_cfg_t st_cfg;
+	const intel_ctx_t *ctx;
 
 	/*
 	 * On an ordinary context, a blockage on one engine doesn't prevent
 	 * execution on an other.
 	 */
-	ctx = 0;
+	ctx = intel_ctx_create(i915, cfg);
 	spin = NULL;
-	__for_each_physical_engine(i915, e) {
+	for_each_ctx_cfg_engine(i915, cfg, e) {
 		if (e->flags == engine)
 			continue;
 
 		if (spin == NULL) {
-			spin = __igt_spin_new(i915, .ctx_id = ctx, .engine = e->flags);
+			spin = __igt_spin_new(i915, .ctx = ctx, .engine = e->flags);
 		} else {
 			struct drm_i915_gem_execbuffer2 execbuf = {
 				.buffers_ptr = spin->execbuf.buffers_ptr,
 				.buffer_count = spin->execbuf.buffer_count,
 				.flags = e->flags,
-				.rsvd1 = ctx,
+				.rsvd1 = ctx->id,
 			};
 			gem_execbuf(i915, &execbuf);
 		}
@@ -403,27 +428,29 @@ static void exec_single_timeline(int i915, unsigned int engine)
 	igt_require(spin);
 	igt_assert_eq(nop_sync(i915, ctx, engine, NSEC_PER_SEC), 0);
 	igt_spin_free(i915, spin);
+	intel_ctx_destroy(i915, ctx);
 
 	/*
 	 * But if we create a context with just a single shared timeline,
 	 * then it will block waiting for the earlier requests on the
 	 * other engines.
 	 */
-	ctx = gem_context_clone(i915, 0, 0,
-				I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE);
+	st_cfg = *cfg;
+	st_cfg.flags |= I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE;
+	ctx = intel_ctx_create(i915, &st_cfg);
 	spin = NULL;
-	__for_each_physical_engine(i915, e) {
+	for_each_ctx_cfg_engine(i915, cfg, e) {
 		if (e->flags == engine)
 			continue;
 
 		if (spin == NULL) {
-			spin = __igt_spin_new(i915, .ctx_id = ctx, .engine = e->flags);
+			spin = __igt_spin_new(i915, .ctx = ctx, .engine = e->flags);
 		} else {
 			struct drm_i915_gem_execbuffer2 execbuf = {
 				.buffers_ptr = spin->execbuf.buffers_ptr,
 				.buffer_count = spin->execbuf.buffer_count,
 				.flags = e->flags,
-				.rsvd1 = ctx,
+				.rsvd1 = ctx->id,
 			};
 			gem_execbuf(i915, &execbuf);
 		}
@@ -431,9 +458,10 @@ static void exec_single_timeline(int i915, unsigned int engine)
 	igt_assert(spin);
 	igt_assert_eq(nop_sync(i915, ctx, engine, NSEC_PER_SEC), -ETIME);
 	igt_spin_free(i915, spin);
+	intel_ctx_destroy(i915, ctx);
 }
 
-static void store_dword(int i915, uint32_t ctx, unsigned ring,
+static void store_dword(int i915, const intel_ctx_t *ctx, unsigned ring,
 			uint32_t target, uint32_t offset, uint32_t value,
 			uint32_t cork, unsigned write_domain)
 {
@@ -450,7 +478,7 @@ static void store_dword(int i915, uint32_t ctx, unsigned ring,
 	execbuf.flags = ring;
 	if (gen < 6)
 		execbuf.flags |= I915_EXEC_SECURE;
-	execbuf.rsvd1 = ctx;
+	execbuf.rsvd1 = ctx->id;
 
 	memset(obj, 0, sizeof(obj));
 	obj[0].handle = cork;
@@ -491,31 +519,30 @@ static void store_dword(int i915, uint32_t ctx, unsigned ring,
 	gem_close(i915, obj[2].handle);
 }
 
-static uint32_t create_highest_priority(int i915)
+static const intel_ctx_t *
+create_highest_priority(int i915, const intel_ctx_cfg_t *cfg)
 {
-	uint32_t ctx = gem_context_clone_with_engines(i915, 0);
+	const intel_ctx_t *ctx = intel_ctx_create(i915, cfg);
 
 	/*
 	 * If there is no priority support, all contexts will have equal
 	 * priority (and therefore the max user priority), so no context
 	 * can overtake us, and we effectively can form a plug.
 	 */
-	__gem_context_set_priority(i915, ctx, MAX_PRIO);
+	__gem_context_set_priority(i915, ctx->id, MAX_PRIO);
 
 	return ctx;
 }
 
-static void unplug_show_queue(int i915, struct igt_cork *c, unsigned int engine)
+static void unplug_show_queue(int i915, struct igt_cork *c,
+			      const intel_ctx_cfg_t *cfg, unsigned int engine)
 {
 	igt_spin_t *spin[MAX_ELSP_QLEN];
 
 	for (int n = 0; n < ARRAY_SIZE(spin); n++) {
-		const struct igt_spin_factory opts = {
-			.ctx_id = create_highest_priority(i915),
-			.engine = engine,
-		};
-		spin[n] = __igt_spin_factory(i915, &opts);
-		gem_context_destroy(i915, opts.ctx_id);
+		const intel_ctx_t *ctx = create_highest_priority(i915, cfg);
+		spin[n] = __igt_spin_new(i915, .ctx = ctx, .engine = engine);
+		intel_ctx_destroy(i915, ctx);
 	}
 
 	igt_cork_unplug(c); /* batches will now be queued on the engine */
@@ -526,7 +553,8 @@ static void unplug_show_queue(int i915, struct igt_cork *c, unsigned int engine)
 }
 
 static uint32_t store_timestamp(int i915,
-				uint32_t ctx, unsigned ring,
+				const intel_ctx_t *ctx,
+				unsigned ring,
 				unsigned mmio_base,
 				int fence,
 				int offset)
@@ -549,7 +577,7 @@ static uint32_t store_timestamp(int i915,
 		.buffers_ptr = to_user_pointer(&obj),
 		.buffer_count = 1,
 		.flags = ring | I915_EXEC_FENCE_IN,
-		.rsvd1 = ctx,
+		.rsvd1 = ctx->id,
 		.rsvd2 = fence
 	};
 	uint32_t batch[] = {
@@ -577,7 +605,7 @@ static void kick_tasklets(void)
 	sched_yield();
 }
 
-static void independent(int i915,
+static void independent(int i915, const intel_ctx_cfg_t *cfg,
 			const struct intel_execution_engine2 *e,
 			unsigned flags)
 {
@@ -592,22 +620,19 @@ static void independent(int i915,
 	igt_require_f(mmio_base, "mmio base not known\n");
 
 	for (int n = 0; n < ARRAY_SIZE(spin); n++) {
-		const struct igt_spin_factory opts = {
-			.ctx_id = create_highest_priority(i915),
-			.engine = e->flags,
-		};
-		spin[n] = __igt_spin_factory(i915, &opts);
-		gem_context_destroy(i915, opts.ctx_id);
+		const intel_ctx_t *ctx = create_highest_priority(i915, cfg);
+		spin[n] = __igt_spin_new(i915, .ctx = ctx, .engine = e->flags);
+		intel_ctx_destroy(i915, ctx);
 	}
 
 	fence = igt_cork_plug(&cork, i915);
 	for (int i = 0; i < ARRAY_SIZE(priorities); i++) {
-		uint32_t ctx = gem_queue_create(i915);
-		gem_context_set_priority(i915, ctx, priorities[i]);
+		const intel_ctx_t *ctx = create_highest_priority(i915, cfg);
+		gem_context_set_priority(i915, ctx->id, priorities[i]);
 		handle[i] = store_timestamp(i915, ctx,
 					    e->flags, mmio_base,
 					    fence, TIMESTAMP);
-		gem_context_destroy(i915, ctx);
+		intel_ctx_destroy(i915, ctx);
 	}
 	close(fence);
 	kick_tasklets(); /* XXX try to hide cmdparser delays XXX */
@@ -636,20 +661,21 @@ static void independent(int i915,
 	igt_assert((int32_t)(handle[HI] - handle[LO]) < 0);
 }
 
-static void reorder(int i915, unsigned ring, unsigned flags)
+static void reorder(int i915, const intel_ctx_cfg_t *cfg,
+		    unsigned ring, unsigned flags)
 #define EQUAL 1
 {
 	IGT_CORK_HANDLE(cork);
 	uint32_t scratch;
 	uint32_t *ptr;
-	uint32_t ctx[2];
+	const intel_ctx_t *ctx[2];
 	uint32_t plug;
 
-	ctx[LO] = gem_queue_create(i915);
-	gem_context_set_priority(i915, ctx[LO], MIN_PRIO);
+	ctx[LO] = intel_ctx_create(i915, cfg);
+	gem_context_set_priority(i915, ctx[LO]->id, MIN_PRIO);
 
-	ctx[HI] = gem_queue_create(i915);
-	gem_context_set_priority(i915, ctx[HI], flags & EQUAL ? MIN_PRIO : 0);
+	ctx[HI] = intel_ctx_create(i915, cfg);
+	gem_context_set_priority(i915, ctx[HI]->id, flags & EQUAL ? MIN_PRIO : 0);
 
 	scratch = gem_create(i915, 4096);
 	plug = igt_cork_plug(&cork, i915);
@@ -657,43 +683,43 @@ static void reorder(int i915, unsigned ring, unsigned flags)
 	/* We expect the high priority context to be executed first, and
 	 * so the final result will be value from the low priority context.
 	 */
-	store_dword(i915, ctx[LO], ring, scratch, 0, ctx[LO], plug, 0);
-	store_dword(i915, ctx[HI], ring, scratch, 0, ctx[HI], plug, 0);
+	store_dword(i915, ctx[LO], ring, scratch, 0, ctx[LO]->id, plug, 0);
+	store_dword(i915, ctx[HI], ring, scratch, 0, ctx[HI]->id, plug, 0);
 
-	unplug_show_queue(i915, &cork, ring);
+	unplug_show_queue(i915, &cork, cfg, ring);
 	gem_close(i915, plug);
 
-	gem_context_destroy(i915, ctx[LO]);
-	gem_context_destroy(i915, ctx[HI]);
-
 	ptr = gem_mmap__device_coherent(i915, scratch, 0, 4096, PROT_READ);
 	gem_set_domain(i915, scratch, /* no write hazard lies! */
 		       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
 	gem_close(i915, scratch);
 
 	if (flags & EQUAL) /* equal priority, result will be fifo */
-		igt_assert_eq_u32(ptr[0], ctx[HI]);
+		igt_assert_eq_u32(ptr[0], ctx[HI]->id);
 	else
-		igt_assert_eq_u32(ptr[0], ctx[LO]);
+		igt_assert_eq_u32(ptr[0], ctx[LO]->id);
 	munmap(ptr, 4096);
+
+	intel_ctx_destroy(i915, ctx[LO]);
+	intel_ctx_destroy(i915, ctx[HI]);
 }
 
-static void promotion(int i915, unsigned ring)
+static void promotion(int i915, const intel_ctx_cfg_t *cfg, unsigned ring)
 {
 	IGT_CORK_HANDLE(cork);
 	uint32_t result, dep;
 	uint32_t *ptr;
-	uint32_t ctx[3];
+	const intel_ctx_t *ctx[3];
 	uint32_t plug;
 
-	ctx[LO] = gem_queue_create(i915);
-	gem_context_set_priority(i915, ctx[LO], MIN_PRIO);
+	ctx[LO] = intel_ctx_create(i915, cfg);
+	gem_context_set_priority(i915, ctx[LO]->id, MIN_PRIO);
 
-	ctx[HI] = gem_queue_create(i915);
-	gem_context_set_priority(i915, ctx[HI], 0);
+	ctx[HI] = intel_ctx_create(i915, cfg);
+	gem_context_set_priority(i915, ctx[HI]->id, 0);
 
-	ctx[NOISE] = gem_queue_create(i915);
-	gem_context_set_priority(i915, ctx[NOISE], MIN_PRIO/2);
+	ctx[NOISE] = intel_ctx_create(i915, cfg);
+	gem_context_set_priority(i915, ctx[NOISE]->id, MIN_PRIO/2);
 
 	result = gem_create(i915, 4096);
 	dep = gem_create(i915, 4096);
@@ -705,28 +731,24 @@ static void promotion(int i915, unsigned ring)
 	 * fifo would be NOISE, LO, HI.
 	 * strict priority would be  HI, NOISE, LO
 	 */
-	store_dword(i915, ctx[NOISE], ring, result, 0, ctx[NOISE], plug, 0);
-	store_dword(i915, ctx[LO], ring, result, 0, ctx[LO], plug, 0);
+	store_dword(i915, ctx[NOISE], ring, result, 0, ctx[NOISE]->id, plug, 0);
+	store_dword(i915, ctx[LO], ring, result, 0, ctx[LO]->id, plug, 0);
 
 	/* link LO <-> HI via a dependency on another buffer */
-	store_dword(i915, ctx[LO], ring, dep, 0, ctx[LO], 0, I915_GEM_DOMAIN_INSTRUCTION);
-	store_dword(i915, ctx[HI], ring, dep, 0, ctx[HI], 0, 0);
+	store_dword(i915, ctx[LO], ring, dep, 0, ctx[LO]->id, 0, I915_GEM_DOMAIN_INSTRUCTION);
+	store_dword(i915, ctx[HI], ring, dep, 0, ctx[HI]->id, 0, 0);
 
-	store_dword(i915, ctx[HI], ring, result, 0, ctx[HI], 0, 0);
+	store_dword(i915, ctx[HI], ring, result, 0, ctx[HI]->id, 0, 0);
 
-	unplug_show_queue(i915, &cork, ring);
+	unplug_show_queue(i915, &cork, cfg, ring);
 	gem_close(i915, plug);
 
-	gem_context_destroy(i915, ctx[NOISE]);
-	gem_context_destroy(i915, ctx[LO]);
-	gem_context_destroy(i915, ctx[HI]);
-
 	ptr = gem_mmap__device_coherent(i915, dep, 0, 4096, PROT_READ);
 	gem_set_domain(i915, dep, /* no write hazard lies! */
 			I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
 	gem_close(i915, dep);
 
-	igt_assert_eq_u32(ptr[0], ctx[HI]);
+	igt_assert_eq_u32(ptr[0], ctx[HI]->id);
 	munmap(ptr, 4096);
 
 	ptr = gem_mmap__device_coherent(i915, result, 0, 4096, PROT_READ);
@@ -734,11 +756,16 @@ static void promotion(int i915, unsigned ring)
 			I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
 	gem_close(i915, result);
 
-	igt_assert_eq_u32(ptr[0], ctx[NOISE]);
+	igt_assert_eq_u32(ptr[0], ctx[NOISE]->id);
 	munmap(ptr, 4096);
+
+	intel_ctx_destroy(i915, ctx[NOISE]);
+	intel_ctx_destroy(i915, ctx[LO]);
+	intel_ctx_destroy(i915, ctx[HI]);
 }
 
-static void smoketest(int i915, unsigned ring, unsigned timeout)
+static void smoketest(int i915, const intel_ctx_cfg_t *cfg,
+		      unsigned ring, unsigned timeout)
 {
 	const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
 	unsigned engines[I915_EXEC_RING_MASK + 1];
@@ -751,7 +778,7 @@ static void smoketest(int i915, unsigned ring, unsigned timeout)
 	if (ring == -1) {
 		const struct intel_execution_engine2 *e;
 
-		__for_each_physical_engine(i915, e)
+		for_each_ctx_cfg_engine(i915, cfg, e)
 			engines[nengine++] = e->flags;
 	} else {
 		engines[nengine++] = ring;
@@ -761,16 +788,16 @@ static void smoketest(int i915, unsigned ring, unsigned timeout)
 	scratch = gem_create(i915, 4096);
 	igt_fork(child, ncpus) {
 		unsigned long count = 0;
-		uint32_t ctx;
+		const intel_ctx_t *ctx;
 
 		hars_petruska_f54_1_random_perturb(child);
 
-		ctx = gem_queue_create(i915);
+		ctx = intel_ctx_create(i915, cfg);
 		igt_until_timeout(timeout) {
 			int prio;
 
 			prio = hars_petruska_f54_1_random_unsafe_max(MAX_PRIO - MIN_PRIO) + MIN_PRIO;
-			gem_context_set_priority(i915, ctx, prio);
+			gem_context_set_priority(i915, ctx->id, prio);
 
 			engine = engines[hars_petruska_f54_1_random_unsafe_max(nengine)];
 			store_dword(i915, ctx, engine, scratch,
@@ -781,7 +808,7 @@ static void smoketest(int i915, unsigned ring, unsigned timeout)
 					    8*child + 4, count++,
 					    0, 0);
 		}
-		gem_context_destroy(i915, ctx);
+		intel_ctx_destroy(i915, ctx);
 	}
 	igt_waitchildren();
 
@@ -803,19 +830,21 @@ static void smoketest(int i915, unsigned ring, unsigned timeout)
 	munmap(ptr, 4096);
 }
 
-#define for_each_queue(e, i915) \
-	__for_each_physical_engine(i915, e) \
+#define for_each_queue(e, i915, cfg) \
+	for_each_ctx_cfg_engine(i915, cfg, e) \
 		for_each_if(gem_class_can_store_dword(i915, (e)->class)) \
 			igt_dynamic_f("%s", e->name)
 
 igt_main
 {
 	const struct intel_execution_engine2 *e;
+	intel_ctx_cfg_t cfg;
 	int i915 = -1;
 
 	igt_fixture {
 		i915 = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(i915);
+		cfg = intel_ctx_cfg_all_physical(i915);
 	}
 
 	igt_subtest_group {
@@ -831,20 +860,20 @@ igt_main
 			create_shared_gtt(i915, DETACHED);
 
 		igt_subtest("disjoint-timelines")
-			disjoint_timelines(i915);
+			disjoint_timelines(i915, &cfg);
 
 		igt_subtest("single-timeline")
-			single_timeline(i915);
+			single_timeline(i915, &cfg);
 
 		igt_subtest_with_dynamic("exec-shared-gtt") {
-			for_each_queue(e, i915)
-				exec_shared_gtt(i915, e->flags);
+			for_each_queue(e, i915, &cfg)
+				exec_shared_gtt(i915, &cfg, e->flags);
 		}
 
 		igt_subtest_with_dynamic("exec-single-timeline") {
 			igt_require(has_single_timeline(i915));
-			for_each_queue(e, i915)
-				exec_single_timeline(i915, e->flags);
+			for_each_queue(e, i915, &cfg)
+				exec_single_timeline(i915, &cfg, e->flags);
 		}
 
 		/*
@@ -856,38 +885,37 @@ igt_main
 		 */
 		igt_subtest_group {
 			igt_fixture {
-				igt_require(gem_has_queues(i915));
 				igt_require(gem_scheduler_enabled(i915));
 				igt_require(gem_scheduler_has_ctx_priority(i915));
 			}
 
 			igt_subtest_with_dynamic("Q-independent") {
-				for_each_queue(e, i915)
-					independent(i915, e, 0);
+				for_each_queue(e, i915, &cfg)
+					independent(i915, &cfg, e, 0);
 			}
 
 			igt_subtest_with_dynamic("Q-in-order") {
-				for_each_queue(e, i915)
-					reorder(i915, e->flags, EQUAL);
+				for_each_queue(e, i915, &cfg)
+					reorder(i915, &cfg, e->flags, EQUAL);
 			}
 
 			igt_subtest_with_dynamic("Q-out-order") {
-				for_each_queue(e, i915)
-					reorder(i915, e->flags, 0);
+				for_each_queue(e, i915, &cfg)
+					reorder(i915, &cfg, e->flags, 0);
 			}
 
 			igt_subtest_with_dynamic("Q-promotion") {
-				for_each_queue(e, i915)
-					promotion(i915, e->flags);
+				for_each_queue(e, i915, &cfg)
+					promotion(i915, &cfg, e->flags);
 			}
 
 			igt_subtest_with_dynamic("Q-smoketest") {
-				for_each_queue(e, i915)
-					smoketest(i915, e->flags, 5);
+				for_each_queue(e, i915, &cfg)
+					smoketest(i915, &cfg, e->flags, 5);
 			}
 
 			igt_subtest("Q-smoketest-all")
-				smoketest(i915, -1, 30);
+				smoketest(i915, &cfg, -1, 30);
 		}
 
 		igt_subtest("exhaust-shared-gtt")
-- 
2.31.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2021-06-14 16:37 UTC|newest]

Thread overview: 148+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-14 16:36 [igt-dev] [PATCH i-g-t 00/77] Stop depending on context mutation (v4) Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 01/77] tests/i915/gem_exec_fence: Move the engine data into inter_engine_context (v3) Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 02/77] tests/i915/gem_exec_fence: Convert to intel_ctx_t Jason Ekstrand
2021-06-15  1:57   ` Dixit, Ashutosh
2021-06-15  2:07     ` Dixit, Ashutosh
2021-06-15 18:10     ` Jason Ekstrand
2021-06-15 18:23       ` Dixit, Ashutosh
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 03/77] tests/i915/gem_exec_schedule: " Jason Ekstrand
2021-06-15 23:03   ` Dixit, Ashutosh
2021-06-16 16:46     ` Jason Ekstrand
2021-06-16 21:08       ` Dixit, Ashutosh
2021-06-16 23:38     ` Dixit, Ashutosh
2021-06-16 16:57   ` [igt-dev] [PATCH i-g-t] tests/i915/gem_shrink: Convert to intel_ctx_t (v3) Jason Ekstrand
2021-06-16 23:22     ` Dixit, Ashutosh
2021-06-17 15:56       ` Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 04/77] tests/i915/perf_pmu: Convert to intel_ctx_t (v2) Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 05/77] tests/i915/gem_exec_nop: Convert to intel_ctx_t Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 06/77] tests/i915/gem_exec_reloc: Convert to intel_ctx_t (v3) Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 07/77] tests/i915/gem_busy: Convert to intel_ctx_t (v2) Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 08/77] tests/i915/gem_ctx_isolation: " Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 09/77] tests/i915/gem_exec_async: " Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 10/77] tests/i915/sysfs_clients: Convert to intel_ctx_t Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 11/77] tests/i915/gem_exec_fair: " Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 12/77] tests/i915/gem_spin_batch: Convert to intel_ctx_t (v2) Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 13/77] tests/i915/gem_exec_store: " Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 14/77] tests/amdgpu/amd_prime: Convert to intel_ctx_t Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 15/77] tests/i915/i915_hangman: " Jason Ekstrand
2021-06-15 10:10   ` Zbigniew Kempczyński
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 16/77] tests/i915/gem_ringfill: " Jason Ekstrand
2021-06-15 10:46   ` Zbigniew Kempczyński
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 17/77] tests/prime_busy: " Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 18/77] tests/prime_vgem: Convert to intel_ctx_t (v2) Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 19/77] tests/gem_exec_whisper: Convert to intel_ctx_t Jason Ekstrand
2021-06-17  2:17   ` Dixit, Ashutosh
2021-06-17 18:31     ` Jason Ekstrand
2021-06-17 19:40       ` Dixit, Ashutosh
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 20/77] tests/i915/gem_ctx_exec: Stop cloning contexts in close_race Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 21/77] tests/i915/gem_ctx_exec: Convert to intel_ctx_t Jason Ekstrand
2021-06-14 17:26   ` Zbigniew Kempczyński
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 22/77] tests/i915/gem_exec_suspend: Convert to intel_ctx_t (v2) Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 23/77] tests/i915/gem_sync: Convert to intel_ctx_t Jason Ekstrand
2021-06-14 17:28   ` Zbigniew Kempczyński
2021-06-14 22:42     ` Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 24/77] tests/i915/gem_userptr_blits: " Jason Ekstrand
2021-06-14 17:31   ` Zbigniew Kempczyński
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 25/77] tests/i915/gem_wait: " Jason Ekstrand
2021-06-14 17:32   ` Zbigniew Kempczyński
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 26/77] tests/i915/gem_request_retire: " Jason Ekstrand
2021-06-14 17:36   ` Zbigniew Kempczyński
2021-06-14 16:36 ` Jason Ekstrand [this message]
2021-06-17  5:22   ` [igt-dev] [PATCH i-g-t 27/77] tests/i915/gem_ctx_shared: " Dixit, Ashutosh
2021-06-17 19:08     ` Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 28/77] tests/i915/gem_ctx_shared: Stop cloning contexts Jason Ekstrand
2021-06-17  6:28   ` Dixit, Ashutosh
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 29/77] tests/i915/gem_create: Convert to intel_ctx_t Jason Ekstrand
2021-06-14 17:39   ` Zbigniew Kempczyński
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 30/77] tests/i915/gem_ctx_switch: " Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 31/77] tests/i915/gem_exec_parallel: " Jason Ekstrand
2021-06-14 19:04   ` Zbigniew Kempczyński
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 32/77] tests/i915/gem_exec_latency: " Jason Ekstrand
2021-06-14 19:10   ` Zbigniew Kempczyński
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 33/77] tests/i915/gem_watchdog: Convert to intel_ctx_t (v2) Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 34/77] tests/i915/gem_shrink: Convert to intel_ctx_t Jason Ekstrand
2021-06-14 19:23   ` Zbigniew Kempczyński
2021-06-15 20:29     ` Jason Ekstrand
2021-06-15 20:30   ` [igt-dev] [PATCH i-g-t] tests/i915/gem_shrink: Convert to intel_ctx_t (v2) Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 35/77] tests/i915/gem_exec_params: Convert to intel_ctx_t Jason Ekstrand
2021-06-14 19:24   ` Zbigniew Kempczyński
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 36/77] tests/i915/gem_exec_gttfill: " Jason Ekstrand
2021-06-14 19:25   ` Zbigniew Kempczyński
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 37/77] tests/i915/gem_exec_capture: " Jason Ekstrand
2021-06-15  6:38   ` Zbigniew Kempczyński
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 38/77] tests/i915/gem_exec_create: " Jason Ekstrand
2021-06-15  6:45   ` Zbigniew Kempczyński
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 39/77] tests/i915/gem_exec_await: " Jason Ekstrand
2021-06-15  6:56   ` Zbigniew Kempczyński
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 40/77] tests/i915/gem_ctx_persistence: Drop the clone subtest Jason Ekstrand
2021-06-15  6:57   ` Zbigniew Kempczyński
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 41/77] tests/i915/gem_ctx_persistence: Drop the engine replace subtests Jason Ekstrand
2021-06-15  7:45   ` Zbigniew Kempczyński
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 42/77] tests/i915/gem_ctx_persistence: Convert to intel_ctx_t Jason Ekstrand
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 43/77] tests/i915/module_load: " Jason Ekstrand
2021-06-15  7:52   ` Zbigniew Kempczyński
2021-06-14 16:36 ` [igt-dev] [PATCH i-g-t 44/77] tests/i915/pm_rc6_residency: " Jason Ekstrand
2021-06-15  7:54   ` Zbigniew Kempczyński
2021-06-14 16:37 ` [igt-dev] [PATCH i-g-t 45/77] tests/i915/gem_cs_tlb: " Jason Ekstrand
2021-06-15  7:56   ` Zbigniew Kempczyński
2021-06-14 16:37 ` [igt-dev] [PATCH i-g-t 46/77] tests/core_hotplug: " Jason Ekstrand
2021-06-15  7:58   ` Zbigniew Kempczyński
2021-06-14 16:37 ` [igt-dev] [PATCH i-g-t 47/77] tests/i915/gem_exec_balancer: Stop cloning engines Jason Ekstrand
2021-06-14 16:37 ` [igt-dev] [PATCH i-g-t 48/77] tests/i915/gem_exec_balancer: Don't reset engines on a context Jason Ekstrand
2021-06-14 16:37 ` [igt-dev] [PATCH i-g-t 49/77] tests/i915/gem_exec_balancer: Stop munging ctx0 engines Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 50/77] tests/i915/gem_exec_balancer: Drop bonded tests Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 51/77] lib/intel_ctx: Add load balancing support (v2) Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 52/77] tests/i915/gem_exec_balancer: Convert to intel_ctx_t Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 53/77] tests/i915/gem_exec_endless: Stop munging ctx0 engines Jason Ekstrand
2021-06-15  8:40   ` Zbigniew Kempczyński
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 54/77] lib/i915: Use for_each_physical_ring for submission tests Jason Ekstrand
2021-06-15  8:44   ` Zbigniew Kempczyński
2021-06-15 18:23     ` Jason Ekstrand
2021-06-15 19:11       ` Dixit, Ashutosh
2021-06-16  4:55       ` Zbigniew Kempczyński
2021-06-16 17:09         ` Jason Ekstrand
2021-06-16 17:08   ` [igt-dev] [PATCH i-g-t] lib/i915: Use intel_ctx_0() for submission tests (v2) Jason Ekstrand
2021-06-16 20:28     ` Dixit, Ashutosh
2021-06-17 16:16       ` Jason Ekstrand
2021-06-17 17:17         ` Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 55/77] tests/i915/gem_ctx_engines: Rework execute-one* Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 56/77] tests/i915/gem_ctx_engines: Use better engine iteration Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 57/77] tests/i915/gem_ctx_engines: Drop the idempotent subtest Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 58/77] tests/i915/gem_ctx_create: Convert benchmarks to intel_ctx_t Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 59/77] tests/i915/gem_vm_create: Delete destroy racing tests Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 60/77] tests/i915/gem_vm_create: Use intel_ctx_t in the execbuf test Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 61/77] tests/i915/sysfs: Convert to intel_ctx_t Jason Ekstrand
2021-06-15 23:37   ` Dixit, Ashutosh
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 62/77] tests/i915/gem_workarounds: " Jason Ekstrand
2021-06-17  0:28   ` Dixit, Ashutosh
2021-06-17 15:59     ` Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 63/77] lib/i915/gem_context: Delete all the context clone/copy stuff Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 64/77] tests/i915/gem_ctx_engines: Delete the libapi subtest Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 65/77] lib/igt_dummyload: Stop supporting ALL_ENGINES without an intel_ctx_t Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 66/77] lib/i915/gem_engine_topology: Delete the old physical engine iterators Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 67/77] tests/i915/gem_mmap_gtt: Convert to intel_ctx_t Jason Ekstrand
2021-06-16  3:14   ` Dixit, Ashutosh
2021-06-23  5:29     ` Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 68/77] igt/dummyload: Require an intel_ctx_t for POLL_RUN and !ALL_ENGINES Jason Ekstrand
2021-06-16  2:25   ` Dixit, Ashutosh
2021-06-16  2:49     ` Dixit, Ashutosh
2021-06-16  2:56       ` Dixit, Ashutosh
2021-06-16 17:30         ` Jason Ekstrand
2021-06-17  3:57           ` Petri Latvala
2021-06-16 17:21       ` Jason Ekstrand
2021-06-16 17:25         ` Jason Ekstrand
2021-06-16 22:56           ` Dixit, Ashutosh
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 69/77] lib/i915: Rework engine API availability checks (v2) Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 70/77] lib/intel_bb: Remove intel_bb_assign_vm and tests (v2) Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 71/77] tests/i915/gem_ctx_param: Stop setting VMs on old contexts Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 72/77] tests/i915/gen9_exec_parse: Convert to intel_ctx_t Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 73/77] tests/i915/gem_ctx_param: Add tests for recently removed params Jason Ekstrand
2021-06-14 16:38 ` [igt-dev] [PATCH i-g-t 74/77] tests/i915/gem_ctx_param: Add a couple invalid PARAM_VM cases Jason Ekstrand
2021-06-14 16:39 ` [igt-dev] [PATCH i-g-t 75/77] tests/i915/gem_ctx_engines: Fix the invalid subtest for the new rules Jason Ekstrand
2021-06-14 16:39 ` [igt-dev] [PATCH i-g-t 76/77] tests/i915/gem_exec_balancer: Fix invalid-balancer for the set-once rule Jason Ekstrand
2021-06-14 16:39 ` [igt-dev] [PATCH i-g-t 77/77] tests/i915/gem_exec_balancer: Add a test for combind balancing and bonding (v2) Jason Ekstrand
2021-06-14 17:45 ` [igt-dev] ✓ Fi.CI.BAT: success for Stop depending on context mutation (rev8) Patchwork
2021-06-14 22:48 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2021-06-15 21:05 ` [igt-dev] ✓ Fi.CI.BAT: success for Stop depending on context mutation (rev9) Patchwork
2021-06-16  3:16 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2021-06-16 18:08 ` [igt-dev] ✗ Fi.CI.BUILD: failure for Stop depending on context mutation (rev11) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210614163704.365989-28-jason@jlekstrand.net \
    --to=jason@jlekstrand.net \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.