tu/drm/virtio: Fix tu_wait_fence timeout handling

Fixes two bugs in the WAIT_FENCE polling loop:
1. Break on timeout returned VK_SUCCESS because ret was read too late.
2. UINT64_MAX timeout_ns overflowed end_time, causing immediate exit.

Fix by reading rsp->ret before the timeout check and using
OS_TIMEOUT_INFINITE (like virtio_pipe_wait in freedreno) to avoid
overflow.

This prevents premature BO teardown during host-side fault recovery.

Fixes: f17c5297d7 ("tu: Add virtgpu support")
Signed-off-by: Valentine Burley <valentine.burley@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41108>
This commit is contained in:
Valentine Burley 2026-04-22 13:31:41 +02:00 committed by Marge Bot
parent 809bf45c12
commit dad72b414b

View file

@ -430,10 +430,11 @@ tu_wait_fence(struct tu_device *dev,
if (ret)
goto out;
if (os_time_get_nano() >= end_time)
break;
ret = rsp->ret;
if (timeout_ns != OS_TIMEOUT_INFINITE &&
os_time_get_nano() >= end_time)
break;
} while (ret == -ETIMEDOUT);
out: