[PATCH i-g-t 31/36] WIP: tests/gem_ctx_shared: Convert to use no-reloc

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Tue Jun 22 03:46:29 UTC 2021


Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
 tests/i915/gem_ctx_shared.c | 67 +++++++++++++++++++++++++------------
 1 file changed, 46 insertions(+), 21 deletions(-)

diff --git a/tests/i915/gem_ctx_shared.c b/tests/i915/gem_ctx_shared.c
index aedf389c6..06a55b9c1 100644
--- a/tests/i915/gem_ctx_shared.c
+++ b/tests/i915/gem_ctx_shared.c
@@ -114,6 +114,7 @@ static void disjoint_timelines(int i915)
 	IGT_CORK_HANDLE(cork);
 	igt_spin_t *spin[2];
 	uint32_t plug, child;
+	uint64_t ahnd = get_reloc_ahnd(i915, 0);
 
 	igt_require(gem_has_execlists(i915));
 
@@ -125,8 +126,10 @@ static void disjoint_timelines(int i915)
 	child = gem_context_clone(i915, 0, I915_CONTEXT_CLONE_VM, 0);
 	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, .ahnd = ahnd,
+				 .ctx_id = 0, .dependency = plug);
+	spin[1] = __igt_spin_new(i915, .ahnd = ahnd,
+				 .ctx_id = child);
 
 	/* Wait for the second spinner, will hang if stuck behind the first */
 	igt_spin_end(spin[1]);
@@ -136,6 +139,7 @@ static void disjoint_timelines(int i915)
 
 	igt_spin_free(i915, spin[1]);
 	igt_spin_free(i915, spin[0]);
+	put_ahnd(ahnd);
 }
 
 static void exhaust_shared_gtt(int i915, unsigned int flags)
@@ -334,11 +338,12 @@ static void single_timeline(int i915)
 		.num_fences = 1,
 	};
 	igt_spin_t *spin;
+	uint64_t ahnd = get_reloc_ahnd(i915, 0);
 	int n;
 
 	igt_require(has_single_timeline(i915));
 
-	spin = igt_spin_new(i915);
+	spin = igt_spin_new(i915, .ahnd = ahnd);
 
 	/*
 	 * For a "single timeline" context, each ring is on the common
@@ -370,6 +375,7 @@ 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));
 	}
+	put_ahnd(ahnd);
 }
 
 static void exec_single_timeline(int i915, unsigned int engine)
@@ -377,19 +383,22 @@ static void exec_single_timeline(int i915, unsigned int engine)
 	const struct intel_execution_engine2 *e;
 	igt_spin_t *spin;
 	uint32_t ctx;
+	uint64_t ahnd;
 
 	/*
 	 * On an ordinary context, a blockage on one engine doesn't prevent
 	 * execution on an other.
 	 */
 	ctx = 0;
