From 3ab8ff99fa779911e7b9436faba0f64b5e6d3038 Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Wed, 3 Jul 2024 14:28:15 -0700 Subject: [PATCH] anv/trtt: fix the process of picking device->trtt.queue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want to use actual sparse-capable queues as the default trtt->queue, not copy queues that may have a companion_rcs_batch. Before this patch, if we expose more than one queue *and* the application creates a copy queue first, we'll end up setting trtt->queue as the copy queue, which will GPU hang when we submit the TR-TT batches as they don't support the pipe_control commands we issue. The trtt->queue queue is used for binding/unbinding buffers in code paths where there's no specific queue coming from user space, such as when we're creating or destroying a sparse resource. This is not a problem yet on i915.ko since we are exposing only a single queue, and it is not a problem for xe.ko since TR-TT is not the default there. This is also not a problem in applications that create the render or compute queue first. We plan to expose more queues when using TR-TT, so this would become a problem without this patch. None of VK-GL-CTS seems to exercise that, and none of the Steam games I tested exercise that as well. I was able to reproduce this issue using our internal tracing tool. v2: New implementation that doesn't break when we only have a compute queue (Lionel). Fixes: 04bfe828db81 ("anv/sparse: allow sparse resouces to use TR-TT as its backend") Reviewed-by: José Roberto de Souza Signed-off-by: Paulo Zanoni Part-of: --- src/intel/vulkan/anv_sparse.c | 1 + src/intel/vulkan/genX_init_state.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/intel/vulkan/anv_sparse.c b/src/intel/vulkan/anv_sparse.c index b80b681d44d..c899a1f2b16 100644 --- a/src/intel/vulkan/anv_sparse.c +++ b/src/intel/vulkan/anv_sparse.c @@ -625,6 +625,7 @@ anv_sparse_bind_trtt(struct anv_device *device, /* TR-TT submission needs a queue even when the API entry point doesn't * give one, such as resource creation. */ + assert(trtt->queue != NULL); if (!sparse_submit->queue) sparse_submit->queue = trtt->queue; diff --git a/src/intel/vulkan/genX_init_state.c b/src/intel/vulkan/genX_init_state.c index 7f5ff759830..c653a3dfcfd 100644 --- a/src/intel/vulkan/genX_init_state.c +++ b/src/intel/vulkan/genX_init_state.c @@ -667,9 +667,6 @@ init_render_queue_state(struct anv_queue *queue, bool is_companion_rcs_batch) return result; } - if (!device->trtt.queue) - device->trtt.queue = queue; - if (is_companion_rcs_batch) queue->init_companion_submit = submit; else @@ -904,6 +901,10 @@ genX(init_device_state)(struct anv_device *device) } if (res != VK_SUCCESS) return res; + + if (!device->trtt.queue && + queue->family->queueFlags & VK_QUEUE_SPARSE_BINDING_BIT) + device->trtt.queue = queue; } return res;