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>
(cherry picked from commit 8ac7d78bf3)
This commit is contained in:
Yiwei Zhang
2023-11-28 12:17:29 -08:00
committed by Eric Engestrom
parent 0f6ee029d8
commit 4d9ec22da3
3 changed files with 5 additions and 4 deletions

View File

@@ -434,7 +434,7 @@
"description": "venus: properly initialize ring monitor initial alive status",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "4a4b05869a6ad909417e30d46706ad6038084901",
"notes": null

View File

@@ -168,10 +168,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){

View File

@@ -137,6 +137,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,