[PATCH i-g-t 40/47] WIP: gem_exec_schedule

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Wed Jun 30 08:39:56 UTC 2021


---
 tests/i915/gem_exec_schedule.c | 57 +++++++++++++++++++++++++---------
 1 file changed, 43 insertions(+), 14 deletions(-)

diff --git a/tests/i915/gem_exec_schedule.c b/tests/i915/gem_exec_schedule.c
index 59108b1f5..c3fa2a773 100644
--- a/tests/i915/gem_exec_schedule.c
+++ b/tests/i915/gem_exec_schedule.c
@@ -1722,12 +1722,18 @@ static void __preempt_queue(int fd,
 	const struct intel_execution_engine2 *e;
 	uint32_t result = gem_create(fd, 4096);
 	uint32_t result_read[4096 / sizeof(uint32_t)];
+	uint64_t result_offset;
 	igt_spin_t *above = NULL, *below = NULL;
 	uint32_t ctx[3] = {
 		gem_context_clone_with_engines(fd, 0),
 		gem_context_clone_with_engines(fd, 0),
 		gem_context_clone_with_engines(fd, 0),
 	};
+	uint64_t ahnd[3] = {
+		get_reloc_ahnd(fd, ctx[0]),
+		get_reloc_ahnd(fd, ctx[1]),
+		get_reloc_ahnd(fd, ctx[2]),
+	};
 	int prio = MAX_PRIO;
 	unsigned int n, i;
 
@@ -1736,7 +1742,7 @@ static void __preempt_queue(int fd,
 			gem_context_destroy(fd, ctx[NOISE]);
 			ctx[NOISE] = gem_context_clone_with_engines(fd, 0);
 		}
-		//above = __noise(fd, ctx[NOISE], prio--, above);
+		above = __noise(fd, ahnd[NOISE], ctx[NOISE], prio--, above);
 	}
 
 	gem_context_set_priority(fd, ctx[HI], prio--);
@@ -1746,28 +1752,31 @@ static void __preempt_queue(int fd,
 			gem_context_destroy(fd, ctx[NOISE]);
 			ctx[NOISE] = gem_context_clone_with_engines(fd, 0);
 		}
-		//below = __noise(fd, ctx[NOISE], prio--, below);
+		below = __noise(fd, ahnd[NOISE], ctx[NOISE], prio--, below);
 	}
 
 	gem_context_set_priority(fd, ctx[LO], prio--);
 
 	n = 0;
