From 7a02d3056fe93fd2ddd2986f7d3db5f384ee22a0 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 9 Feb 2018 10:35:54 +0000 Subject: lib: force a reset on an uncooperative i915 device Try to reset the GPU from within igt_require_gem() if we notice we are starting with a wedged device. If it remains wedged, the test definitely cannot run. We leave a warning in place to highlight the potentially suspect result, which will keep the flip-flops alive in CI! v2: Split out device reset to avoid reusing a local variable Signed-off-by: Chris Wilson Reviewed-by: Antonio Argenziano --- lib/ioctl_wrappers.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'lib/ioctl_wrappers.c') diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index 10d95872..7b656cce 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -1405,6 +1405,22 @@ void gem_require_caching(int fd) errno = 0; } +static void reset_device(int fd) +{ + int dir; + + dir = igt_debugfs_dir(fd); + igt_require(dir >= 0); + + if (ioctl(fd, DRM_IOCTL_I915_GEM_THROTTLE)) { + igt_info("Found wedged device, trying to reset and continue\n"); + igt_sysfs_set(dir, "i915_wedged", "-1"); + } + igt_sysfs_set(dir, "i915_next_seqno", "1"); + + close(dir); +} + void igt_require_gem(int fd) { char path[256]; @@ -1427,15 +1443,12 @@ void igt_require_gem(int fd) * itself, which avoids accidentally hanging when setting up long * sequences of batches. */ - err = igt_debugfs_dir(fd); - if (err != -1) { - igt_sysfs_printf(err, "i915_next_seqno", "1"); - close(err); - } + reset_device(fd); err = 0; if (ioctl(fd, DRM_IOCTL_I915_GEM_THROTTLE)) err = -errno; + close(fd); igt_require_f(err == 0, "Unresponsive i915/GEM device\n"); -- cgit v1.2.3