anv/sparse: pass anv_sparse_submission to the backend functions

Our ultimate goal is to have the backend functions deal with the wait
and signal syncobjs instead of waiting for them on the CPU inside
anv_queue_submit_sparse_bind_locked(). For that, we'll need waits and
signals parameters to be passed all the way to the backend functions
that actually make the submission, and this is what this patch does,
through struct anv_sparse_submission.

This patch just deals with passing the parameters to the functions,
nothing is using the new variables yet. There should be no functional
changes here. The goal here is to make code review easier.

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-23 17:35:31 -07:00 committed by Marge Bot
parent 6c7753ee0b
commit 576275907a
12 changed files with 79 additions and 31 deletions

View file

@ -1437,6 +1437,10 @@ anv_queue_submit_sparse_bind_locked(struct anv_queue *queue,
.binds = NULL,
.binds_len = 0,
.binds_capacity = 0,
.wait_count = submit->wait_count,
.signal_count = submit->signal_count,
.waits = submit->waits,
.signals = submit->signals,
};
/* TODO: make both the syncs and signals be passed as part of the vm_bind
@ -1715,6 +1719,7 @@ anv_queue_submit_simple_batch(struct anv_queue *queue,
VkResult
anv_queue_submit_trtt_batch(struct anv_queue *queue,
struct anv_sparse_submission *submit,
struct anv_batch *batch)
{
struct anv_device *device = queue->device;
@ -1738,7 +1743,7 @@ anv_queue_submit_trtt_batch(struct anv_queue *queue,
batch_bo->offset, false);
}
result = device->kmd_backend->execute_trtt_batch(queue, batch_bo,
result = device->kmd_backend->execute_trtt_batch(queue, submit, batch_bo,
batch_size);
anv_bo_pool_free(&device->batch_bo_pool, batch_bo);

View file

@ -66,8 +66,9 @@ stub_execute_simple_batch(struct anv_queue *queue, struct anv_bo *batch_bo,
}
static VkResult
stub_execute_trtt_batch(struct anv_queue *queue, struct anv_bo *batch_bo,
uint32_t batch_size)
stub_execute_trtt_batch(struct anv_queue *queue,
struct anv_sparse_submission *submit,
struct anv_bo *batch_bo, uint32_t batch_size)
{
return VK_ERROR_UNKNOWN;
}
@ -174,8 +175,7 @@ anv_gem_import_bo_alloc_flags_to_bo_flags(struct anv_device *device,
}
static int
stub_vm_bind(struct anv_device *device, int num_binds,
struct anv_vm_bind *binds)
stub_vm_bind(struct anv_device *device, struct anv_sparse_submission *submit)
{
return 0;
}

View file

@ -38,6 +38,7 @@ struct anv_device;
struct anv_queue;
struct anv_query_pool;
struct anv_utrace_submit;
struct anv_sparse_submission;
enum anv_vm_bind_op {
ANV_VM_BIND,
@ -68,8 +69,8 @@ struct anv_kmd_backend {
void *(*gem_mmap)(struct anv_device *device, struct anv_bo *bo,
uint64_t offset, uint64_t size);
/* Bind things however you want. */
int (*vm_bind)(struct anv_device *device, int num_binds,
struct anv_vm_bind *binds);
int (*vm_bind)(struct anv_device *device,
struct anv_sparse_submission *submit);
/* Fully bind or unbind a BO. */
int (*vm_bind_bo)(struct anv_device *device, struct anv_bo *bo);
int (*vm_unbind_bo)(struct anv_device *device, struct anv_bo *bo);
@ -78,6 +79,7 @@ struct anv_kmd_backend {
uint32_t batch_bo_size,
bool is_companion_rcs_batch);
VkResult (*execute_trtt_batch)(struct anv_queue *queue,
struct anv_sparse_submission *submit,
struct anv_bo *batch_bo,
uint32_t batch_size);
VkResult (*queue_exec_locked)(struct anv_queue *queue,

View file

@ -715,6 +715,12 @@ struct anv_sparse_submission {
struct anv_vm_bind *binds;
int binds_len;
int binds_capacity;
uint32_t wait_count;
uint32_t signal_count;
struct vk_sync_wait *waits;
struct vk_sync_signal *signals;
};
struct anv_trtt_bind {
@ -723,6 +729,8 @@ struct anv_trtt_bind {
};
struct anv_trtt_submission {
struct anv_sparse_submission *sparse;
struct anv_queue *queue;
struct anv_trtt_bind *l3l2_binds;
@ -1934,6 +1942,7 @@ VkResult anv_queue_submit_simple_batch(struct anv_queue *queue,
struct anv_batch *batch,
bool is_companion_rcs_batch);
VkResult anv_queue_submit_trtt_batch(struct anv_queue *queue,
struct anv_sparse_submission *submit,
struct anv_batch *batch);
void anv_queue_trace(struct anv_queue *queue, const char *label,

View file

@ -539,6 +539,7 @@ anv_sparse_bind_trtt(struct anv_device *device,
STACK_ARRAY(struct anv_trtt_bind, l3l2_binds, l3l2_binds_capacity);
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,
@ -596,7 +597,14 @@ anv_sparse_bind_vm_bind(struct anv_device *device,
* See: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/746
*/
for (int b = 0; b < submit->binds_len; b++) {
int rc = device->kmd_backend->vm_bind(device, 1, &submit->binds[b]);
struct anv_sparse_submission s = {
.binds = &submit->binds[b],
.binds_len = 1,
.binds_capacity = 1,
.wait_count = 0,
.signal_count = 0,
};
int rc = device->kmd_backend->vm_bind(device, &s);
if (rc)
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
}
@ -650,6 +658,8 @@ anv_init_sparse_bindings(struct anv_device *device,
.binds = &bind,
.binds_len = 1,
.binds_capacity = 1,
.wait_count = 0,
.signal_count = 0,
};
VkResult res = anv_sparse_bind(device, &submit);
if (res != VK_SUCCESS) {
@ -681,6 +691,8 @@ anv_free_sparse_bindings(struct anv_device *device,
.binds = &unbind,
.binds_len = 1,
.binds_capacity = 1,
.wait_count = 0,
.signal_count = 0,
};
VkResult res = anv_sparse_bind(device, &submit);
if (res != VK_SUCCESS)

View file

@ -8530,7 +8530,8 @@ genX(write_trtt_entries)(struct anv_trtt_submission *submit)
assert(batch.next <= batch.end);
VkResult result = anv_queue_submit_trtt_batch(queue, &batch);
VkResult result = anv_queue_submit_trtt_batch(queue, submit->sparse,
&batch);
STACK_ARRAY_FINISH(cmds);
return result;

View file

@ -985,8 +985,9 @@ fail:
}
VkResult
i915_execute_trtt_batch(struct anv_queue *queue, struct anv_bo *batch_bo,
uint32_t batch_size)
i915_execute_trtt_batch(struct anv_queue *queue,
struct anv_sparse_submission *submit,
struct anv_bo *batch_bo, uint32_t batch_size)
{
struct anv_device *device = queue->device;
struct anv_trtt *trtt = &device->trtt;

View file

@ -35,6 +35,7 @@ struct anv_bo;
struct anv_cmd_buffer;
struct anv_query_pool;
struct anv_utrace_submit;
struct anv_sparse_submission;
VkResult
i915_queue_exec_trace(struct anv_queue *queue,
@ -44,8 +45,9 @@ i915_execute_simple_batch(struct anv_queue *queue, struct anv_bo *batch_bo,
uint32_t batch_bo_size, bool is_companion_rcs_batch);
VkResult
i915_execute_trtt_batch(struct anv_queue *queue, struct anv_bo *batch_bo,
uint32_t batch_size);
i915_execute_trtt_batch(struct anv_queue *queue,
struct anv_sparse_submission *submit,
struct anv_bo *batch_bo, uint32_t batch_size);
VkResult
i915_queue_exec_locked(struct anv_queue *queue,

View file

@ -207,8 +207,7 @@ i915_gem_mmap(struct anv_device *device, struct anv_bo *bo, uint64_t offset,
}
static int
i915_vm_bind(struct anv_device *device, int num_binds,
struct anv_vm_bind *binds)
i915_vm_bind(struct anv_device *device, struct anv_sparse_submission *submit)
{
return 0;
}

View file

@ -179,8 +179,9 @@ xe_exec_print_debug(struct anv_queue *queue, uint32_t cmd_buffer_count,
}
VkResult
xe_execute_trtt_batch(struct anv_queue *queue, struct anv_bo *batch_bo,
uint32_t batch_size)
xe_execute_trtt_batch(struct anv_queue *queue,
struct anv_sparse_submission *submit,
struct anv_bo *batch_bo, uint32_t batch_size)
{
struct anv_device *device = queue->device;
VkResult result = VK_SUCCESS;

View file

@ -34,13 +34,15 @@ struct anv_bo;
struct anv_cmd_buffer;
struct anv_query_pool;
struct anv_utrace_submit;
struct anv_sparse_submission;
VkResult
xe_execute_simple_batch(struct anv_queue *queue, struct anv_bo *batch_bo,
uint32_t batch_bo_size, bool is_companion_rcs_batch);
VkResult
xe_execute_trtt_batch(struct anv_queue *queue, struct anv_bo *batch_bo,
uint32_t batch_size);
xe_execute_trtt_batch(struct anv_queue *queue,
struct anv_sparse_submission *submit,
struct anv_bo *batch_bo, uint32_t batch_size);
VkResult
xe_queue_exec_locked(struct anv_queue *queue,

View file

@ -97,20 +97,21 @@ xe_gem_mmap(struct anv_device *device, struct anv_bo *bo, uint64_t offset,
}
static inline int
xe_vm_bind_op(struct anv_device *device, int num_binds,
struct anv_vm_bind *binds)
xe_vm_bind_op(struct anv_device *device,
struct anv_sparse_submission *submit)
{
int ret;
struct drm_xe_vm_bind args = {
.vm_id = device->vm_id,
.num_binds = num_binds,
.num_binds = submit->binds_len,
.bind = {},
};
STACK_ARRAY(struct drm_xe_vm_bind_op, xe_binds_stackarray, num_binds);
STACK_ARRAY(struct drm_xe_vm_bind_op, xe_binds_stackarray,
submit->binds_len);
struct drm_xe_vm_bind_op *xe_binds;
if (num_binds > 1) {
if (submit->binds_len > 1) {
if (!xe_binds_stackarray)
return -ENOMEM;
@ -120,8 +121,8 @@ xe_vm_bind_op(struct anv_device *device, int num_binds,
xe_binds = &args.bind;
}
for (int i = 0; i < num_binds; i++) {
struct anv_vm_bind *bind = &binds[i];
for (int i = 0; i < submit->binds_len; i++) {
struct anv_vm_bind *bind = &submit->binds[i];
struct anv_bo *bo = bind->bo;
struct drm_xe_vm_bind_op *xe_bind = &xe_binds[i];
@ -161,10 +162,9 @@ xe_vm_bind_op(struct anv_device *device, int num_binds,
}
static int
xe_vm_bind(struct anv_device *device, int num_binds,
struct anv_vm_bind *binds)
xe_vm_bind(struct anv_device *device, struct anv_sparse_submission *submit)
{
return xe_vm_bind_op(device, num_binds, binds);
return xe_vm_bind_op(device, submit);
}
static int xe_vm_bind_bo(struct anv_device *device, struct anv_bo *bo)
@ -176,7 +176,14 @@ static int xe_vm_bind_bo(struct anv_device *device, struct anv_bo *bo)
.size = bo->actual_size,
.op = ANV_VM_BIND,
};
return xe_vm_bind_op(device, 1, &bind);
struct anv_sparse_submission submit = {
.binds = &bind,
.binds_len = 1,
.binds_capacity = 1,
.wait_count = 0,
.signal_count = 0,
};
return xe_vm_bind_op(device, &submit);
}
static int xe_vm_unbind_bo(struct anv_device *device, struct anv_bo *bo)
@ -188,7 +195,14 @@ static int xe_vm_unbind_bo(struct anv_device *device, struct anv_bo *bo)
.size = bo->actual_size,
.op = ANV_VM_UNBIND,
};
return xe_vm_bind_op(device, 1, &bind);
struct anv_sparse_submission submit = {
.binds = &bind,
.binds_len = 1,
.binds_capacity = 1,
.wait_count = 0,
.signal_count = 0,
};
return xe_vm_bind_op(device, &submit);
}
static uint32_t