[PATCH i-g-t 1/6] tests/i915/gem_exec_capture: Propagate the context

Thomas Hellström thomas.hellstrom at linux.intel.com
Sun Oct 24 17:16:36 UTC 2021


From: Thomas Hellström <thomas.hellstrom at intel.com>

Propagate the context to the various capture function instead of using
a default context id of 0. This stops us from receiving occasional -5
errors from execbuf.

Signed-off-by: Thomas Hellström <thomas.hellstrom at intel.com>
---
 tests/i915/gem_exec_capture.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/tests/i915/gem_exec_capture.c b/tests/i915/gem_exec_capture.c
index 7e0a8b8a..d5f16d93 100644
--- a/tests/i915/gem_exec_capture.c
+++ b/tests/i915/gem_exec_capture.c
@@ -209,8 +209,8 @@ static int cmp(const void *A, const void *B)
 static struct offset {
 	uint64_t addr;
 	unsigned long idx;
-} *__captureN(int fd, int dir, uint64_t ahnd, unsigned ring,
-	      unsigned int size, int count,
+} *__captureN(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx,
+	      unsigned ring, unsigned int size, int count,
 	      unsigned int flags)
 #define INCREMENTAL 0x1
 #define ASYNC 0x2
@@ -325,6 +325,7 @@ static struct offset {
 	execbuf.buffers_ptr = (uintptr_t)obj;
 	execbuf.buffer_count = count + 2;
 	execbuf.flags = ring;
+	execbuf.rsvd1 = ctx->id;
 	if (gen > 3 && gen < 6)
 		execbuf.flags |= I915_EXEC_SECURE;
 
@@ -443,7 +444,8 @@ ascii85_decode(char *in, uint32_t **out, bool inflate, char **end)
 	return zlib_inflate(out, len);
 }
 
-static void many(int fd, int dir, uint64_t size, unsigned int flags)
+static void many(int fd, int dir, const intel_ctx_t *ctx, uint64_t size,
+		 unsigned int flags)
 {
 	uint64_t ram, gtt, ahnd;
 	unsigned long count, blobs;
@@ -459,9 +461,9 @@ static void many(int fd, int dir, uint64_t size, unsigned int flags)
 	igt_require(count > 1);
 
 	intel_require_memory(count, size, CHECK_RAM);
-	ahnd = get_reloc_ahnd(fd, 0);
+	ahnd = get_reloc_ahnd(fd, ctx->id);
 
-	offsets = __captureN(fd, dir, ahnd, 0, size, count, flags);
+	offsets = __captureN(fd, dir, ahnd, ctx, 0, size, count, flags);
 
 	error = igt_sysfs_get(dir, "error");
 	igt_sysfs_set(dir, "error", "Begone!");
@@ -585,7 +587,8 @@ static void prioinv(int fd, int dir, const intel_ctx_t *ctx,
 		/* Reopen the allocator in the new process. */
 		ahnd = get_reloc_ahnd(fd, 0);
 
-		free(__captureN(fd, dir, ahnd, ring, size, count, ASYNC));
+		free(__captureN(fd, dir, ahnd, intel_ctx_0(fd), ring, size,
+				count, ASYNC));
 		put_ahnd(ahnd);
 
 		write(link[1], &fd, sizeof(fd)); /* wake the parent up */
@@ -625,7 +628,7 @@ static void userptr(int fd, int dir)
 	igt_require(__gem_userptr(fd, ptr, 4096, 0, 0, &handle) == 0);
 	ahnd = get_reloc_ahnd(fd, ctx->id);
 
-	__capture1(fd, dir, ahnd, intel_ctx_0(fd), 0, handle, 4096);
+	__capture1(fd, dir, ahnd, ctx, 0, handle, 4096);
 
 	gem_close(fd, handle);
 	put_ahnd(ahnd);
@@ -687,27 +690,27 @@ igt_main
 
 	igt_subtest_f("many-4K-zero") {
 		igt_require(gem_can_store_dword(fd, 0));
-		many(fd, dir, 1<<12, 0);
+		many(fd, dir, ctx, 1<<12, 0);
 	}
 
 	igt_subtest_f("many-4K-incremental") {
 		igt_require(gem_can_store_dword(fd, 0));
-		many(fd, dir, 1<<12, INCREMENTAL);
+		many(fd, dir, ctx, 1<<12, INCREMENTAL);
 	}
 
 	igt_subtest_f("many-2M-zero") {
 		igt_require(gem_can_store_dword(fd, 0));
-		many(fd, dir, 2<<20, 0);
+		many(fd, dir, ctx, 2<<20, 0);
 	}
 
 	igt_subtest_f("many-2M-incremental") {
 		igt_require(gem_can_store_dword(fd, 0));
-		many(fd, dir, 2<<20, INCREMENTAL);
+		many(fd, dir, ctx, 2<<20, INCREMENTAL);
 	}
 
 	igt_subtest_f("many-256M-incremental") {
 		igt_require(gem_can_store_dword(fd, 0));
-		many(fd, dir, 256<<20, INCREMENTAL);
+		many(fd, dir, ctx, 256<<20, INCREMENTAL);
 	}
 
 	/* And check we can read from different types of objects */
-- 
2.31.1



More information about the Intel-gfx-trybot mailing list