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>
(cherry picked from commit dad72b414b)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41269>
This commit is contained in:
Valentine Burley 2026-04-22 13:31:41 +02:00 committed by Eric Engestrom
parent 286c245e98
commit b7560252e4
2 changed files with 5 additions and 4 deletions

View file

@ -2494,7 +2494,7 @@
"description": "tu/drm/virtio: Fix tu_wait_fence timeout handling",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "f17c5297d7a01eb37815f96bbf3a87667a2f3261",
"notes": null

View file

@ -427,10 +427,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: