[Intel-gfx] [PATCH igt v2] lib: Avoid actually throttling from igt_require_gem()

Chris Wilson chris at chris-wilson.co.uk
Thu Aug 24 12:42:37 UTC 2017


igt_require_gem() checks whether we can use the i915 fd for submitting
requests by detecting a wedged driver. It was intended to be used just
after opening DRIVER_INTEL for a gem test to provide an early skip if
the device was unusable. However, it is also used at the start of
library functions like igt_spin_batch_new() which may be called after
the test has setup some state, and importantly submitted some batches.
igt_require_gem() has the risk of then waiting on those batches, unless
we tell it to use a clean fd.

v2: Chase the /proc/self/fd/$fd link

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Michał Winiarski <michal.winiarski at intel.com>
---
 lib/ioctl_wrappers.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 51000bac..d91f29c8 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1598,13 +1598,23 @@ void gem_require_caching(int fd)
 
 void igt_require_gem(int fd)
 {
+	char path[256];
 	int err;
 
 	igt_require_intel(fd);
 
+	/* 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.
+	 */
+	snprintf(path, sizeof(path), "/proc/self/fd/%d", fd);
+	fd = open(path, O_RDWR);
+	igt_assert_lte(0, 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");
 }
-- 
2.14.1



More information about the Intel-gfx mailing list