+	ahnd = get_reloc_ahnd(i915, ctx);
 	spin = NULL;
 	__for_each_physical_engine(i915, 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, .ahnd = ahnd,
+					      .ctx_id = ctx, .engine = e->flags);
 		} else {
 			struct drm_i915_gem_execbuffer2 execbuf = {
 				.buffers_ptr = spin->execbuf.buffers_ptr,
@@ -417,7 +426,8 @@ static void exec_single_timeline(int i915, unsigned int engine)
 			continue;
 
 		if (spin == NULL) {
-			spin = __igt_spin_new(i915, .ctx_id = ctx, .engine = e->flags);
+			spin = __igt_spin_new(i915, .ahnd = ahnd,
+					      .ctx_id = ctx, .engine = e->flags);
 		} else {
 			struct drm_i915_gem_execbuffer2 execbuf = {
 				.buffers_ptr = spin->execbuf.buffers_ptr,
@@ -431,9 +441,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);
+	put_ahnd(ahnd);
 }
 
-static void store_dword(int i915, uint32_t ctx, unsigned ring,
+static void store_dword(int i915, uint64_t ahnd, uint32_t ctx, unsigned ring,
 			uint32_t target, uint32_t offset, uint32_t value,
 			uint32_t cork, unsigned write_domain)
 {
@@ -469,7 +480,8 @@ static void store_dword(int i915, uint32_t ctx, unsigned ring,
 	reloc.read_domains = I915_GEM_DOMAIN_INSTRUCTION;
 	reloc.write_domain = write_domain;
 	obj[2].relocs_ptr = to_user_pointer(&reloc);
-	obj[2].relocation_count = 1;
+	if (!ahnd)
+		obj[2].relocation_count = 1;
 
 	i = 0;
 	batch[i] = MI_STORE_DWORD_IMM | (gen < 6 ? 1 << 22 : 0);
@@ -491,6 +503,7 @@ 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)
 {
 	uint32_t ctx = gem_context_clone_with_engines(i915, 0);
@@ -505,7 +518,8 @@ static uint32_t create_highest_priority(int i915)
 	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, unsigned int engine,
+			      uint64_t ahnd)
 {
 	igt_spin_t *spin[MAX_ELSP_QLEN];
 
@@ -513,6 +527,7 @@ static void unplug_show_queue(int i915, struct igt_cork *c, unsigned int engine)
 		const struct igt_spin_factory opts = {
 			.ctx_id = create_highest_priority(i915),
 			.engine = engine,
+			.ahnd = ahnd,
 		};
 		spin[n] = __igt_spin_factory(i915, &opts);
 		gem_context_destroy(i915, opts.ctx_id);
@@ -526,6 +541,7 @@ static void unplug_show_queue(int i915, struct igt_cork *c, unsigned int engine)
 }
 
 static uint32_t store_timestamp(int i915,
+				uint64_t ahnd,
 				uint32_t ctx, unsigned ring,
 				unsigned mmio_base,
 				int fence,
@@ -535,7 +551,7 @@ static uint32_t store_timestamp(int i915,
 	uint32_t handle = gem_create(i915, 4096);
 	struct drm_i915_gem_exec_object2 obj = {
 		.handle = handle,
-		.relocation_count = 1,
+		.relocation_count = !ahnd ? 1 : 0,
 		.offset = (32 << 20) + (handle << 16),
 	};
 	struct drm_i915_gem_relocation_entry reloc = {
@@ -587,6 +603,7 @@ static void independent(int i915,
 	unsigned int mmio_base;
 	IGT_CORK_FENCE(cork);
 	int fence;
+	uint64_t ahnd = get_reloc_ahnd(i915, 0);
 
 	mmio_base = gem_engine_mmio_base(i915, e->name);
 	igt_require_f(mmio_base, "mmio base not known\n");
@@ -595,6 +612,7 @@ static void independent(int i915,
 		const struct igt_spin_factory opts = {
 			.ctx_id = create_highest_priority(i915),
 			.engine = e->flags,
+			.ahnd = ahnd,
 		};
 		spin[n] = __igt_spin_factory(i915, &opts);
 		gem_context_destroy(i915, opts.ctx_id);
@@ -604,7 +622,7 @@ static void independent(int 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]);
-		handle[i] = store_timestamp(i915, ctx,
+		handle[i] = store_timestamp(i915, ahnd, ctx,
 					    e->flags, mmio_base,
 					    fence, TIMESTAMP);
 		gem_context_destroy(i915, ctx);
@@ -634,6 +652,7 @@ static void independent(int i915,
 	}
 
 	igt_assert((int32_t)(handle[HI] - handle[LO]) < 0);
+	put_ahnd(ahnd);
 }
 
 static void reorder(int i915, unsigned ring, unsigned flags)
@@ -644,6 +663,7 @@ static void reorder(int i915, unsigned ring, unsigned flags)
 	uint32_t *ptr;
 	uint32_t ctx[2];
 	uint32_t plug;
+	uint64_t ahnd = get_reloc_ahnd(i915, 0);
 
 	ctx[LO] = gem_queue_create(i915);
 	gem_context_set_priority(i915, ctx[LO], MIN_PRIO);
@@ -657,10 +677,10 @@ 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, ahnd, ctx[LO], ring, scratch, 0, ctx[LO], plug, 0);
+	store_dword(i915, ahnd, ctx[HI], ring, scratch, 0, ctx[HI], plug, 0);
 
-	unplug_show_queue(i915, &cork, ring);
+	unplug_show_queue(i915, &cork, ring, ahnd);
 	gem_close(i915, plug);
 
 	gem_context_destroy(i915, ctx[LO]);
@@ -676,6 +696,7 @@ static void reorder(int i915, unsigned ring, unsigned flags)
 	else
 		igt_assert_eq_u32(ptr[0], ctx[LO]);
 	munmap(ptr, 4096);
+	put_ahnd(ahnd);
 }
 
 static void promotion(int i915, unsigned ring)
@@ -685,6 +706,7 @@ static void promotion(int i915, unsigned ring)
 	uint32_t *ptr;
 	uint32_t ctx[3];
 	uint32_t plug;
+	uint64_t ahnd = get_reloc_ahnd(i915, 0);
 
 	ctx[LO] = gem_queue_create(i915);
 	gem_context_set_priority(i915, ctx[LO], MIN_PRIO);
@@ -705,16 +727,16 @@ 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, ahnd, ctx[NOISE], ring, result, 0, ctx[NOISE], plug, 0);
+	store_dword(i915, ahnd, ctx[LO], ring, result, 0, ctx[LO], 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, ahnd, ctx[LO], ring, dep, 0, ctx[LO], 0, I915_GEM_DOMAIN_INSTRUCTION);
+	store_dword(i915, ahnd, ctx[HI], ring, dep, 0, ctx[HI], 0, 0);
 
-	store_dword(i915, ctx[HI], ring, result, 0, ctx[HI], 0, 0);
+	store_dword(i915, ahnd, ctx[HI], ring, result, 0, ctx[HI], 0, 0);
 
-	unplug_show_queue(i915, &cork, ring);
+	unplug_show_queue(i915, &cork, ring, ahnd);
 	gem_close(i915, plug);
 
 	gem_context_destroy(i915, ctx[NOISE]);
@@ -736,6 +758,7 @@ static void promotion(int i915, unsigned ring)
 
 	igt_assert_eq_u32(ptr[0], ctx[NOISE]);
 	munmap(ptr, 4096);
+	put_ahnd(ahnd);
 }
 
 static void smoketest(int i915, unsigned ring, unsigned timeout)
@@ -746,6 +769,7 @@ static void smoketest(int i915, unsigned ring, unsigned timeout)
 	unsigned engine;
 	uint32_t scratch;
 	uint32_t *ptr;
+	uint64_t ahnd = get_reloc_ahnd(i915, 0);
 
 	nengine = 0;
 	if (ring == -1) {
@@ -773,11 +797,11 @@ static void smoketest(int i915, unsigned ring, unsigned timeout)
 			gem_context_set_priority(i915, ctx, prio);
 
 			engine = engines[hars_petruska_f54_1_random_unsafe_max(nengine)];
-			store_dword(i915, ctx, engine, scratch,
+			store_dword(i915, ahnd, ctx, engine, scratch,
 				    8*child + 0, ~child,
 				    0, 0);
 			for (unsigned int step = 0; step < 8; step++)
-				store_dword(i915, ctx, engine, scratch,
+				store_dword(i915, ahnd, ctx, engine, scratch,
 					    8*child + 4, count++,
 					    0, 0);
 		}
@@ -801,6 +825,7 @@ static void smoketest(int i915, unsigned ring, unsigned timeout)
 		igt_info("Child[%d] completed %u cycles\n",  n, ptr[2*n+1]);
 	}
 	munmap(ptr, 4096);
+	put_ahnd(ahnd);
 }
 
 #define for_each_queue(e, i915) \
-- 
2.26.0



More information about the Intel-gfx-trybot mailing list