[Intel-gfx] [PATCH] tests/gem_reset_stats: add subtest hang_all_rings

Mika Kuoppala mika.kuoppala at linux.intel.com
Tue Jan 7 10:46:37 CET 2014


Check that we can hang each individual engine

Signed-off-by: Mika Kuoppala <mika.kuoppala at intel.com>
---
 tests/gem_reset_stats.c |   54 ++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 49 insertions(+), 5 deletions(-)

diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c
index 0515605..a85f486 100644
--- a/tests/gem_reset_stats.c
+++ b/tests/gem_reset_stats.c
@@ -160,7 +160,7 @@ static int gem_exec(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
 	return 0;
 }
 
-static int exec_valid(int fd, int ctx)
+static int exec_valid_ring(int fd, int ctx, int ring)
 {
 	struct drm_i915_gem_execbuffer2 execbuf;
 	struct drm_i915_gem_exec_object2 exec;
@@ -186,7 +186,7 @@ static int exec_valid(int fd, int ctx)
 	execbuf.num_cliprects = 0;
 	execbuf.DR1 = 0;
 	execbuf.DR4 = 0;
-	execbuf.flags = 0;
+	execbuf.flags = ring;
 	i915_execbuffer2_set_context_id(execbuf, ctx);
 	execbuf.rsvd2 = 0;
 
@@ -197,6 +197,11 @@ static int exec_valid(int fd, int ctx)
 	return exec.handle;
 }
 
+static int exec_valid(int fd, int ctx)
+{
+	return exec_valid_ring(fd, ctx, 0);
+}
+
 static void stop_rings(void)
 {
 	int fd;
@@ -211,7 +216,7 @@ static void stop_rings(void)
 #define BUFSIZE (4 * 1024)
 #define ITEMS   (BUFSIZE >> 2)
 
-static int inject_hang(int fd, int ctx)
+static int inject_hang_ring(int fd, int ctx, int ring)
 {
 	struct drm_i915_gem_execbuffer2 execbuf;
 	struct drm_i915_gem_exec_object2 exec;
@@ -249,7 +254,7 @@ static int inject_hang(int fd, int ctx)
 	execbuf.num_cliprects = 0;
 	execbuf.DR1 = 0;
 	execbuf.DR4 = 0;
-	execbuf.flags = 0;
+	execbuf.flags = ring;
 	i915_execbuffer2_set_context_id(execbuf, ctx);
 	execbuf.rsvd2 = 0;
 
@@ -290,7 +295,7 @@ static int inject_hang(int fd, int ctx)
 	execbuf.num_cliprects = 0;
 	execbuf.DR1 = 0;
 	execbuf.DR4 = 0;
-	execbuf.flags = 0;
+	execbuf.flags = ring;
 	i915_execbuffer2_set_context_id(execbuf, ctx);
 	execbuf.rsvd2 = 0;
 
@@ -305,6 +310,11 @@ static int inject_hang(int fd, int ctx)
 	return exec.handle;
 }
 
+static int inject_hang(int fd, int ctx)
+{
+	return inject_hang_ring(fd, ctx, 0);
+}
+
 static int _assert_reset_status(int fd, int ctx, int status)
 {
 	int rs;
@@ -908,6 +918,37 @@ static void test_params(void)
 	close(fd);
 }
 
+static void test_hang_all_rings(void)
+{
+	for (unsigned i = 0; i < NUM_RINGS; i++) {
+		int fd, count, h1, h2;
+		const struct target_ring *ring = &rings[i];
+
+		fd = drm_open_any();
+		igt_assert(fd >= 0);
+
+		assert_reset_status(fd, 0, RS_NO_ERROR);
+		count = get_reset_count(fd, 0);
+
+		if (!ring->avail || (ring->avail && ring->avail(fd))) {
+			h1 = exec_valid_ring(fd, 0, ring->exec);
+			assert(h1 >= 0);
+
+			h2 = inject_hang_ring(fd, 0, ring->exec);
+			assert(h2 >= 0);
+
+			gem_sync(fd, h2);
+
+			igt_assert(get_reset_count(fd, 0) == count + 1);
+
+			gem_close(fd, h1);
+			gem_close(fd, h2);
+
+			close(fd);
+
+		}
+	}
+}
 
 igt_main
 {
@@ -960,6 +1001,9 @@ igt_main
 		test_close_pending_fork(false);
 	}
 
+	igt_subtest("hang-all-rings")
+		test_hang_all_rings();
+
 	igt_subtest("params")
 		test_params();
 }
-- 
1.7.9.5




More information about the Intel-gfx mailing list