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:
@@ -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){
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user