All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib: Implement gem_sync() using WAIT
@ 2015-04-13 11:01 Chris Wilson
  2015-04-13 12:48 ` Daniel Vetter
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Wilson @ 2015-04-13 11:01 UTC (permalink / raw)
  To: intel-gfx

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>
---
 lib/ioctl_wrappers.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index dec45f1..000d394 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)
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] lib: Implement gem_sync() using WAIT
  2015-04-13 11:01 [PATCH] lib: Implement gem_sync() using WAIT Chris Wilson
@ 2015-04-13 12:48 ` Daniel Vetter
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Vetter @ 2015-04-13 12:48 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

On Mon, Apr 13, 2015 at 12:01:34PM +0100, Chris Wilson wrote:
> 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>

Yeah makes tons of sense. I looked a bit through existing tests and didn't
spot any existing bad usage of gem_sync.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  lib/ioctl_wrappers.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> index dec45f1..000d394 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)
> -- 
> 2.1.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-13 12:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-13 11:01 [PATCH] lib: Implement gem_sync() using WAIT Chris Wilson
2015-04-13 12:48 ` Daniel Vetter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.