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 <[email protected]>
Reviewed-by: Arkadiusz Hiler <[email protected]>
---
 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 15120842..207a9ef9 100644
--- a/tests/gem_eio.c
+++ b/tests/gem_eio.c
@@ -220,14 +220,27 @@ static void test_inflight(int fd)
        trigger_reset(fd);
 }
 
+static int fd = -1;
+
+static void
+exit_handler(int sig)
+{
+       i915_reset_control(true);
+       igt_force_gpu_reset(fd);
+}
+
 igt_main
 {
-       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);
+
                igt_require_gem(fd);
                igt_require_hang_ring(fd, I915_EXEC_DEFAULT);
        }
@@ -243,7 +256,4 @@ igt_main
 
        igt_subtest("in-flight")
                test_inflight(fd);
-
-       igt_fixture
-               close(fd);
 }
-- 
2.14.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to