summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2015-04-13 11:54:18 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2015-04-14 15:46:56 +0100
commit41fe1d1a4452891a297cea427a338c8769fc5c26 (patch)
tree72f4424844a8a9573c478912ac209865070177da /lib
parent9fd6e07369837ee268097e7aae4c8dea05431fa1 (diff)
lib: Implement gem_sync() using WAIT
When synchronising to rendering, we only want to wait for it to complete and avoid the cache-domain side-effects of SET_DOMAIN if possible. This has the advantage of speeding up a few tests (and thereby making the actual test more explicit in terms of kernel operations). Of course some tests may be reliant on the side-effects... Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'lib')
-rw-r--r--lib/ioctl_wrappers.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index dec45f11..000d3940 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -371,12 +371,22 @@ void gem_set_domain(int fd, uint32_t handle,
* @fd: open i915 drm file descriptor
* @handle: gem buffer object handle
*
- * This is a wrapper around gem_set_domain() which simply blocks for any
- * outstanding rendering to complete.
+ * This functions waits for outstanding rendering to complete.
*/
void gem_sync(int fd, uint32_t handle)
{
- gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
+ struct drm_i915_gem_wait wait;
+
+ memset(&wait, 0, sizeof(wait));
+ wait.bo_handle = handle;
+ wait.timeout_ns =-1;
+ if (drmIoctl(fd, DRM_IOCTL_I915_GEM_WAIT, &wait) == 0) {
+ errno = 0;
+ return;
+ }
+
+ gem_set_domain(fd, handle,
+ I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
}
uint32_t __gem_create(int fd, int size)