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

Ramalingam C ramalingam.c at intel.com
Fri Jun 21 10:03:31 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_reset_stats.c | 60 +++++++++++++++++-------------------
 1 file changed, 29 insertions(+), 31 deletions(-)

diff --git a/tests/i915/gem_reset_stats.c b/tests/i915/gem_reset_stats.c
index ac9af23f2248..dd0ba821f7d8 100644
--- a/tests/i915/gem_reset_stats.c
+++ b/tests/i915/gem_reset_stats.c
@@ -73,7 +73,7 @@ static void sync_gpu(void)
 	close(fd);
 }
 
-static int noop(int fd, uint32_t ctx, const struct intel_execution_engine *e)
+static int noop(int fd, uint32_t ctx, const struct intel_execution_engine2 *e)
 {
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	struct drm_i915_gem_execbuffer2 eb;
@@ -88,7 +88,7 @@ static int noop(int fd, uint32_t ctx, const struct intel_execution_engine *e)
 	memset(&eb, 0, sizeof(eb));
 	eb.buffers_ptr = to_user_pointer(&exec);
 	eb.buffer_count = 1;
-	eb.flags = e->exec_id | e->flags;
+	eb.flags = e->flags;
 	i915_execbuffer2_set_context_id(eb, ctx);
 
 	ret = __gem_execbuf(fd, &eb);
@@ -102,7 +102,7 @@ static int noop(int fd, uint32_t ctx, const struct intel_execution_engine *e)
 
 static int has_engine(int fd,
 		      uint32_t ctx,
-		      const struct intel_execution_engine *e)
+		      const struct intel_execution_engine2 *e)
 {
 	int handle = noop(fd, ctx, e);
 	if (handle < 0)
@@ -111,7 +111,7 @@ static int has_engine(int fd,
 	return 1;
 }
 
-static void check_context(const struct intel_execution_engine *e)
+static void check_context(const struct intel_execution_engine2 *e)
 {
 	int fd = drm_open_driver(DRIVER_INTEL);
 
@@ -157,14 +157,14 @@ static struct timespec ts_injected;
 #define BAN HANG_ALLOW_BAN
 #define ASYNC 2
 static void inject_hang(int fd, uint32_t ctx,
-			const struct intel_execution_engine *e,
+			const struct intel_execution_engine2 *e,
 			unsigned flags)
 {
 	igt_hang_t hang;
 
 	clock_gettime(CLOCK_MONOTONIC, &ts_injected);
 
-	hang = igt_hang_ctx(fd, ctx, e->exec_id | e->flags, flags & BAN);
+	hang = igt_hang_ctx(fd, ctx, e->flags, flags & BAN);
 	if ((flags & ASYNC) == 0)
 		igt_post_hang_ring(fd, hang);
 }
@@ -207,7 +207,7 @@ static int _assert_reset_status(int idx, int fd, int ctx, int status)
 #define assert_reset_status(idx, fd, ctx, status) \
 	igt_assert(_assert_reset_status(idx, fd, ctx, status) == 0)
 
-static void test_rs(const struct intel_execution_engine *e,
+static void test_rs(const struct intel_execution_engine2 *e,
 		    int num_fds, int hang_index, int rs_assumed_no_hang)
 {
 	int fd[MAX_FD];
@@ -253,7 +253,7 @@ static void test_rs(const struct intel_execution_engine *e,
 }
 
 #define MAX_CTX 100
-static void test_rs_ctx(const struct intel_execution_engine *e,
+static void test_rs_ctx(const struct intel_execution_engine2 *e,
 			int num_fds, int num_ctx, int hang_index,
 			int hang_context)
 {
@@ -329,7 +329,7 @@ static void test_rs_ctx(const struct intel_execution_engine *e,
 	}
 }
 
-static void test_ban(const struct intel_execution_engine *e)
+static void test_ban(const struct intel_execution_engine2 *e)
 {
 	struct local_drm_i915_reset_stats rs_bad, rs_good;
 	int fd_bad, fd_good;
@@ -383,7 +383,7 @@ static void test_ban(const struct intel_execution_engine *e)
 	close(fd_good);
 }
 
-static void test_ban_ctx(const struct intel_execution_engine *e)
+static void test_ban_ctx(const struct intel_execution_engine2 *e)
 {
 	struct local_drm_i915_reset_stats rs_bad, rs_good;
 	int fd, ban, retry = 10;
@@ -441,7 +441,7 @@ static void test_ban_ctx(const struct intel_execution_engine *e)
 	close(fd);
 }
 
-static void test_unrelated_ctx(const struct intel_execution_engine *e)
+static void test_unrelated_ctx(const struct intel_execution_engine2 *e)
 {
 	int fd1,fd2;
 	int ctx_guilty, ctx_unrelated;
@@ -480,7 +480,7 @@ static int get_reset_count(int fd, int ctx)
 	return rs.reset_count;
 }
 
-static void test_close_pending_ctx(const struct intel_execution_engine *e)
+static void test_close_pending_ctx(const struct intel_execution_engine2 *e)
 {
 	int fd = drm_open_driver(DRIVER_INTEL);
 	uint32_t ctx = gem_context_create(fd);
@@ -494,7 +494,7 @@ static void test_close_pending_ctx(const struct intel_execution_engine *e)
 	close(fd);
 }
 
-static void test_close_pending(const struct intel_execution_engine *e)
+static void test_close_pending(const struct intel_execution_engine2 *e)
 {
 	int fd = drm_open_driver(DRIVER_INTEL);
 
@@ -509,7 +509,7 @@ static void noop_on_each_ring(int fd, const bool reverse)
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	struct drm_i915_gem_execbuffer2 eb;
 	struct drm_i915_gem_exec_object2 obj;
-	const struct intel_execution_engine *e;
+	const struct intel_execution_engine2 *e;
 
 	memset(&obj, 0, sizeof(obj));
 	obj.handle = gem_create(fd, 4096);
@@ -520,15 +520,15 @@ static void noop_on_each_ring(int fd, const bool reverse)
 	eb.buffer_count = 1;
 
 	if (reverse) {
-		for (e = intel_execution_engines; e->name; e++)
+		__for_each_static_engine(e)
 			;
-		while (--e >= intel_execution_engines) {
-			eb.flags = e->exec_id | e->flags;
+		while (--e >= intel_execution_engines2) {
+			eb.flags = e->flags;
 			__gem_execbuf(fd, &eb);
 		}
 	} else {
-		for (e = intel_execution_engines; e->name; e++) {
-			eb.flags = e->exec_id | e->flags;
+		__for_each_static_engine(e) {
+			eb.flags = e->flags;
 			__gem_execbuf(fd, &eb);
 		}
 	}
@@ -537,7 +537,7 @@ static void noop_on_each_ring(int fd, const bool reverse)
 	gem_close(fd, obj.handle);
 }
 
-static void test_close_pending_fork(const struct intel_execution_engine *e,
+static void test_close_pending_fork(const struct intel_execution_engine2 *e,
 				    const bool reverse)
 {
 	int fd = drm_open_driver(DRIVER_INTEL);
@@ -546,7 +546,7 @@ static void test_close_pending_fork(const struct intel_execution_engine *e,
 
 	assert_reset_status(fd, fd, 0, RS_NO_ERROR);
 
-	hang = igt_hang_ctx(fd, 0, e->exec_id | e->flags, 0);
+	hang = igt_hang_ctx(fd, 0, e->flags, 0);
 	sleep(1);
 
 	/* Avoid helpers as we need to kill the child
@@ -579,7 +579,7 @@ static void test_close_pending_fork(const struct intel_execution_engine *e,
 	close(fd);
 }
 
-static void test_reset_count(const struct intel_execution_engine *e,
+static void test_reset_count(const struct intel_execution_engine2 *e,
 			     const bool create_ctx)
 {
 	int fd = drm_open_driver(DRIVER_INTEL);
@@ -699,23 +699,21 @@ static void test_params(void)
 	close(fd);
 }
 
-static const struct intel_execution_engine *
-next_engine(int fd, const struct intel_execution_engine *e)
+static const struct intel_execution_engine2 *
+next_engine(int fd, const struct intel_execution_engine2 *e)
 {
 	do {
 		e++;
 		if (e->name == NULL)
-			e = intel_execution_engines;
-		if (e->exec_id == 0)
-			e++;
+			e = intel_execution_engines2;
 	} while (!has_engine(fd, 0, e));
 
 	return e;
 }
 
-static void defer_hangcheck(const struct intel_execution_engine *engine)
+static void defer_hangcheck(const struct intel_execution_engine2 *engine)
 {
-	const struct intel_execution_engine *next;
+	const struct intel_execution_engine2 *next;
 	int fd, count_start, count_end;
 	int seconds = 30;
 
@@ -772,7 +770,7 @@ static bool gem_has_reset_stats(int fd)
 
 igt_main
 {
-	const struct intel_execution_engine *e;
+	const struct intel_execution_engine2 *e;
 	igt_skip_on_simulation();
 
 	igt_fixture {
@@ -805,7 +803,7 @@ igt_main
 	igt_subtest_f("params-ctx")
 		RUN_TEST(test_params_ctx());
 
-	for (e = intel_execution_engines; e->name; e++) {
+	__for_each_static_engine(e) {
 		igt_subtest_f("reset-stats-%s", e->name)
 			RUN_TEST(test_rs(e, 4, 1, 0));
 
-- 
2.19.1



More information about the igt-dev mailing list