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: 5b284fe6bc ("llvmpipe: add lp_fence_timedwait() helper")
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16847>
This commit is contained in:
Dave Airlie 2022-06-03 12:25:32 +10:00 committed by Marge Bot
parent 8eb5178a6d
commit b62dd20dea
1 changed files with 8 additions and 8 deletions

View File

@ -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;
}