diff mbox

drm/syncobj: Use dma_fence_wait for the simple wait case

Message ID 20180505105549.14351-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson May 5, 2018, 10:55 a.m. UTC
When waiting for a single fence beneath a syncobj, forgo our open coding
for waiting over multiple fences and call the driver specific
dma_fence_wait_timeout(). This gives the opportunity for the driver to
handle it more efficiently then the lcd of signal callbacks, and avoids
the temporary allocations and array iterations.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/drm_syncobj.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Daniel Vetter May 8, 2018, 5:51 a.m. UTC | #1
On Sat, May 05, 2018 at 11:55:49AM +0100, Chris Wilson wrote:
> When waiting for a single fence beneath a syncobj, forgo our open coding
> for waiting over multiple fences and call the driver specific
> dma_fence_wait_timeout(). This gives the opportunity for the driver to
> handle it more efficiently then the lcd of signal callbacks, and avoids
> the temporary allocations and array iterations.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Aside: Do the igts test both the single and multi-case?
-Daniel
> ---
>  drivers/gpu/drm/drm_syncobj.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
> index d4f4ce484529..c0f787f7a298 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -695,6 +695,14 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
>  	signed long ret;
>  	uint32_t signaled_count, i;
>  
> +	/* KISS for the common case of waiting for a single submitted fence. */
> +	if (count == 1 && (fence = drm_syncobj_fence_get(syncobjs[0]))) {
> +		ret = dma_fence_wait_timeout(fence, true, timeout);
> +		dma_fence_put(fence);
> +		*idx = 0;
> +		return ret;
> +	}
> +
>  	entries = kcalloc(count, sizeof(*entries), GFP_KERNEL);
>  	if (!entries)
>  		return -ENOMEM;
> -- 
> 2.17.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index d4f4ce484529..c0f787f7a298 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -695,6 +695,14 @@  static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
 	signed long ret;
 	uint32_t signaled_count, i;
 
+	/* KISS for the common case of waiting for a single submitted fence. */
+	if (count == 1 && (fence = drm_syncobj_fence_get(syncobjs[0]))) {
+		ret = dma_fence_wait_timeout(fence, true, timeout);
+		dma_fence_put(fence);
+		*idx = 0;
+		return ret;
+	}
+
 	entries = kcalloc(count, sizeof(*entries), GFP_KERNEL);
 	if (!entries)
 		return -ENOMEM;