Mesa (main): llvmpipe: handle timespec overflow on fence waits.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jun 3 03:53:04 UTC 2022
Module: Mesa
Branch: main
Commit: b62dd20dea64c3ab5a79673fcfd9442e4f80b855
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b62dd20dea64c3ab5a79673fcfd9442e4f80b855
Author: Dave Airlie <airlied at redhat.com>
Date: Fri Jun 3 12:25:32 2022 +1000
llvmpipe: handle timespec overflow on fence waits.
on 32-bit systems VK CTS was failing due to an overflow here,
detect the overflow and just do a normal wait.
Fixes: 5b284fe6bc0a ("llvmpipe: add lp_fence_timedwait() helper")
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16847>
---
src/gallium/drivers/llvmpipe/lp_fence.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/gallium/drivers/llvmpipe/lp_fence.c b/src/gallium/drivers/llvmpipe/lp_fence.c
index e103cf2a8bd..221003d7872 100644
--- a/src/gallium/drivers/llvmpipe/lp_fence.c
+++ b/src/gallium/drivers/llvmpipe/lp_fence.c
@@ -32,6 +32,8 @@
#include "lp_fence.h"
+#include "util/timespec.h"
+
/**
* Create a new fence object.
*
@@ -128,17 +130,12 @@ lp_fence_wait(struct lp_fence *f)
boolean
lp_fence_timedwait(struct lp_fence *f, uint64_t timeout)
{
- struct timespec ts;
+ struct timespec ts, abs_ts;
int ret;
timespec_get(&ts, TIME_UTC);
- ts.tv_nsec += timeout % 1000000000L;
- ts.tv_sec += timeout / 1000000000L;
- if (ts.tv_nsec >= 1000000000L) {
- ts.tv_sec++;
- ts.tv_nsec -= 1000000000L;
- }
+ bool ts_overflow = timespec_add_nsec(&abs_ts, &ts, timeout);
if (LP_DEBUG & DEBUG_FENCE)
debug_printf("%s %d\n", __FUNCTION__, f->id);
@@ -146,7 +143,10 @@ lp_fence_timedwait(struct lp_fence *f, uint64_t timeout)
mtx_lock(&f->mutex);
assert(f->issued);
while (f->count < f->rank) {
- ret = cnd_timedwait(&f->signalled, &f->mutex, &ts);
+ if (ts_overflow)
+ ret = cnd_wait(&f->signalled, &f->mutex);
+ else
+ ret = cnd_timedwait(&f->signalled, &f->mutex, &abs_ts);
if (ret != thrd_success)
break;
}
More information about the mesa-commit
mailing list