[PATCH i-g-t 12/46] tests/gem_ctx_exec: Adopt to use allocator

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Wed Jun 30 03:22:21 UTC 2021


Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
 tests/i915/gem_ctx_exec.c | 38 +++++++++++++++++++++++++++++++++-----
 1 file changed, 33 insertions(+), 5 deletions(-)

diff --git a/tests/i915/gem_ctx_exec.c b/tests/i915/gem_ctx_exec.c
index a8616f95c..e18a41be8 100644
--- a/tests/i915/gem_ctx_exec.c
+++ b/tests/i915/gem_ctx_exec.c
@@ -177,6 +177,7 @@ static void norecovery(int i915)
 		};
 		int expect = pass == 0 ? -EIO : 0;
 		igt_spin_t *spin;
+		uint64_t ahnd = get_reloc_ahnd(i915, param.ctx_id);
 
 		gem_context_set_param(i915, &param);
 
@@ -185,6 +186,7 @@ static void norecovery(int i915)
 		igt_assert_eq(param.value, pass);
 
 		spin = __igt_spin_new(i915,
+				      .ahnd = ahnd,
 				      .ctx_id = param.ctx_id,
 				      .flags = IGT_SPIN_POLL_RUN);
 		igt_spin_busywait_until_started(spin);
@@ -196,6 +198,7 @@ static void norecovery(int i915)
 		igt_spin_free(i915, spin);
 
 		gem_context_destroy(i915, param.ctx_id);
+		put_ahnd(ahnd);
 	}
 
 	 igt_disallow_hang(i915, hang);
@@ -271,6 +274,7 @@ static void nohangcheck_hostile(int i915)
 	uint32_t ctx;
 	int err = 0;
 	int dir;
+	uint64_t ahnd;
 
 	/*
 	 * Even if the user disables hangcheck during their context,
@@ -287,6 +291,7 @@ static void nohangcheck_hostile(int i915)
 
 	igt_require(__enable_hangcheck(dir, false));
 
+	ahnd = get_reloc_ahnd(i915, ctx);
 	____for_each_physical_engine(i915, ctx, e) {
 		igt_spin_t *spin;
 		int new;
@@ -296,6 +301,7 @@ static void nohangcheck_hostile(int i915)
 					   "preempt_timeout_ms", "%d", 50);
 
 		spin = __igt_spin_new(i915, ctx,
+				      .ahnd = ahnd,
 				      .engine = e->flags,
 				      .flags = (IGT_SPIN_NO_PREEMPTION |
 						IGT_SPIN_FENCE_OUT));
@@ -333,6 +339,7 @@ static void nohangcheck_hostile(int i915)
 
 	igt_assert_eq(sync_fence_status(fence), -EIO);
 	close(fence);
+	put_ahnd(ahnd);
 
 	close(dir);
 	close(i915);
@@ -343,9 +350,11 @@ static void close_race(int i915)
 	const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
 	uint32_t *contexts;
 	igt_spin_t *spin;
+	uint64_t ahnd = get_reloc_ahnd(i915, 0);
 
 	/* Check we can execute a polling spinner */
-	igt_spin_free(i915, igt_spin_new(i915, .flags = IGT_SPIN_POLL_RUN));
+	igt_spin_free(i915, igt_spin_new(i915, .ahnd = ahnd,
+					 .flags = IGT_SPIN_POLL_RUN));
 
 	contexts = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
 	igt_assert(contexts != MAP_FAILED);
@@ -354,7 +363,11 @@ static void close_race(int i915)
 		contexts[child] = gem_context_clone_with_engines(i915, 0);
 
 	igt_fork(child, ncpus) {
-		spin = __igt_spin_new(i915, .flags = IGT_SPIN_POLL_RUN);
+		ahnd = get_reloc_ahnd(i915, 0);
+
+		spin = __igt_spin_new(i915,
+				      .ahnd = ahnd,
+				      .flags = IGT_SPIN_POLL_RUN);
 		igt_spin_end(spin);
 		gem_sync(i915, spin->handle);
 
@@ -395,6 +408,7 @@ static void close_race(int i915)
 		}
 
 		igt_spin_free(i915, spin);
+		put_ahnd(ahnd);
 	}
 
 	igt_until_timeout(5) {
@@ -418,6 +432,7 @@ static void close_race(int i915)
 		gem_context_destroy(i915, contexts[child]);
 
 	munmap(contexts, 4096);
+	put_ahnd(ahnd);
 }
 
 igt_main
@@ -464,11 +479,22 @@ igt_main
 	igt_subtest("basic-nohangcheck")
 		nohangcheck_hostile(fd);
 
-	igt_subtest("basic-close-race")
-		close_race(fd);
+	igt_subtest_group {
+		igt_fixture {
+			intel_allocator_multiprocess_start();
+		}
+
+		igt_subtest("basic-close-race")
+				close_race(fd);
+
+		igt_fixture {
+			intel_allocator_multiprocess_stop();
+		}
+	}
 
 	igt_subtest("reset-pin-leak") {
 		int i;
+		uint64_t ahnd = get_reloc_ahnd(fd, 0);
 
 		/*
 		 * Use an explicit context to isolate the test from
@@ -483,7 +509,8 @@ igt_main
 		 * the last context is leaked at every reset.
 		 */
 		for (i = 0; i < 20; i++) {
-			igt_hang_t hang = igt_hang_ring(fd, 0);
+
+			igt_hang_t hang = igt_hang_ring_with_ahnd(fd, 0, ahnd);
 
 			igt_assert_eq(exec(fd, handle, 0, 0), 0);
 			igt_assert_eq(exec(fd, handle, 0, ctx_id), 0);
@@ -491,5 +518,6 @@ igt_main
 		}
 
 		gem_context_destroy(fd, ctx_id);
+		put_ahnd(ahnd);
 	}
 }
-- 
2.26.0



More information about the Intel-gfx-trybot mailing list