From 32c898849bd4f087e5b816b6e9e842edd5ce81d6 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 15 Jul 2015 16:18:10 +0100 Subject: [PATCH] igt/gem_eio: Waiting on a hung batch should report -EIO If we are waiting on a handle, and its request is cancelled due to a hang, we should report that explicitly through the ABI. Signed-off-by: Chris Wilson --- tests/gem_eio.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/gem_eio.c b/tests/gem_eio.c index 6d60d465..998766c1 100644 --- a/tests/gem_eio.c +++ b/tests/gem_eio.c @@ -147,9 +147,34 @@ static void test_execbuf(int fd) trigger_reset(fd); } +static int __gem_wait(int fd, uint32_t handle, int64_t timeout) +{ + struct drm_i915_gem_wait wait; + int err = 0; + + memset(&wait, 0, sizeof(wait)); + wait.bo_handle = handle; + wait.timeout_ns = timeout; + if (drmIoctl(fd, DRM_IOCTL_I915_GEM_WAIT, &wait)) + err = -errno; + + return err; +} + +static void test_wait(int fd) +{ + igt_hang_ring_t hang; + + hang = igt_hang_ring(fd, I915_EXEC_DEFAULT); + igt_assert_eq(__gem_wait(fd, hang.handle, -1), -EIO); + igt_post_hang_ring(fd, hang); + + trigger_reset(fd); +} + igt_main { - int fd; + int fd = -1; igt_skip_on_simulation(); @@ -164,6 +189,9 @@ igt_main igt_subtest("execbuf") test_execbuf(fd); + igt_subtest("wait") + test_wait(fd); + igt_fixture close(fd); }