[igt-dev] [RFC v2 22/43] tests/i915/gem_exec_latency: use the gem_engine_topology library

Ramalingam C ramalingam.c at intel.com
Fri Jun 21 10:03:24 UTC 2019


Replace the legacy for_each_engine* defines with the ones
implemented in the gem_engine_topology library.

Signed-off-by: Ramalingam C <ramalingam.c at intel.com>
---
 tests/i915/gem_exec_latency.c | 103 ++++++++++++++--------------------
 1 file changed, 42 insertions(+), 61 deletions(-)

diff --git a/tests/i915/gem_exec_latency.c b/tests/i915/gem_exec_latency.c
index e56d62780c94..0a95c491eb56 100644
--- a/tests/i915/gem_exec_latency.c
+++ b/tests/i915/gem_exec_latency.c
@@ -63,10 +63,10 @@ static unsigned int ring_size;
 static double rcs_clock;
 
 static void
-poll_ring(int fd, unsigned ring, const char *name)
+poll_ring(int fd, const struct intel_execution_engine2 *e, const char *name)
 {
 	const struct igt_spin_factory opts = {
-		.engine = ring,
+		.engine = e->flags,
 		.flags = IGT_SPIN_POLL_RUN | IGT_SPIN_FAST,
 	};
 	struct timespec tv = {};
@@ -74,8 +74,8 @@ poll_ring(int fd, unsigned ring, const char *name)
 	igt_spin_t *spin[2];
 	uint64_t elapsed;
 
-	gem_require_ring(fd, ring);
-	igt_require(gem_can_store_dword(fd, ring));
+	gem_require_ring(fd, e->flags);
+	igt_require(gem_class_can_store_dword(fd, e->class));
 
 	spin[0] = __igt_spin_factory(fd, &opts);
 	igt_assert(igt_spin_has_poll(spin[0]));
@@ -109,8 +109,8 @@ poll_ring(int fd, unsigned ring, const char *name)
 
 #define RCS_TIMESTAMP (0x2000 + 0x358)
 static void latency_on_ring(int fd,
-			    unsigned ring, const char *name,
-			    unsigned flags)
+			    const struct intel_execution_engine2 *e,
+			    const char *name, unsigned flags)
 {
 	const int gen = intel_gen(intel_get_drm_devid(fd));
 	const int has_64bit_reloc = gen >= 8;
@@ -131,7 +131,7 @@ static void latency_on_ring(int fd,
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(&obj[1]);
 	execbuf.buffer_count = 2;
-	execbuf.flags = ring;
+	execbuf.flags = e->flags;
 	execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC | LOCAL_I915_EXEC_HANDLE_LUT;
 
 	memset(obj, 0, sizeof(obj));
@@ -188,7 +188,7 @@ static void latency_on_ring(int fd,
 	}
 
 	if (flags & LIVE)
-		spin = igt_spin_new(fd, .engine = ring);
+		spin = igt_spin_new(fd, .engine = e->flags);
 
 	start = *reg;
 	for (j = 0; j < repeats; j++) {
@@ -256,8 +256,8 @@ static void latency_on_ring(int fd,
 }
 
 static void latency_from_ring(int fd,
-			      unsigned ring, const char *name,
-			      unsigned flags)
+			      const struct intel_execution_engine2 *e,
+			      const char *name, unsigned flags)
 {
 	const int gen = intel_gen(intel_get_drm_devid(fd));
 	const int has_64bit_reloc = gen >= 8;
@@ -265,7 +265,7 @@ static void latency_from_ring(int fd,
 	struct drm_i915_gem_relocation_entry reloc;
 	struct drm_i915_gem_execbuffer2 execbuf;
 	const unsigned int repeats = ring_size / 2;
-	unsigned int other;
+	const struct intel_execution_engine2 *other;
 	uint32_t *map, *results;
 	uint32_t ctx[2] = {};
 	int i, j;
@@ -281,7 +281,7 @@ static void latency_from_ring(int fd,
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(&obj[1]);
 	execbuf.buffer_count = 2;
-	execbuf.flags = ring;
+	execbuf.flags = e->flags;
 	execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC | LOCAL_I915_EXEC_HANDLE_LUT;
 	execbuf.rsvd1 = ctx[1];
 
@@ -311,7 +311,7 @@ static void latency_from_ring(int fd,
 	reloc.presumed_offset = obj[1].offset;
 	reloc.target_handle = flags & CORK ? 1 : 0;
 
-	for_each_physical_engine(fd, other) {
+	__for_each_physical_engine(fd, other) {
 		igt_spin_t *spin = NULL;
 		IGT_CORK_HANDLE(c);
 
@@ -322,7 +322,7 @@ static void latency_from_ring(int fd,
 		if (flags & PREEMPT)
 			spin = __igt_spin_new(fd,
 					      .ctx = ctx[0],
-					      .engine = ring);
+					      .engine = e->flags);
 
 		if (flags & CORK) {
 			obj[0].handle = igt_cork_plug(&c, fd);
@@ -334,7 +334,7 @@ static void latency_from_ring(int fd,
 			uint64_t offset;
 
 			execbuf.flags &= ~ENGINE_FLAGS;
-			execbuf.flags |= ring;
+			execbuf.flags |= e->flags;
 
 			execbuf.batch_start_offset = 64 * j;
 			reloc.offset =
@@ -359,7 +359,7 @@ static void latency_from_ring(int fd,
 			gem_execbuf(fd, &execbuf);
 
 			execbuf.flags &= ~ENGINE_FLAGS;
-			execbuf.flags |= other;
+			execbuf.flags |= other->flags;
 
 			execbuf.batch_start_offset = 64 * (j + repeats);
 			reloc.offset =
@@ -392,7 +392,7 @@ static void latency_from_ring(int fd,
 		igt_spin_free(fd, spin);
 
 		igt_info("%s-%s delay: %.2fns\n",
-			 name, e__->name,
+			 name, e->name,
 			 (results[2*repeats-1] - results[0]) / (double)repeats * rcs_clock);
 	}
 
@@ -441,7 +441,8 @@ static bool __spin_wait(int fd, igt_spin_t *spin)
  * reasonable latency.
  */
 static void
-rthog_latency_on_ring(int fd, unsigned int engine, const char *name, unsigned int flags)
+rthog_latency_on_ring(int fd, const struct intel_execution_engine2 *e,
+		      const char *name, unsigned int flags)
 #define RTIDLE 0x1
 {
 	const char *passname[] = {
@@ -458,7 +459,7 @@ rthog_latency_on_ring(int fd, unsigned int engine, const char *name, unsigned in
 #define NPASS ARRAY_SIZE(passname)
 #define MMAP_SZ (64 << 10)
 	const struct igt_spin_factory opts = {
-		.engine = engine,
+		.engine = e->flags,
 		.flags = IGT_SPIN_POLL_RUN | IGT_SPIN_FAST,
 	};
 	struct rt_pkt *results;
@@ -472,19 +473,19 @@ rthog_latency_on_ring(int fd, unsigned int engine, const char *name, unsigned in
 	igt_assert(results != MAP_FAILED);
 
 	nengine = 0;
-	if (engine == ALL_ENGINES) {
-		for_each_physical_engine(fd, engine) {
-			if (!gem_can_store_dword(fd, engine))
+	if (!e) {
+		__for_each_physical_engine(fd, e) {
+			if (!gem_class_can_store_dword(fd, e->class))
 				continue;
 
-			engines[nengine] = engine;
-			names[nengine] = e__->name;
+			engines[nengine] = e->flags;
+			names[nengine] = e->name;
 			nengine++;
 		}
 		igt_require(nengine > 1);
 	} else {
-		igt_require(gem_can_store_dword(fd, engine));
-		engines[nengine] = engine;
+		igt_require(gem_class_can_store_dword(fd, e->class));
+		engines[nengine] = e->flags;
 		names[nengine] = name;
 		nengine++;
 	}
@@ -494,7 +495,6 @@ rthog_latency_on_ring(int fd, unsigned int engine, const char *name, unsigned in
 	igt_fork(child, nengine) {
 		unsigned int pass = 0; /* Three phases: warmup, normal, rt. */
 
-		engine = engines[child];
 		do {
 			struct igt_mean mean;
 			double min = HUGE_VAL;
@@ -547,7 +547,7 @@ rthog_latency_on_ring(int fd, unsigned int engine, const char *name, unsigned in
 				igt_spin_reset(spin);
 
 				igt_nsec_elapsed(&ts);
-				__submit_spin(fd, spin, engine);
+				__submit_spin(fd, spin, engines[child]);
 				if (!__spin_wait(fd, spin)) {
 					igt_warn("Wait timeout! (%s)\n",
 						 passname[pass]);
@@ -650,7 +650,7 @@ static double clockrate(int i915, int reg)
 
 igt_main
 {
-	const struct intel_execution_engine *e;
+	const struct intel_execution_engine2 *e;
 	int device = -1;
 
 	igt_fixture {
@@ -675,71 +675,53 @@ igt_main
 	}
 
 	igt_subtest("all-rtidle-submit")
-		rthog_latency_on_ring(device, ALL_ENGINES, "all", RTIDLE);
+		rthog_latency_on_ring(device, NULL, "all", RTIDLE);
 
 	igt_subtest("all-rthog-submit")
-		rthog_latency_on_ring(device, ALL_ENGINES, "all", 0);
+		rthog_latency_on_ring(device, NULL, "all", 0);
 
 	igt_subtest_group {
 		igt_fixture
 			igt_require(intel_gen(intel_get_drm_devid(device)) >= 7);
 
-		for (e = intel_execution_engines; e->name; e++) {
-			if (e->exec_id == 0)
-				continue;
-
+		__for_each_physical_engine(device, e) {
 			igt_subtest_group {
-				igt_fixture {
-					igt_require(gem_ring_has_physical_engine(device, e->exec_id | e->flags));
-				}
-
 				igt_subtest_f("%s-dispatch", e->name)
 					latency_on_ring(device,
-							e->exec_id | e->flags,
-							e->name, 0);
+							e, e->name, 0);
 
 				igt_subtest_f("%s-live-dispatch", e->name)
 					latency_on_ring(device,
-							e->exec_id | e->flags,
-							e->name, LIVE);
+							e, e->name, LIVE);
 
 				igt_subtest_f("%s-poll", e->name)
 					poll_ring(device,
-						  e->exec_id | e->flags,
-						  e->name);
+						  e, e->name);
 
 				igt_subtest_f("%s-rtidle-submit", e->name)
 					rthog_latency_on_ring(device,
-							      e->exec_id |
-							      e->flags,
-							      e->name,
+							      e, e->name,
 							      RTIDLE);
 
 				igt_subtest_f("%s-rthog-submit", e->name)
 					rthog_latency_on_ring(device,
-							      e->exec_id |
-							      e->flags,
-							      e->name,
+							      e, e->name,
 							      0);
 
 				igt_subtest_f("%s-live-dispatch-queued", e->name)
 					latency_on_ring(device,
-							e->exec_id | e->flags,
-							e->name, LIVE | CORK);
+							e, e->name, LIVE | CORK);
 				igt_subtest_f("%s-dispatch-queued", e->name)
 					latency_on_ring(device,
-							e->exec_id | e->flags,
-							e->name, CORK);
+							e, e->name, CORK);
 
 				igt_subtest_f("%s-synchronisation", e->name)
 					latency_from_ring(device,
-							  e->exec_id | e->flags,
-							  e->name, 0);
+							  e, e->name, 0);
 
 				igt_subtest_f("%s-synchronisation-queued", e->name)
 					latency_from_ring(device,
-							  e->exec_id | e->flags,
-							  e->name, CORK);
+							  e, e->name, CORK);
 
 				igt_subtest_group {
 					igt_fixture {
@@ -749,8 +731,7 @@ igt_main
 
 					igt_subtest_f("%s-preemption", e->name)
 						latency_from_ring(device,
-								  e->exec_id | e->flags,
-								  e->name, PREEMPT);
+								  e, e->name, PREEMPT);
 				}
 			}
 		}
-- 
2.19.1



More information about the igt-dev mailing list