[PATCH i-g-t 53/58] WIP: tests/gem_exec_schedule

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Tue Jul 6 07:09:30 UTC 2021


---
 tests/i915/gem_exec_schedule.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/tests/i915/gem_exec_schedule.c b/tests/i915/gem_exec_schedule.c
index d2b34ab02..59108b1f5 100644
--- a/tests/i915/gem_exec_schedule.c
+++ b/tests/i915/gem_exec_schedule.c
@@ -1531,8 +1531,10 @@ static void preempt(int fd, const struct intel_execution_engine2 *e, unsigned fl
 	igt_spin_t *spin[MAX_ELSP_QLEN];
 	uint32_t ctx[2];
 	igt_hang_t hang;
-	uint64_t ahnd = get_reloc_ahnd(fd, 0), ahnd_lo;
+	uint64_t ahnd = get_reloc_ahnd(fd, 0);
+	uint64_t ahnd_lo_arr[MAX_ELSP_QLEN], ahnd_lo;
 	uint64_t result_offset = get_offset(ahnd, result, 4096, 0);
+	int n;
 
 	/* Set a fast timeout to speed the test up (if available) */
 	set_preempt_timeout(fd, e, 150);
@@ -1545,19 +1547,21 @@ static void preempt(int fd, const struct intel_execution_engine2 *e, unsigned fl
 	gem_context_set_priority(fd, ctx[HI], MAX_PRIO);
 
 	if (flags & HANG_LP)
-		hang = igt_hang_ctx(fd, ctx[LO], e->flags, 0);
+		hang = igt_hang_ctx_with_ahnd(fd, ahnd_lo, ctx[LO], e->flags, 0);
+
+	for (n = 0; n < ARRAY_SIZE(spin); n++) {
+		uint64_t currahnd = ahnd_lo;
 
-	for (int n = 0; n < ARRAY_SIZE(spin); n++) {
 		if (flags & NEW_CTX) {
-			put_ahnd(ahnd_lo);
 			gem_context_destroy(fd, ctx[LO]);
 			ctx[LO] = gem_context_clone_with_engines(fd, 0);
 			gem_context_set_priority(fd, ctx[LO], MIN_PRIO);
-			ahnd_lo = get_reloc_ahnd(fd, ctx[LO]);
+			ahnd_lo_arr[n] = get_reloc_ahnd(fd, ctx[LO]);
+			currahnd = ahnd_lo_arr[n];
 		}
 
 		spin[n] = __igt_spin_new(fd,
-					 .ahnd = ahnd_lo,
+					 .ahnd = currahnd,
 					 .ctx_id = ctx[LO],
 					 .engine = e->flags,
 					 .flags = flags & USERPTR ? IGT_SPIN_USERPTR : 0);
@@ -1571,7 +1575,7 @@ static void preempt(int fd, const struct intel_execution_engine2 *e, unsigned fl
 		igt_assert(gem_bo_busy(fd, spin[0]->handle));
 	}
 
-	for (int n = 0; n < ARRAY_SIZE(spin); n++)
+	for (n = 0; n < ARRAY_SIZE(spin); n++)
 		igt_spin_free(fd, spin[n]);
 
 	if (flags & HANG_LP)
@@ -1582,6 +1586,11 @@ static void preempt(int fd, const struct intel_execution_engine2 *e, unsigned fl
 	put_ahnd(ahnd);
 	put_ahnd(ahnd_lo);
 
+	if (flags & NEW_CTX) {
+		for (n = 0; n < ARRAY_SIZE(spin); n++)
+			put_ahnd(ahnd_lo_arr[n]);
+	}
+
 	gem_close(fd, result);
 }
 
-- 
2.26.0



More information about the Intel-gfx-trybot mailing list