summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>2018-02-21 15:19:42 -0800
committerChris Wilson <chris@chris-wilson.co.uk>2018-02-23 08:57:14 +0000
commitcc1f2ed53ea2b106101b6b5c2179471b6c96e048 (patch)
tree0557b94f02c7aab3892fb73f70526ed54d250272
parentca4369b31b92a4cce61897a60788ef84cfe7e9a9 (diff)
tests/gem_wait: use igt_cork
With igt_cork added as common utility we can use it instead of the local copy Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--tests/gem_wait.c58
1 files changed, 14 insertions, 44 deletions
diff --git a/tests/gem_wait.c b/tests/gem_wait.c
index cf8c8154..34388d26 100644
--- a/tests/gem_wait.c
+++ b/tests/gem_wait.c
@@ -69,51 +69,15 @@ static void invalid_buf(int fd)
#define AWAIT 4
#define WRITE 8
-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 & (WRITE | 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)
{
- struct cork cork = plug(fd, flags);
- igt_spin_t *spin = igt_spin_batch_new(fd, 0, engine, cork.handle);
+ IGT_CORK_HANDLE(cork);
+ uint32_t plug =
+ flags & (WRITE | AWAIT) ? igt_cork_plug(&cork, fd) : 0;
+ igt_spin_t *spin = igt_spin_batch_new(fd, 0, engine, plug);
struct drm_i915_gem_wait wait = {
- flags & WRITE ? cork.handle : spin->handle
- };
+ flags & WRITE ? plug : spin->handle
+ };
igt_assert_eq(__gem_wait(fd, &wait), -ETIME);
@@ -127,7 +91,9 @@ static void basic(int fd, unsigned engine, unsigned flags)
timeout = 1;
}
- unplug(&cork);
+ if (flags & (WRITE | AWAIT))
+ igt_cork_unplug(&cork);
+
igt_assert_eq(__gem_wait(fd, &wait), -ETIME);
while (__gem_wait(fd, &wait) == -ETIME)
@@ -137,7 +103,9 @@ 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 & (WRITE | AWAIT))
+ igt_cork_unplug(&cork);
+
wait.timeout_ns = 0;
igt_assert_eq(__gem_wait(fd, &wait), -ETIME);
@@ -157,6 +125,8 @@ static void basic(int fd, unsigned engine, unsigned flags)
igt_assert(wait.timeout_ns == 0);
}
+ if (plug)
+ gem_close(fd, plug);
igt_spin_batch_free(fd, spin);
}