From 5e39b52e6a42a67bb681ec146af9a8866ea7a3c4 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Wed, 21 Sep 2022 16:42:34 -0700 Subject: [PATCH] turnip: Fix busy-waiting on syncobjs with OS_TIMEOUT_INFINITE. I noticed that glmark2's glFinish()es in its offscreen rendering tests under zink were spinning. When we passed -1 as the timeout for drmSyncobjWait(), the kernel would immediately return ETIME. Fixes: 0a82a26a1854 ("turnip: Porting to common implementation for timeline semaphore") Part-of: --- src/freedreno/vulkan/tu_drm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/freedreno/vulkan/tu_drm.c b/src/freedreno/vulkan/tu_drm.c index 9cb89f86158..ac6b563afc6 100644 --- a/src/freedreno/vulkan/tu_drm.c +++ b/src/freedreno/vulkan/tu_drm.c @@ -647,11 +647,14 @@ tu_timeline_sync_reset(struct vk_device *vk_device, static VkResult drm_syncobj_wait(struct tu_device *device, uint32_t *handles, uint32_t count_handles, - int64_t timeout_nsec, bool wait_all) + uint64_t timeout_nsec, bool wait_all) { uint32_t syncobj_wait_flags = DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT; if (wait_all) syncobj_wait_flags |= DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL; + /* syncobj absolute timeouts are signed. clamp OS_TIMEOUT_INFINITE down. */ + timeout_nsec = MIN2(timeout_nsec, (uint64_t)INT64_MAX); + int err = drmSyncobjWait(device->fd, handles, count_handles, timeout_nsec, syncobj_wait_flags,