[Mesa-dev] [PATCH 2/2] i965/bufmgr: Skip wait ioctl when busy.

Chris Wilson chris at chris-wilson.co.uk
Fri Jul 21 20:31:59 UTC 2017


Quoting Kenneth Graunke (2017-07-18 06:14:53)
> If the buffer is idle, we I915_GEM_WAIT will return immediately,
> so we may as well skip the ioctl altogether.  We can't trust the
> "idle" flag for external buffers, but for most, it should be fine.
> ---
>  src/mesa/drivers/dri/i965/brw_bufmgr.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> This patch should be legitimate regardless of how bogus the previous
> one ends up being, and could land immediately.
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c
> index e1b98755e39..1669d26e990 100644
> --- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
> +++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
> @@ -911,6 +911,10 @@ brw_bo_wait(struct brw_bo *bo, int64_t timeout_ns)
>     struct drm_i915_gem_wait wait;
>     int ret;
>  
> +   /* If we know it's idle, don't bother with the kernel round trip */
> +   if (bo->idle && !bo->external)
> +      return 0;

The only times I can think of where bo->idle is insufficient are for
dmabuf and scanout, both covered by bo->external.

Although the wait-ioctl is lockless it is optimised for taking the wait,
so skipping the ioctl entirely when we know we are safe is great.

Similarly after a successful wait, we can mark bo->idle = true again.

Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris


More information about the mesa-dev mailing list