-	store_dword(fd, ctx[LO], primary,
-		    result, (n + 1)*sizeof(uint32_t), n + 1,
+	result_offset = get_offset(ahnd[LO], result, 4096, 0);
+	store_dword2(fd, ahnd[LO], ctx[LO], primary,
+		    result, result_offset, (n + 1)*sizeof(uint32_t), n + 1,
 		    I915_GEM_DOMAIN_RENDER);
 	n++;
 
 	if (flags & CHAIN) {
 		__for_each_physical_engine(fd, e) {
-			store_dword(fd, ctx[LO], e->flags,
-				    result, (n + 1)*sizeof(uint32_t), n + 1,
+			store_dword2(fd, ahnd[LO], ctx[LO], e->flags,
+				    result, result_offset,
+				     (n + 1)*sizeof(uint32_t), n + 1,
 				    I915_GEM_DOMAIN_RENDER);
 			n++;
 		}
 	}
 
-	store_dword(fd, ctx[HI], target,
-		    result, (n + 1)*sizeof(uint32_t), n + 1,
+	result_offset = get_offset(ahnd[HI], result, 4096, 0);
+	store_dword2(fd, ahnd[HI], ctx[HI], target,
+		    result, result_offset, (n + 1)*sizeof(uint32_t), n + 1,
 		    I915_GEM_DOMAIN_RENDER);
 
 	igt_debugfs_dump(fd, "i915_engine_info");
@@ -1793,6 +1802,9 @@ static void __preempt_queue(int fd,
 	gem_context_destroy(fd, ctx[LO]);
 	gem_context_destroy(fd, ctx[NOISE]);
 	gem_context_destroy(fd, ctx[HI]);
+	put_ahnd(ahnd[LO]);
+	put_ahnd(ahnd[NOISE]);
+	put_ahnd(ahnd[HI]);
 
 	gem_close(fd, result);
 }
@@ -1838,6 +1850,7 @@ static void preempt_engines(int i915,
 	} pnode[I915_EXEC_RING_MASK + 1], *p;
 	IGT_LIST_HEAD(plist);
 	igt_spin_t *spin, *sn;
+	uint64_t ahnd = get_reloc_ahnd(i915, param.ctx_id);
 
 	/*
 	 * A quick test that each engine within a context is an independent
@@ -1858,7 +1871,8 @@ static void preempt_engines(int i915,
 		unsigned int engine = n & I915_EXEC_RING_MASK;
 
 		gem_context_set_priority(i915, param.ctx_id, n);
-		spin = igt_spin_new(i915, param.ctx_id, .engine = engine);
+		spin = igt_spin_new(i915, .ahnd = ahnd, .ctx_id = param.ctx_id,
+				    .engine = engine);
 
 		igt_list_move_tail(&spin->link, &pnode[engine].spinners);
 		igt_list_move(&pnode[engine].link, &plist);
@@ -1872,6 +1886,7 @@ static void preempt_engines(int i915,
 		}
 	}
 	gem_context_destroy(i915, param.ctx_id);
+	put_ahnd(ahnd);
 }
 
 static void preempt_self(int fd, unsigned ring)
@@ -1882,6 +1897,7 @@ static void preempt_self(int fd, unsigned ring)
 	igt_spin_t *spin[MAX_ELSP_QLEN];
 	unsigned int n, i;
 	uint32_t ctx[3];
+	uint64_t ahnd[3], result_offset;
 
 	/* On each engine, insert
 	 * [NOISE] spinner,
@@ -1893,21 +1909,26 @@ static void preempt_self(int fd, unsigned ring)
 
 	ctx[NOISE] = gem_context_clone_with_engines(fd, 0);
 	ctx[HI] = gem_context_clone_with_engines(fd, 0);
+	ahnd[NOISE] = get_reloc_ahnd(fd, ctx[NOISE]);
+	ahnd[HI] = get_reloc_ahnd(fd, ctx[HI]);
+	result_offset = get_offset(ahnd[HI], result, 4096, 0);
 
 	n = 0;
 	gem_context_set_priority(fd, ctx[HI], MIN_PRIO);
 	__for_each_physical_engine(fd, e) {
 		spin[n] = __igt_spin_new(fd,
+					 .ahnd = ahnd[NOISE],
 					 .ctx_id = ctx[NOISE],
 					 .engine = e->flags);
-		store_dword(fd, ctx[HI], e->flags,
-			    result, (n + 1)*sizeof(uint32_t), n + 1,
+		store_dword2(fd, ahnd[HI], ctx[HI], e->flags,
+			    result, result_offset,
+			     (n + 1)*sizeof(uint32_t), n + 1,
 			    I915_GEM_DOMAIN_RENDER);
 		n++;
 	}
 	gem_context_set_priority(fd, ctx[HI], MAX_PRIO);
-	store_dword(fd, ctx[HI], ring,
-		    result, (n + 1)*sizeof(uint32_t), n + 1,
+	store_dword2(fd, ahnd[HI], ctx[HI], ring,
+		    result, result_offset, (n + 1)*sizeof(uint32_t), n + 1,
 		    I915_GEM_DOMAIN_RENDER);
 
 	gem_set_domain(fd, result, I915_GEM_DOMAIN_GTT, 0);
@@ -1925,6 +1946,8 @@ static void preempt_self(int fd, unsigned ring)
 
 	gem_context_destroy(fd, ctx[NOISE]);
 	gem_context_destroy(fd, ctx[HI]);
+	put_ahnd(ahnd[NOISE]);
+	put_ahnd(ahnd[HI]);
 
 	gem_close(fd, result);
 }
@@ -1934,25 +1957,29 @@ static void preemptive_hang(int fd, const struct intel_execution_engine2 *e)
 	igt_spin_t *spin[MAX_ELSP_QLEN];
 	igt_hang_t hang;
 	uint32_t ctx[2];
+	uint64_t ahnd_hi, ahnd_lo[MAX_ELSP_QLEN];
 
 	/* Set a fast timeout to speed the test up (if available) */
 	set_preempt_timeout(fd, e, 150);
 
 	ctx[HI] = gem_context_clone_with_engines(fd, 0);
 	gem_context_set_priority(fd, ctx[HI], MAX_PRIO);
+	ahnd_hi = get_reloc_ahnd(fd, ctx[HI]);
 
 	for (int n = 0; n < ARRAY_SIZE(spin); n++) {
 		ctx[LO] = gem_context_clone_with_engines(fd, 0);
 		gem_context_set_priority(fd, ctx[LO], MIN_PRIO);
+		ahnd_lo[n] = get_reloc_ahnd(fd, ctx[LO]);
 
 		spin[n] = __igt_spin_new(fd,
+					 .ahnd = ahnd_lo[n],
 					 .ctx_id = ctx[LO],
 					 .engine = e->flags);
 
 		gem_context_destroy(fd, ctx[LO]);
 	}
 
-	hang = igt_hang_ctx(fd, ctx[HI], e->flags, 0);
+	hang = igt_hang_ctx_with_ahnd(fd, ahnd_hi, ctx[HI], e->flags, 0);
 	igt_post_hang_ring(fd, hang);
 
 	for (int n = 0; n < ARRAY_SIZE(spin); n++) {
@@ -1962,9 +1989,11 @@ static void preemptive_hang(int fd, const struct intel_execution_engine2 *e)
 		 */
 		igt_assert(gem_bo_busy(fd, spin[n]->handle));
 		igt_spin_free(fd, spin[n]);
+		put_ahnd(ahnd_lo[n]);
 	}
 
 	gem_context_destroy(fd, ctx[HI]);
+	put_ahnd(ahnd_hi);
 }
 
 static void deep(int fd, unsigned ring)
-- 
2.26.0



More information about the Intel-gfx-trybot mailing list