From e3afacb7b30cbfa48fc06ebd73412487563dfe9f Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Fri, 3 Apr 2026 20:56:25 -0700 Subject: [PATCH] venus: ensure sfb can catch device lost Similar to qfb except that we skip sfb consistency validation here. Part-of: --- src/virtio/vulkan/vn_queue.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/virtio/vulkan/vn_queue.c b/src/virtio/vulkan/vn_queue.c index 30b49f04b11..880d90a74e2 100644 --- a/src/virtio/vulkan/vn_queue.c +++ b/src/virtio/vulkan/vn_queue.c @@ -2204,6 +2204,7 @@ vn_get_semaphore_counter_value(VkDevice dev_handle, struct vn_device *dev = vn_device_from_handle(dev_handle); struct vn_semaphore *sem = vn_semaphore_from_handle(sem_handle); ASSERTED struct vn_sync_payload *payload = sem->payload; + bool check_device_lost = false; assert(payload->type == VN_SYNC_TYPE_DEVICE_ONLY); @@ -2262,6 +2263,9 @@ vn_get_semaphore_counter_value(VkDevice dev_handle, simple_mtx_unlock(&sem->feedback.cmd_mtx); sem->feedback.signaled_counter = counter; + } else if (relax_state && vn_relax_warn(relax_state)) { + /* upon vn_relax warn order and when sfb doesn't progress */ + check_device_lost = true; } /* vn_SignalSemaphore writes the sfb signaled_counter without updating @@ -2270,6 +2274,21 @@ vn_get_semaphore_counter_value(VkDevice dev_handle, counter = MAX2(counter, sem->feedback.signaled_counter); simple_mtx_unlock(&sem->feedback.counter_mtx); + if (check_device_lost) { + /* Emit a synchronous vkGetSemaphoreCounterValue to catch renderer + * device lost without tangling with sfb internals. + */ + uint64_t tmp; + VkResult result = vn_call_vkGetSemaphoreCounterValue( + dev->primary_ring, dev_handle, sem_handle, &tmp); + if (result == VK_ERROR_DEVICE_LOST) { + vn_log(dev->instance, "aborting on sfb device lost"); + abort(); + } + if (result != VK_SUCCESS) + return result; + } + *out_value = counter; } else { VkResult result = vn_call_vkGetSemaphoreCounterValue(