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 <lionel.g.landwerlin@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25512>
This commit is contained in:
Paulo Zanoni 2023-10-24 11:37:53 -07:00 committed by Marge Bot
parent 576275907a
commit f6d28bec6d
5 changed files with 15 additions and 5 deletions

View file

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

View file

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

View file

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

View file

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

View file

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