From 6db24416fdcdf5571125f9005089241cc6ba2652 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 3 Jan 2018 18:09:09 +0000 Subject: lib/gem: Reset the global seqno at the start of each test When we require GEM, reset the global seqno. This gives each test a clean slate to work with, and avoids left-over state from previous tests impacting on the next. In particular, somes tests may be setting up long sequence of stalling batches not expecting to hit a seqno wraparound (leftover from, for example, gem_exec_whisper), causing long GPU hangs and incompletes in CI if they do. Signed-off-by: Chris Wilson Reviewed-by: Arkadiusz Hiler --- lib/ioctl_wrappers.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/ioctl_wrappers.c') diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index 118dcefe..39e8469e 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -52,6 +52,7 @@ #include "intel_chipset.h" #include "intel_io.h" #include "igt_debugfs.h" +#include "igt_sysfs.h" #include "config.h" #ifdef HAVE_VALGRIND @@ -1411,7 +1412,8 @@ void igt_require_gem(int fd) igt_require_intel(fd); - /* We only want to use the throttle-ioctl for its -EIO reporting + /* + * We only want to use the throttle-ioctl for its -EIO reporting * of a wedged device, not for actually waiting on outstanding * requests! So create a new drm_file for the device that is clean. */ @@ -1419,6 +1421,18 @@ void igt_require_gem(int fd) fd = open(path, O_RDWR); igt_assert_lte(0, fd); + /* + * Reset the global seqno at the start of each test. This ensures that + * the test will not wrap unless it explicitly sets up seqno wrapping + * 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); + } + err = 0; if (ioctl(fd, DRM_IOCTL_I915_GEM_THROTTLE)) err = -errno; -- cgit v1.2.3