summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-02-08 18:10:29 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2017-02-08 18:11:41 +0000
commit0aed4dffb517536cff575633fa1f049bd6393184 (patch)
tree2d37e57f636950d8f30ca92df1444b3e86296109 /tests
parent3d7a27e47689a1045d760fb8ab6976a60e0f3d8f (diff)
igt/gem_wait: Exercise BUG_ON if wait_for_execute times out
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests')
-rw-r--r--tests/gem_wait.c54
1 files changed, 53 insertions, 1 deletions
diff --git a/tests/gem_wait.c b/tests/gem_wait.c
index 223e25b8..e67e4d1d 100644
--- a/tests/gem_wait.c
+++ b/tests/gem_wait.c
@@ -26,6 +26,7 @@
*/
#include "igt.h"
+#include "igt_vgem.h"
static int __gem_wait(int fd, struct drm_i915_gem_wait *w)
{
@@ -65,9 +66,50 @@ static void invalid_buf(int fd)
#define BUSY 1
#define HANG 2
+#define AWAIT 4
+
+struct cork {
+ int device;
+ uint32_t handle;
+ uint32_t fence;
+};
+
+static struct cork plug(int fd, unsigned flags)
+{
+ struct cork c;
+ struct vgem_bo bo;
+ int dmabuf;
+
+ if ((flags & AWAIT) == 0)
+ return (struct cork){0};
+
+ c.device = drm_open_driver(DRIVER_VGEM);
+
+ 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);
+
+ return c;
+}
+
+static void unplug(struct cork *c)
+{
+ if (!c->device)
+ return;
+
+ vgem_fence_signal(c->device, c->fence);
+ close(c->device);
+}
+
static void basic(int fd, unsigned engine, unsigned flags)
{
- igt_spin_t *spin = igt_spin_batch_new(fd, engine, 0);
+ struct cork cork = plug(fd, flags);
+ igt_spin_t *spin = igt_spin_batch_new(fd, engine, cork.handle);
struct drm_i915_gem_wait wait = { spin->handle };
igt_assert_eq(__gem_wait(fd, &wait), -ETIME);
@@ -91,6 +133,8 @@ static void basic(int fd, unsigned engine, unsigned flags)
igt_assert_eq(__gem_wait(fd, &wait), -ETIME);
igt_assert_eq_s64(wait.timeout_ns, 0);
+ unplug(&cork);
+
if ((flags & HANG) == 0) {
wait.timeout_ns = NSEC_PER_SEC; /* 1.0s */
igt_assert_eq(__gem_wait(fd, &wait), 0);
@@ -140,6 +184,10 @@ igt_main
gem_quiescent_gpu(fd);
basic(fd, -1, 0);
}
+ igt_subtest("basic-await-all") {
+ gem_quiescent_gpu(fd);
+ basic(fd, -1, AWAIT);
+ }
for (e = intel_execution_engines; e->name; e++) {
igt_subtest_group {
@@ -151,6 +199,10 @@ igt_main
gem_quiescent_gpu(fd);
basic(fd, e->exec_id | e->flags, 0);
}
+ igt_subtest_f("await-%s", e->name) {
+ gem_quiescent_gpu(fd);
+ basic(fd, e->exec_id | e->flags, AWAIT);
+ }
}
}