Commit 5c136258 authored by Kenneth Graunke's avatar Kenneth Graunke Committed by Dylan Baker

iris: Fix large timeout handling in rel2abs()

...by copying the implementation of anv_get_absolute_timeout().

Appears to fix a CTS test with 32-bit builds:
GTF-GL46.gtf32.GL3Tests.sync.sync_functionality_clientwaitsync_flush

Fixes: f459c56b ("iris: Add fence support using drm_syncobj")
Reviewed-by: Lionel Landwerlin's avatarLionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Eric Engestrom's avatarEric Engestrom <eric@engestrom.ch>
(cherry picked from commit 7ee7b0ec)
parent 649040ed
......@@ -206,24 +206,25 @@ iris_fence_await(struct pipe_context *ctx,
#define MSEC_PER_SEC (1000)
static uint64_t
rel2abs(uint64_t timeout)
gettime_ns(void)
{
struct timespec ts;
uint64_t now;
struct timespec current;
clock_gettime(CLOCK_MONOTONIC, &current);
return (uint64_t)current.tv_sec * NSEC_PER_SEC + current.tv_nsec;
}
if (!timeout)
static uint64_t
rel2abs(uint64_t timeout)
{
if (timeout == 0)
return 0;
if (timeout == PIPE_TIMEOUT_INFINITE)
return INT64_MAX;
clock_gettime(CLOCK_MONOTONIC, &ts);
now = ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec;
uint64_t current_time = gettime_ns();
uint64_t max_timeout = (uint64_t) INT64_MAX - current_time;
if (now > INT64_MAX - timeout)
return INT64_MAX;
timeout = MIN2(max_timeout, timeout);
return now + timeout;
return current_time + timeout;
}
static bool
......@@ -244,7 +245,7 @@ iris_fence_finish(struct pipe_screen *p_screen,
struct drm_syncobj_wait args = {
.handles = (uintptr_t)handles,
.count_handles = fence->count,
.timeout_nsec = rel2abs(timeout), /* XXX */
.timeout_nsec = rel2abs(timeout),
.flags = DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL
};
return gen_ioctl(screen->fd, DRM_IOCTL_SYNCOBJ_WAIT, &args) == 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment