[PATCH 0/1] MR2654: libs/vkd3d: Leave the command queue op mutex locked after a partial flush.
All return paths in d3d12_command_queue_flush_ops_locked() must leave the op mutex locked. (cherry-picked from upstream commit e27ceddfb4a89470d5d35ab4391d0a5cf4453ef1) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2654
From: Conor McCarthy <cmccarthy(a)codeweavers.com> All return paths in d3d12_command_queue_flush_ops_locked() must leave the op mutex locked. (cherry-picked from upstream commit e27ceddfb4a89470d5d35ab4391d0a5cf4453ef1) --- libs/vkd3d/libs/vkd3d/command.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/libs/vkd3d/libs/vkd3d/command.c b/libs/vkd3d/libs/vkd3d/command.c index e5ead7d3e4e..6eddcfa2d14 100644 --- a/libs/vkd3d/libs/vkd3d/command.c +++ b/libs/vkd3d/libs/vkd3d/command.c @@ -6781,16 +6781,16 @@ static bool d3d12_command_queue_op_array_append(struct d3d12_command_queue_op_ar return true; } -static HRESULT d3d12_command_queue_fixup_after_flush(struct d3d12_command_queue *queue, unsigned int done_count) +static void d3d12_command_queue_delete_aux_ops(struct d3d12_command_queue *queue, + unsigned int done_count) { - HRESULT hr; - queue->aux_op_queue.count -= done_count; memmove(queue->aux_op_queue.ops, &queue->aux_op_queue.ops[done_count], queue->aux_op_queue.count * sizeof(*queue->aux_op_queue.ops)); +} - vkd3d_mutex_lock(&queue->op_mutex); - +static HRESULT d3d12_command_queue_fixup_after_flush_locked(struct d3d12_command_queue *queue) +{ d3d12_command_queue_swap_queues(queue); d3d12_command_queue_op_array_append(&queue->op_queue, queue->aux_op_queue.count, queue->aux_op_queue.ops); @@ -6798,11 +6798,7 @@ static HRESULT d3d12_command_queue_fixup_after_flush(struct d3d12_command_queue queue->aux_op_queue.count = 0; queue->is_flushing = false; - hr = d3d12_command_queue_record_as_blocked(queue); - - vkd3d_mutex_unlock(&queue->op_mutex); - - return hr; + return d3d12_command_queue_record_as_blocked(queue); } static HRESULT d3d12_command_queue_flush_ops(struct d3d12_command_queue *queue, bool *flushed_any) @@ -6855,7 +6851,9 @@ static HRESULT d3d12_command_queue_flush_ops_locked(struct d3d12_command_queue * if (op->u.wait.value > fence->max_pending_value) { vkd3d_mutex_unlock(&fence->mutex); - return d3d12_command_queue_fixup_after_flush(queue, i); + d3d12_command_queue_delete_aux_ops(queue, i); + vkd3d_mutex_lock(&queue->op_mutex); + return d3d12_command_queue_fixup_after_flush_locked(queue); } d3d12_command_queue_wait_locked(queue, fence, op->u.wait.value); d3d12_fence_decref(fence); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/2654
This merge request was approved by Giovanni Mascellani. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2654
Could you please explain what bug is fixed by this, and why it's necessary to cherry-pick it outside of the normal upstream merge process? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2654#note_30272
On Mon Apr 24 15:07:05 2023 +0000, Alexandre Julliard wrote:
Could you please explain what bug is fixed by this, and why it's necessary to cherry-pick it outside of the normal upstream merge process? Without this fix the affected code path unlocks an already unlocked mutex every time it runs.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/2654#note_31004
participants (4)
-
Alexandre Julliard (@julliard) -
Conor McCarthy -
Conor McCarthy (@cmccarthy) -
Giovanni Mascellani (@giomasce)