radv/amdgpu: Split gang submissions correctly when not chained.
authorTimur Kristóf <timur.kristof@gmail.com>
Fri, 7 Apr 2023 00:57:32 +0000 (02:57 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 11 Apr 2023 17:05:03 +0000 (17:05 +0000)
In a gang submit, the follower (typically ACE) and leader
(typically GFX) can have synchronization between each other.
We must ensure that these end up in the same submission,
otherwise we can deadlock the GPU.

We rely on radv_queue here to order follower before the leader
in the submitted CS array.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22354>

src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c

index 6875bad..3fed599 100644 (file)
@@ -1013,6 +1013,19 @@ radv_amdgpu_winsys_cs_submit_fallback(
             unsigned cs_num_ib = cs->use_ib ? 1 : cs->num_old_ib_buffers;
             if (i + cs_num_ib > ib_per_submit)
                break;
+
+            if (cs->hw_ip != request.ip_type) {
+               /* Found a "follower" CS in a gang submission.
+                * Make sure to submit this together with its "leader", the next CS.
+                * We rely on the caller to order each "follower" before its "leader."
+                */
+               assert(cs_idx != cs_count - 1);
+               struct radv_amdgpu_cs *next_cs = radv_amdgpu_cs(cs_array[cs_idx + 1]);
+               assert(next_cs->hw_ip == request.ip_type);
+               unsigned next_cs_num_ib = next_cs->use_ib ? 1 : next_cs->num_old_ib_buffers;
+               if (i + cs_num_ib + next_cs_num_ib > ib_per_submit)
+                  break;
+            }
          }
 
          /* When can use IBs, we only need to submit the main IB of this CS,