[igt-dev] [PATCH i-g-t 14/93] tests/i915/gem_exec_basic: Convert to intel_ctx_t

Jason Ekstrand jason at jlekstrand.net
Wed Jun 9 04:30:00 UTC 2021


This acts as a template for the rest of this patch series.  The rough
idea is that we create a new context if the HW supports contexts and
otherwise we use intel_ctx_0().  Once we have an intel_ctx_t, we can
iterate over all of the engines in it in a consistent way.

Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
---
 tests/i915/gem_exec_basic.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/i915/gem_exec_basic.c b/tests/i915/gem_exec_basic.c
index 872b1d3b..ae7c275d 100644
--- a/tests/i915/gem_exec_basic.c
+++ b/tests/i915/gem_exec_basic.c
@@ -45,10 +45,13 @@ igt_main
 	struct drm_i915_query_memory_regions *query_info;
 	struct igt_collection *regions, *set;
 	uint32_t batch_size;
+	const intel_ctx_t *ctx = NULL;
 	int fd = -1;
 
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_INTEL);
+		ctx = intel_ctx_create_all_physical(fd);
+
 		/* igt_require_gem(fd); // test is mandatory */
 		igt_fork_hang_detector(fd);
 
@@ -70,12 +73,13 @@ igt_main
 			memset(&exec, 0, sizeof(exec));
 			exec.handle = batch_create(fd, batch_size, region);
 
-			__for_each_physical_engine(fd, e) {
+			for_each_ctx_engine(fd, ctx, e) {
 				igt_dynamic_f("%s-%s", e->name, sub_name) {
 					struct drm_i915_gem_execbuffer2 execbuf = {
 						.buffers_ptr = to_user_pointer(&exec),
 						.buffer_count = 1,
 						.flags = e->flags,
+						.rsvd1 = ctx->id,
 					};
 
 					gem_execbuf(fd, &execbuf);
@@ -91,6 +95,7 @@ igt_main
 		free(query_info);
 		igt_collection_destroy(set);
 		igt_stop_hang_detector();
+		intel_ctx_destroy(fd, ctx);
 		close(fd);
 	}
 }
-- 
2.31.1



More information about the igt-dev mailing list