[Intel-gfx] [PATCH igt 3/3] igt/gem_eio: Install an exithandler to unwedge the device after failure

Chris Wilson chris at chris-wilson.co.uk
Fri Sep 8 12:52:07 UTC 2017


Under normal conditions, we try to repair the damage we inflict to the
GPU, but if we fail we don't. Make sure that if the test does die, we do
try to restore normal operation by using an atexit handler.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 tests/gem_eio.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/tests/gem_eio.c b/tests/gem_eio.c
index 4e3b64b3..c441fef0 100644
--- a/tests/gem_eio.c
+++ b/tests/gem_eio.c
@@ -283,15 +283,28 @@ out:
 	return flags;
 }
 
+static int fd = -1;
+
+static void
+exit_handler(int sig)
+{
+	igt_force_gpu_reset(fd);
+	i915_reset_control(true);
+}
+
 igt_main
 {
 	unsigned int caps = 0;
-	int fd = -1;
 
 	igt_skip_on_simulation();
 
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_INTEL);
+
+		igt_require(i915_reset_control(true));
+		igt_force_gpu_reset(fd);
+		igt_install_exit_handler(exit_handler);
+
 		caps = print_welcome(fd);
 		igt_require_gem(fd);
 		igt_require_hang_ring(fd, I915_EXEC_DEFAULT);
@@ -313,7 +326,4 @@ igt_main
 		igt_require(!(caps & HAVE_SEMAPHORES));
 		test_inflight_internal(fd);
 	}
-
-	igt_fixture
-		close(fd);
 }
-- 
2.14.1



More information about the Intel-gfx mailing list