venus: properly initialize ring monitor initial alive status

This avoids a potential race condition if two threads are competing for
the monitor with the initial states, and the losing one may run into
alive status being false and abort.

Fixes: 4a4b05869a ("venus: check and configure new ringMonitoring feature")
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reported-by: Lina Versace <lina@kiwitree.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26179>
This commit is contained in:
Yiwei Zhang
2023-11-28 12:17:29 -08:00
committed by Marge Bot
parent aed4c4d04e
commit 8ac7d78bf3
2 changed files with 4 additions and 3 deletions
+1 -3
View File
@@ -169,10 +169,8 @@ vn_relax_init(struct vn_ring *ring, const char *reason)
ring->monitor.report_period_us);
#endif
if (vn_ring_monitor_acquire(ring)) {
ring->monitor.alive = true;
if (vn_ring_monitor_acquire(ring))
vn_ring_unset_status_bits(ring, VK_RING_STATUS_ALIVE_BIT_MESA);
}
}
return (struct vn_relax_state){
+3
View File
@@ -138,6 +138,9 @@ vn_instance_init_ring(struct vn_instance *instance)
ring->monitor.report_period_us = 3000000;
mtx_init(&ring->monitor.mutex, mtx_plain);
/* ring monitor should be alive at all time */
ring->monitor.alive = true;
const struct VkRingMonitorInfoMESA monitor_info = {
.sType = VK_STRUCTURE_TYPE_RING_MONITOR_INFO_MESA,
.maxReportingPeriodMicroseconds = ring->monitor.report_period_us,