[Intel-gfx] [PATCH igt 07/10] igt/gem_exec_suspend: Try to suspend with a pending GPU hang

Chris Wilson chris at chris-wilson.co.uk
Fri Jul 28 12:08:05 UTC 2017


Ensure that we can suspend the GPU even if it is currently busy in an
indefinite loop, requiring us to declare the task hung.
---
 tests/gem_exec_suspend.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tests/gem_exec_suspend.c b/tests/gem_exec_suspend.c
index 763cb108..bcb0e089 100644
--- a/tests/gem_exec_suspend.c
+++ b/tests/gem_exec_suspend.c
@@ -29,6 +29,7 @@
 
 #include "igt.h"
 #include "igt_gt.h"
+#include "igt_dummyload.h"
 
 #define NOSLEEP 0
 #define SUSPEND_DEVICES 1
@@ -44,6 +45,7 @@
 
 #define UNCACHED (0<<8)
 #define CACHED (1<<8)
+#define HANG (2<<8)
 
 static void run_test(int fd, unsigned ring, unsigned flags);
 
@@ -105,6 +107,7 @@ static void run_test(int fd, unsigned engine, unsigned flags)
 	struct drm_i915_gem_execbuffer2 execbuf;
 	unsigned engines[16];
 	unsigned nengine;
+	igt_spin_t *spin = NULL;
 
 	nengine = 0;
 	if (engine == -1) {
@@ -197,6 +200,9 @@ static void run_test(int fd, unsigned engine, unsigned flags)
 		gem_close(fd, obj[1].handle);
 	}
 
+	if (flags & HANG)
+		spin = igt_spin_batch_new(fd, 0, engine, 0);
+
 	switch (mode(flags)) {
 	case NOSLEEP:
 		break;
@@ -222,6 +228,8 @@ static void run_test(int fd, unsigned engine, unsigned flags)
 		break;
 	}
 
+	igt_spin_batch_free(fd, spin);
+
 	check_bo(fd, obj[0].handle);
 	gem_close(fd, obj[0].handle);
 
@@ -244,6 +252,7 @@ igt_main
 		{ NULL, 0 }
 	}, *m;
 	const struct intel_execution_engine *e;
+	igt_hang_t hang;
 	int fd;
 
 	igt_fixture {
@@ -278,6 +287,16 @@ igt_main
 
 	igt_fixture {
 		igt_stop_hang_detector();
+		hang = igt_allow_hang(fd, 0, 0);
+	}
+
+	igt_subtest("hang-S3")
+		run_test(fd, 0, SUSPEND | HANG);
+	igt_subtest("hang-S4")
+		run_test(fd, 0, HIBERNATE | HANG);
+
+	igt_fixture {
+		igt_disallow_hang(fd, hang);
 		close(fd);
 	}
 }
-- 
2.13.3



More information about the Intel-gfx mailing list