[PATCH 3/9] drm/syncobj: Use dma_fence_wait for the simple wait case

Chris Wilson chris at chris-wilson.co.uk
Sun May 6 22:09:21 UTC 2018


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 at chris-wilson.co.uk>
---
 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



More information about the Intel-gfx-trybot mailing list