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

Ramalingam C ramalingam.c at intel.com
Fri Jun 21 10:03:14 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_ctx_create.c | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/tests/i915/gem_ctx_create.c b/tests/i915/gem_ctx_create.c
index 1e2c40c4f47f..0bf5adb336dc 100644
--- a/tests/i915/gem_ctx_create.c
+++ b/tests/i915/gem_ctx_create.c
@@ -124,7 +124,8 @@ static void files(int core, int timeout, const int ncpus)
 	gem_close(core, batch);
 }
 
-static void active(int fd, unsigned engine, int timeout, int ncpus)
+static void active(int fd, const struct intel_execution_engine2 *e,
+		   int timeout, int ncpus)
 {
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	struct drm_i915_gem_execbuffer2 execbuf;
@@ -132,14 +133,13 @@ static void active(int fd, unsigned engine, int timeout, int ncpus)
 	unsigned int nengine, engines[16];
 	unsigned *shared;
 
-	if (engine == ALL_ENGINES) {
+	if (!e) {
 		igt_require(all_nengine);
 		nengine = all_nengine;
 		memcpy(engines, all_engines, sizeof(engines[0])*nengine);
 	} else {
-		gem_require_ring(fd, engine);
 		nengine = 1;
-		engines[0] = engine;
+		engines[0] = e->flags;
 	}
 
 	shared = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
@@ -157,7 +157,7 @@ static void active(int fd, unsigned engine, int timeout, int ncpus)
 		igt_fork(child, ppgtt_nengine) {
 			unsigned long count = 0;
 
-			if (ppgtt_engines[child] == engine)
+			if (ppgtt_engines[child] == e->flags)
 				continue;
 
 			execbuf.flags = ppgtt_engines[child];
@@ -524,17 +524,16 @@ igt_main
 {
 	const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
 	struct drm_i915_gem_context_create create;
+	const struct intel_execution_engine2 *e;
 	int fd = -1;
 
 	igt_fixture {
-		unsigned engine;
-
 		fd = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(fd);
 		gem_require_contexts(fd);
 
-		for_each_physical_engine(fd, engine)
-			all_engines[all_nengine++] = engine;
+		__for_each_physical_engine(fd, e)
+			all_engines[all_nengine++] = e->flags;
 		igt_require(all_nengine);
 
 		if (gem_uses_full_ppgtt(fd)) {
@@ -575,20 +574,17 @@ igt_main
 		files(fd, 150, ncpus);
 
 	igt_subtest("active-all")
-		active(fd, ALL_ENGINES, 120, 1);
+		active(fd, NULL, 120, 1);
 	igt_subtest("forked-active-all")
-		active(fd, ALL_ENGINES, 120, ncpus);
+		active(fd, NULL, 120, ncpus);
 
-	for (const struct intel_execution_engine *e = intel_execution_engines;
-	     e->name; e++) {
+	__for_each_physical_engine(fd, e) {
 		igt_subtest_f("active-%s", e->name)
-			active(fd, e->exec_id | e->flags, 20, 1);
+			active(fd, e, 20, 1);
 		igt_subtest_f("forked-active-%s", e->name)
-			active(fd, e->exec_id | e->flags, 20, ncpus);
-		if (e->exec_id) {
-			igt_subtest_f("hog-%s", e->name)
-				active(fd, e->exec_id | e->flags, 20, -1);
-		}
+			active(fd, e, 20, ncpus);
+		igt_subtest_f("hog-%s", e->name)
+			active(fd, e, 20, -1);
 	}
 
 	igt_fixture {
-- 
2.19.1



More information about the igt-dev mailing list