diff --git a/src/virtio/vulkan/vn_common.c b/src/virtio/vulkan/vn_common.c index 809a8fd82ae..5e7e8335c84 100644 --- a/src/virtio/vulkan/vn_common.c +++ b/src/virtio/vulkan/vn_common.c @@ -22,6 +22,7 @@ static const struct debug_control vn_debug_options[] = { { "result", VN_DEBUG_RESULT }, { "vtest", VN_DEBUG_VTEST }, { "wsi", VN_DEBUG_WSI }, + { "no_abort", VN_DEBUG_NO_ABORT }, { NULL, 0 }, }; @@ -79,6 +80,7 @@ vn_relax(uint32_t *iter, const char *reason) const uint32_t busy_wait_order = 4; const uint32_t base_sleep_us = 10; const uint32_t warn_order = 12; + const uint32_t abort_order = 14; (*iter)++; if (*iter < (1 << busy_wait_order)) { @@ -89,9 +91,15 @@ vn_relax(uint32_t *iter, const char *reason) /* warn occasionally if we have slept at least 1.28ms for 2048 times (plus * another 2047 shorter sleeps) */ - if (unlikely(*iter % (1 << warn_order) == 0)) + if (unlikely(*iter % (1 << warn_order) == 0)) { vn_log(NULL, "stuck in %s wait with iter at %d", reason, *iter); + if (*iter >= (1 << abort_order) && !VN_DEBUG(NO_ABORT)) { + vn_log(NULL, "aborting"); + abort(); + } + } + const uint32_t shift = util_last_bit(*iter) - busy_wait_order - 1; os_time_sleep(base_sleep_us << shift); } diff --git a/src/virtio/vulkan/vn_common.h b/src/virtio/vulkan/vn_common.h index 35b80789c80..43da00cb168 100644 --- a/src/virtio/vulkan/vn_common.h +++ b/src/virtio/vulkan/vn_common.h @@ -137,6 +137,7 @@ enum vn_debug { VN_DEBUG_RESULT = 1ull << 1, VN_DEBUG_VTEST = 1ull << 2, VN_DEBUG_WSI = 1ull << 3, + VN_DEBUG_NO_ABORT = 1ull << 4, }; typedef uint64_t vn_object_id;