summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>2020-08-29 03:25:02 +0200
committerEric Engestrom <eric@engestrom.ch>2020-09-16 19:23:23 +0200
commitc4089181e32bdf095eb704d42af4f8d47258cb43 (patch)
treec85d7c9074e1a8e6209826e13c8038df3d614a1f
parent361de93f4ffc6ece430fcf9e6450bf6af5144f65 (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> (cherry picked from commit 6b75262941b55960e2f73d93f85020fa6c9c2d2f)
-rw-r--r--.pick_status.json2
-rw-r--r--src/amd/vulkan/radv_device.c6
2 files changed, 7 insertions, 1 deletions
diff --git a/.pick_status.json b/.pick_status.json
index 1fbfe420d49..417b165ccb7 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -3559,7 +3559,7 @@
"description": "radv: Fix threading issue with submission refcounts.",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": "4aa75bb3bdd195d4715ee8fae51bfb0c0fcd823b"
},
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 3fd6c86ef19..da41614ba41 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -4636,6 +4636,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;
+
if (__atomic_sub_fetch(&submission->submission_wait_count, decrement, __ATOMIC_ACQ_REL) == 0) {
list_addtail(&submission->processing_list, processing_list);
}