anv/trtt: fix the process of picking device->trtt.queue

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: 04bfe828db ("anv/sparse: allow sparse resouces to use TR-TT as its backend")
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30252>
This commit is contained in:
Paulo Zanoni
2024-07-03 14:28:15 -07:00
parent 5ca224aa0c
commit 3ab8ff99fa
2 changed files with 5 additions and 3 deletions

View File

@@ -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;

View File

@@ -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;