diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-09-03 10:37:14 +0200 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-09-03 10:37:14 +0200 |
commit | 9cc16e8afd0269d6f94107b2044240e45334e64d (patch) | |
tree | 44e13fbb2a1e7d1b601a0c3bfcb8c3ccafeea2fc | |
parent | bd59d60275e8d7cce2ae4370cf8f8304abdc52fc (diff) |
lib/drmtest: extract gem_execbuf helper
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r-- | lib/drmtest.c | 10 | ||||
-rw-r--r-- | lib/drmtest.h | 1 | ||||
-rw-r--r-- | tests/gem_exec_blt.c | 17 | ||||
-rw-r--r-- | tests/gem_exec_faulting_reloc.c | 12 |
4 files changed, 14 insertions, 26 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c index c0fda727..5475a4d3 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -463,6 +463,16 @@ uint32_t gem_create(int fd, int size) return create.handle; } +void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf) +{ + int ret; + + ret = drmIoctl(fd, + DRM_IOCTL_I915_GEM_EXECBUFFER2, + execbuf); + igt_assert(ret == 0); +} + void *gem_mmap__gtt(int fd, uint32_t handle, int size, int prot) { struct drm_i915_gem_mmap_gtt mmap_arg; diff --git a/lib/drmtest.h b/lib/drmtest.h index 27573bfd..bf947dfd 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -71,6 +71,7 @@ void gem_set_domain(int fd, uint32_t handle, uint32_t read_domains, uint32_t write_domain); void gem_sync(int fd, uint32_t handle); uint32_t gem_create(int fd, int size); +void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf); void *gem_mmap__gtt(int fd, uint32_t handle, int size, int prot); void *gem_mmap__cpu(int fd, uint32_t handle, int size, int prot); diff --git a/tests/gem_exec_blt.c b/tests/gem_exec_blt.c index 058d3d0b..cbaa78b0 100644 --- a/tests/gem_exec_blt.c +++ b/tests/gem_exec_blt.c @@ -125,19 +125,6 @@ static int gem_linear_blt(uint32_t *batch, return (b+2 - batch) * sizeof(uint32_t); } -static int gem_exec(int fd, struct drm_i915_gem_execbuffer2 *execbuf, int loops) -{ - int ret = 0; - - while (loops-- && ret == 0) { - ret = drmIoctl(fd, - DRM_IOCTL_I915_GEM_EXECBUFFER2, - execbuf); - } - - return ret; -} - static double elapsed(const struct timeval *start, const struct timeval *end, int loop) @@ -230,8 +217,8 @@ static void run(int object_size) struct timeval start, end; gettimeofday(&start, NULL); - if (gem_exec(fd, &execbuf, count)) - igt_fail(1); + for (int loop = 0; loop < count; loop++) + gem_execbuf(fd, &execbuf); gem_sync(fd, handle); gettimeofday(&end, NULL); printf("Time to blt %d bytes x %6d: %7.3fµs, %s\n", diff --git a/tests/gem_exec_faulting_reloc.c b/tests/gem_exec_faulting_reloc.c index 8287a077..73b8f6d2 100644 --- a/tests/gem_exec_faulting_reloc.c +++ b/tests/gem_exec_faulting_reloc.c @@ -130,16 +130,6 @@ static int gem_linear_blt(uint32_t *batch, return (b+2 - batch) * sizeof(uint32_t); } -static void gem_exec(int fd, struct drm_i915_gem_execbuffer2 *execbuf) -{ - int ret; - - ret = drmIoctl(fd, - DRM_IOCTL_I915_GEM_EXECBUFFER2, - execbuf); - igt_assert(ret == 0); -} - static void run(int object_size) { struct drm_i915_gem_execbuffer2 execbuf; @@ -209,7 +199,7 @@ static void run(int object_size) i915_execbuffer2_set_context_id(execbuf, 0); execbuf.rsvd2 = 0; - gem_exec(fd, &execbuf); + gem_execbuf(fd, &execbuf); gem_sync(fd, handle); gem_close(fd, handle); |