[PATCH i-g-t 24/52] tests/gem_exec_async: Add no-reloc for gens without relocations.

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Thu Jul 1 12:37:04 UTC 2021


Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
 tests/i915/gem_exec_async.c | 40 ++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/tests/i915/gem_exec_async.c b/tests/i915/gem_exec_async.c
index bf8a856a6..1ee48ad61 100644
--- a/tests/i915/gem_exec_async.c
+++ b/tests/i915/gem_exec_async.c
@@ -27,8 +27,9 @@
 
 IGT_TEST_DESCRIPTION("Check that we can issue concurrent writes across the engines.");
 
-static void store_dword(int fd, unsigned ring,
-			uint32_t target, uint32_t offset, uint32_t value)
+static void store_dword(int fd, uint64_t ahnd, unsigned ring,
+			uint32_t target, uint64_t target_offset,
+			uint32_t offset, uint32_t value)
 {
 	const unsigned int gen = intel_gen(intel_get_drm_devid(fd));
 	struct drm_i915_gem_exec_object2 obj[2];
@@ -48,6 +49,14 @@ static void store_dword(int fd, unsigned ring,
 	obj[0].handle = target;
 	obj[0].flags = EXEC_OBJECT_ASYNC;
 	obj[1].handle = gem_create(fd, 4096);
+	if (ahnd) {
+		obj[0].offset = target_offset;
+		obj[0].flags |= EXEC_OBJECT_PINNED | EXEC_OBJECT_WRITE |
+				EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
+		obj[1].offset = get_offset(ahnd, obj[1].handle, 4096, 0);
+		obj[1].flags |= EXEC_OBJECT_PINNED |
+				EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
+	}
 
 	memset(&reloc, 0, sizeof(reloc));
 	reloc.target_handle = obj[0].handle;
@@ -57,12 +66,12 @@ static void store_dword(int fd, unsigned ring,
 	reloc.read_domains = I915_GEM_DOMAIN_INSTRUCTION;
 	reloc.write_domain = I915_GEM_DOMAIN_INSTRUCTION;
 	obj[1].relocs_ptr = to_user_pointer(&reloc);
-	obj[1].relocation_count = 1;
+	obj[1].relocation_count = !ahnd ? 1 : 0;
 
 	i = 0;
 	batch[i] = MI_STORE_DWORD_IMM | (gen < 6 ? 1 << 22 : 0);
 	if (gen >= 8) {
-		batch[++i] = offset;
+		batch[++i] = target_offset + offset;
 		batch[++i] = 0;
 	} else if (gen >= 4) {
 		batch[++i] = 0;
@@ -87,6 +96,8 @@ static void one(int fd, unsigned engine, unsigned int flags)
 	uint32_t scratch = gem_create(fd, 4096);
 	igt_spin_t *spin;
 	uint32_t *result;
+	uint64_t ahnd = get_reloc_ahnd(fd, 0);
+	uint64_t scratch_offset;
 	int i;
 
 	/*
@@ -94,7 +105,9 @@ static void one(int fd, unsigned engine, unsigned int flags)
 	 * the scratch for write. Then on the other rings try and
 	 * write into that target. If it blocks we hang the GPU...
 	 */
-	spin = igt_spin_new(fd, .engine = engine, .dependency = scratch);
+	spin = igt_spin_new(fd, .ahnd = ahnd,
+			    .engine = engine, .dependency = scratch);
+	scratch_offset = spin->obj[0].offset;
 
 	i = 0;
 	__for_each_physical_engine(fd, e) {
@@ -105,10 +118,16 @@ static void one(int fd, unsigned engine, unsigned int flags)
 			continue;
 
 		if (flags & FORKED) {
-			igt_fork(child, 1)
-				store_dword(fd, e->flags, scratch, 4*i, ~i);
+			igt_fork(child, 1) {
+				ahnd = get_reloc_ahnd(fd, 0);
+				store_dword(fd, ahnd, e->flags,
+					    scratch, scratch_offset,
+					    4*i, ~i);
+				put_ahnd(ahnd);
+			}
 		} else {
-			store_dword(fd, e->flags, scratch, 4*i, ~i);
+			store_dword(fd, ahnd, e->flags, scratch, scratch_offset,
+				    4*i, ~i);
 		}
 		i++;
 	}
@@ -155,8 +174,11 @@ igt_main
 	test_each_engine("concurrent-writes", fd, e)
 		one(fd, e->flags, 0);
 
-	test_each_engine("forked-writes", fd, e)
+	test_each_engine("forked-writes", fd, e) {
+		intel_allocator_multiprocess_start();
 		one(fd, e->flags, FORKED);
+		intel_allocator_multiprocess_stop();
+	}
 
 	igt_fixture {
 		igt_stop_hang_detector();
-- 
2.26.0



More information about the Intel-gfx-trybot mailing list