diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2019-08-22 16:08:16 -0700 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2019-08-23 10:32:01 -0700 |
commit | 7ee7b0ecbc0de098cba631b2ca0b3291c3817665 (patch) | |
tree | 976db2f7cde5e815e45167cc16a118242e0c4347 /src/gallium | |
parent | 9310ae6f689da1d2872accdcbb73498394e38798 (diff) |
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: f459c56be6b ("iris: Add fence support using drm_syncobj")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/iris/iris_fence.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/gallium/drivers/iris/iris_fence.c b/src/gallium/drivers/iris/iris_fence.c index d4ce3c16728..3aaa0af2281 100644 --- a/src/gallium/drivers/iris/iris_fence.c +++ b/src/gallium/drivers/iris/iris_fence.c @@ -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, ¤t); + 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; |