summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>2020-08-29 03:25:02 +0200
committerMarge Bot <eric+marge@anholt.net>2020-09-02 18:00:40 +0000
commit6b75262941b55960e2f73d93f85020fa6c9c2d2f (patch)
treeeaf631f69c5537f85130f6fba7ae4d764f743f42
parente4dadb545fa6cdf52b5a6a7efb5764495e09158c (diff)
radv: Fix threading issue with submission refcounts.
If decrement == 0 then: - it isn't safe to access the submission - even if it is, checking that the result of the atomic_sub is 0 doesn't given an unique owner anymore. So skip it. The submission always starts out with refcount >= 1, so first one to decrement to 0 still get dibs on executing it. Fixes: 4aa75bb3bdd "radv: Add wait-before-submit support for timelines." Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6478>
-rw-r--r--src/amd/vulkan/radv_device.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index b0eba6abe86..90167a9d603 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -4414,6 +4414,12 @@ radv_queue_enqueue_submission(struct radv_deferred_queue_submission *submission,
* submitted, but if the queue was empty, we decrement ourselves as there is no previous
* submission. */
uint32_t decrement = submission->wait_semaphore_count - wait_cnt + (is_first ? 1 : 0);
+
+ /* if decrement is zero, then we don't have a refcounted reference to the
+ * submission anymore, so it is not safe to access the submission. */
+ if (!decrement)
+ return VK_SUCCESS;
+
return radv_queue_trigger_submission(submission, decrement, processing_list);
}