Module: Mesa
Branch: main
Commit: f6d28bec6d168e46becf2c0eca9e362112ed59b8
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f6d28bec6d168e46becf2c0eca9e362112ed59b8

Author: Paulo Zanoni <[email protected]>
Date:   Tue Oct 24 11:37:53 2023 -0700

anv/sparse: add 'queue' to anv_sparse_submission

If we're going to move syncobj waiting/signaling down to the backend
we're going to need a queue to signal as lost in case those operations
fail.

In some places of the stack we don't have a queue available, such as
when we're creating or destroying resources. For those, for vm_bind
cases we don't use the queue for anything so passing it as NULL is
fine. For TR-TT we are already using device->trtt.queue.

For TR-TT specifically this also means we're going to start using the
actual queues from the call stack instead of trtt->queue, but that
shouldn't make any difference since we only ever have one queue.
Still, this is more technigally correct.

Reviewed-by: Lionel Landwerlin <[email protected]>
Signed-off-by: Paulo Zanoni <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25512>

---

 src/intel/vulkan/anv_batch_chain.c    |  1 +
 src/intel/vulkan/anv_private.h        |  4 ++--
 src/intel/vulkan/anv_sparse.c         | 11 +++++++++--
 src/intel/vulkan/genX_cmd_buffer.c    |  2 +-
 src/intel/vulkan/xe/anv_kmd_backend.c |  2 ++
 5 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/intel/vulkan/anv_batch_chain.c 
b/src/intel/vulkan/anv_batch_chain.c
index 2fbd1cd0e3b..ba3d22702f4 100644
--- a/src/intel/vulkan/anv_batch_chain.c
+++ b/src/intel/vulkan/anv_batch_chain.c
@@ -1434,6 +1434,7 @@ anv_queue_submit_sparse_bind_locked(struct anv_queue 
*queue,
    }
 
    struct anv_sparse_submission sparse_submit = {
+      .queue = queue,
       .binds = NULL,
       .binds_len = 0,
       .binds_capacity = 0,
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 36c6fc686a2..ecc63100334 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -712,6 +712,8 @@ struct anv_state_stream {
 };
 
 struct anv_sparse_submission {
+   struct anv_queue *queue;
+
    struct anv_vm_bind *binds;
    int binds_len;
    int binds_capacity;
@@ -731,8 +733,6 @@ struct anv_trtt_bind {
 struct anv_trtt_submission {
    struct anv_sparse_submission *sparse;
 
-   struct anv_queue *queue;
-
    struct anv_trtt_bind *l3l2_binds;
    struct anv_trtt_bind *l1_binds;
 
diff --git a/src/intel/vulkan/anv_sparse.c b/src/intel/vulkan/anv_sparse.c
index 7bd5f9bffbe..5e20cabc625 100644
--- a/src/intel/vulkan/anv_sparse.c
+++ b/src/intel/vulkan/anv_sparse.c
@@ -521,6 +521,11 @@ anv_sparse_bind_trtt(struct anv_device *device,
    struct anv_trtt *trtt = &device->trtt;
    VkResult result;
 
+   /* TR-TT submission needs a queue even when the API entry point doesn't
+    * give one, such as resource creation. */
+   if (!sparse_submit->queue)
+      sparse_submit->queue = trtt->queue;
+
    /* These capacities are conservative estimations. For L1 binds the
     * number will match exactly unless we skip NULL binds due to L2 already
     * being NULL. For L3/L2 things are harder to estimate, but the resulting
@@ -540,7 +545,6 @@ anv_sparse_bind_trtt(struct anv_device *device,
    STACK_ARRAY(struct anv_trtt_bind, l1_binds, l1_binds_capacity);
    struct anv_trtt_submission trtt_submit = {
       .sparse = sparse_submit,
-      .queue = trtt->queue,
       .l3l2_binds = l3l2_binds,
       .l1_binds = l1_binds,
       .l3l2_binds_len = 0,
@@ -550,7 +554,7 @@ anv_sparse_bind_trtt(struct anv_device *device,
    pthread_mutex_lock(&trtt->mutex);
 
    if (!trtt->l3_addr)
-      anv_trtt_init_context_state(trtt_submit.queue);
+      anv_trtt_init_context_state(sparse_submit->queue);
 
    assert(trtt->l3_addr);
 
@@ -598,6 +602,7 @@ anv_sparse_bind_vm_bind(struct anv_device *device,
     */
    for (int b = 0; b < submit->binds_len; b++) {
       struct anv_sparse_submission s = {
+         .queue = submit->queue,
          .binds = &submit->binds[b],
          .binds_len = 1,
          .binds_capacity = 1,
@@ -655,6 +660,7 @@ anv_init_sparse_bindings(struct anv_device *device,
       .op = ANV_VM_BIND,
    };
    struct anv_sparse_submission submit = {
+      .queue = NULL,
       .binds = &bind,
       .binds_len = 1,
       .binds_capacity = 1,
@@ -688,6 +694,7 @@ anv_free_sparse_bindings(struct anv_device *device,
       .op = ANV_VM_UNBIND,
    };
    struct anv_sparse_submission submit = {
+      .queue = NULL,
       .binds = &unbind,
       .binds_len = 1,
       .binds_capacity = 1,
diff --git a/src/intel/vulkan/genX_cmd_buffer.c 
b/src/intel/vulkan/genX_cmd_buffer.c
index aa4f6f3e776..5e7d0ff2844 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -8431,7 +8431,7 @@ VkResult
 genX(write_trtt_entries)(struct anv_trtt_submission *submit)
 {
 #if GFX_VER >= 12
-   struct anv_queue *queue = submit->queue;
+   struct anv_queue *queue = submit->sparse->queue;
    size_t batch_size = submit->l3l2_binds_len * 20 +
                        submit->l1_binds_len * 16 + 8;
    STACK_ARRAY(uint32_t, cmds, batch_size);
diff --git a/src/intel/vulkan/xe/anv_kmd_backend.c 
b/src/intel/vulkan/xe/anv_kmd_backend.c
index 853a4b3118e..434f2a22acd 100644
--- a/src/intel/vulkan/xe/anv_kmd_backend.c
+++ b/src/intel/vulkan/xe/anv_kmd_backend.c
@@ -177,6 +177,7 @@ static int xe_vm_bind_bo(struct anv_device *device, struct 
anv_bo *bo)
       .op = ANV_VM_BIND,
    };
    struct anv_sparse_submission submit = {
+      .queue = NULL,
       .binds = &bind,
       .binds_len = 1,
       .binds_capacity = 1,
@@ -196,6 +197,7 @@ static int xe_vm_unbind_bo(struct anv_device *device, 
struct anv_bo *bo)
       .op = ANV_VM_UNBIND,
    };
    struct anv_sparse_submission submit = {
+      .queue = NULL,
       .binds = &bind,
       .binds_len = 1,
       .binds_capacity = 1,

Reply via email to