summaryrefslogtreecommitdiff
path: root/tests/gem_eio.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-11-18 08:50:33 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2016-11-18 08:54:45 +0000
commit9bbf642dc1f1b661ea970c8c3f66b1a4f8eaef44 (patch)
treec1877ea32d255280f922cf4b3878cd59259a62ad /tests/gem_eio.c
parente9443b3d2680fd3462bd4229eeeb6dd6975bba1e (diff)
igt/gem_eio: Add inflight test
Since we can submit requests after becoming wedged, we need to test that we do handle that correctly. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/gem_eio.c')
-rw-r--r--tests/gem_eio.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/gem_eio.c b/tests/gem_eio.c
index 9376e79e..f594204b 100644
--- a/tests/gem_eio.c
+++ b/tests/gem_eio.c
@@ -39,6 +39,7 @@
#include <drm.h>
+#include "igt_vgem.h"
IGT_TEST_DESCRIPTION("Test that specific ioctls report a wedged GPU (EIO).");
@@ -157,6 +158,67 @@ static void test_wait(int fd)
trigger_reset(fd);
}
+struct cork {
+ int device;
+ uint32_t handle;
+ uint32_t fence;
+};
+
+static void plug(int fd, struct cork *c)
+{
+ struct vgem_bo bo;
+ int dmabuf;
+
+ c->device = __drm_open_driver(DRIVER_VGEM);
+ igt_require(c->device != -1);
+
+ bo.width = bo.height = 1;
+ bo.bpp = 4;
+ vgem_create(c->device, &bo);
+ c->fence = vgem_fence_attach(c->device, &bo, VGEM_FENCE_WRITE);
+
+ dmabuf = prime_handle_to_fd(c->device, bo.handle);
+ c->handle = prime_fd_to_handle(fd, dmabuf);
+ close(dmabuf);
+}
+
+static void unplug(struct cork *c)
+{
+ vgem_fence_signal(c->device, c->fence);
+ close(c->device);
+}
+
+static void test_inflight(int fd)
+{
+ struct drm_i915_gem_execbuffer2 execbuf;
+ struct drm_i915_gem_exec_object2 obj;
+ uint32_t bbe = MI_BATCH_BUFFER_END;
+ igt_hang_t hang;
+ struct cork cork;
+
+ igt_require(i915_reset_control(false));
+ hang = igt_hang_ring(fd, I915_EXEC_DEFAULT);
+
+ plug(fd, &cork);
+
+ memset(&obj, 0, sizeof(obj));
+ obj.handle = gem_create(fd, 4096);
+ gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
+
+ memset(&execbuf, 0, sizeof(execbuf));
+ execbuf.buffers_ptr = (uintptr_t)&obj;
+ execbuf.buffer_count = 2;
+
+ gem_execbuf(fd, &execbuf);
+
+ igt_post_hang_ring(fd, hang);
+ unplug(&cork); /* only now submit our batches */
+ igt_assert_eq(__gem_wait(fd, obj.handle, -1), 0);
+
+ igt_require(i915_reset_control(true));
+ trigger_reset(fd);
+}
+
igt_main
{
int fd = -1;
@@ -177,6 +239,9 @@ igt_main
igt_subtest("wait")
test_wait(fd);
+ igt_subtest("in-flight")
+ test_inflight(fd);
+
igt_fixture
close(fd);
}