venus: propagate vn_ring to vn_relax

This is to prepare for vn_relax to check ring status as well as pinging
renderer.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21542>
This commit is contained in:
Yiwei Zhang 2023-02-26 17:29:09 -08:00 committed by Marge Bot
parent 15a55198ec
commit adb51eeba5
5 changed files with 17 additions and 11 deletions

View file

@ -18,6 +18,8 @@
#include "venus-protocol/vn_protocol_driver_info.h"
#include "vk_enum_to_str.h"
#include "vn_ring.h"
#define VN_RELAX_MIN_BASE_SLEEP_US (160)
static const struct debug_control vn_debug_options[] = {
@ -122,7 +124,7 @@ vn_extension_get_spec_version(const char *name)
}
void
vn_relax(uint32_t *iter, const char *reason)
vn_relax(const struct vn_ring *ring, uint32_t *iter, const char *reason)
{
/* Yield for the first 2^busy_wait_order times and then sleep for
* base_sleep_us microseconds for the same number of times. After that,

View file

@ -89,6 +89,7 @@ struct vn_command_buffer;
struct vn_cs_encoder;
struct vn_cs_decoder;
struct vn_ring;
struct vn_renderer;
struct vn_renderer_shmem;
@ -223,7 +224,7 @@ uint32_t
vn_extension_get_spec_version(const char *name);
void
vn_relax(uint32_t *iter, const char *reason);
vn_relax(const struct vn_ring *ring, uint32_t *iter, const char *reason);
static_assert(sizeof(vn_object_id) >= sizeof(uintptr_t), "");

View file

@ -315,7 +315,7 @@ vn_instance_wait_roundtrip(struct vn_instance *instance,
const uint32_t cur = atomic_load_explicit(ptr, memory_order_acquire);
if (roundtrip_seqno_ge(cur, roundtrip_seqno))
break;
vn_relax(&iter, "roundtrip");
vn_relax(ring, &iter, "roundtrip");
} while (true);
}

View file

@ -1257,7 +1257,10 @@ vn_remove_signaled_fences(VkDevice device, VkFence *fences, uint32_t *count)
}
static VkResult
vn_update_sync_result(VkResult result, int64_t abs_timeout, uint32_t *iter)
vn_update_sync_result(struct vn_device *dev,
VkResult result,
int64_t abs_timeout,
uint32_t *iter)
{
switch (result) {
case VK_NOT_READY:
@ -1265,7 +1268,7 @@ vn_update_sync_result(VkResult result, int64_t abs_timeout, uint32_t *iter)
os_time_get_nano() >= abs_timeout)
result = VK_TIMEOUT;
else
vn_relax(iter, "client");
vn_relax(&dev->instance->ring.ring, iter, "client");
break;
default:
assert(result == VK_SUCCESS || result < 0);
@ -1303,7 +1306,7 @@ vn_WaitForFences(VkDevice device,
while (result == VK_NOT_READY) {
result = vn_remove_signaled_fences(device, fences, &fenceCount);
result = vn_update_sync_result(result, abs_timeout, &iter);
result = vn_update_sync_result(dev, result, abs_timeout, &iter);
}
if (fences != local_fences)
@ -1311,7 +1314,7 @@ vn_WaitForFences(VkDevice device,
} else {
while (result == VK_NOT_READY) {
result = vn_find_first_signaled_fence(device, pFences, fenceCount);
result = vn_update_sync_result(result, abs_timeout, &iter);
result = vn_update_sync_result(dev, result, abs_timeout, &iter);
}
}
@ -1794,7 +1797,7 @@ vn_WaitSemaphores(VkDevice device,
while (result == VK_NOT_READY) {
result = vn_remove_signaled_semaphores(device, semaphores, values,
&semaphore_count);
result = vn_update_sync_result(result, abs_timeout, &iter);
result = vn_update_sync_result(dev, result, abs_timeout, &iter);
}
if (semaphores != local_semaphores)
@ -1804,7 +1807,7 @@ vn_WaitSemaphores(VkDevice device,
result = vn_find_first_signaled_semaphore(
device, pWaitInfo->pSemaphores, pWaitInfo->pValues,
pWaitInfo->semaphoreCount);
result = vn_update_sync_result(result, abs_timeout, &iter);
result = vn_update_sync_result(dev, result, abs_timeout, &iter);
}
}

View file

@ -93,7 +93,7 @@ vn_ring_wait_seqno(const struct vn_ring *ring, uint32_t seqno)
const uint32_t head = vn_ring_load_head(ring);
if (vn_ring_ge_seqno(ring, head, seqno))
return head;
vn_relax(&iter, "ring seqno");
vn_relax(ring, &iter, "ring seqno");
} while (true);
}
@ -126,7 +126,7 @@ vn_ring_wait_space(const struct vn_ring *ring, uint32_t size)
/* see the reasoning in vn_ring_wait_seqno */
uint32_t iter = 0;
do {
vn_relax(&iter, "ring space");
vn_relax(ring, &iter, "ring space");
if (vn_ring_has_space(ring, size, &head))
return head;
} while (true);