anv/xe: add a 'flags' parameter to the vm_bind() kmd_backend function

For now there's only one flag, but we're about to add another.

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/28792>
This commit is contained in:
Paulo Zanoni 2024-03-11 14:49:53 -07:00 committed by Marge Bot
parent 15b6f321af
commit f17d7655fe
5 changed files with 34 additions and 11 deletions

View File

@ -153,7 +153,8 @@ anv_gem_import_bo_alloc_flags_to_bo_flags(struct anv_device *device,
}
static VkResult
stub_vm_bind(struct anv_device *device, struct anv_sparse_submission *submit)
stub_vm_bind(struct anv_device *device, struct anv_sparse_submission *submit,
enum anv_vm_bind_flags flags)
{
return VK_SUCCESS;
}

View File

@ -58,6 +58,20 @@ struct anv_vm_bind {
enum anv_vm_bind_op op;
};
/* These flags apply only to the vm_bind() ioctl backend operations, not to
* the higher-level concept of resource address binding. In other words: they
* don't apply to TR-TT, which also uses other structs with "vm_bind" in their
* names.
*/
enum anv_vm_bind_flags {
ANV_VM_BIND_FLAG_NONE = 0,
/* The most recent bind_timeline wait point is waited for during every
* command submission. This flag allows the vm_bind operation to create a
* new timeline point and signal it upon completion.
*/
ANV_VM_BIND_FLAG_SIGNAL_BIND_TIMELINE = 1 << 0,
};
struct anv_kmd_backend {
/*
* Create a gem buffer.
@ -76,11 +90,12 @@ struct anv_kmd_backend {
/*
* Bind things however you want.
* This is intended for sparse resources, so it does not use the
* bind_timeline interface: synchronization is up to the callers.
* This is intended for sparse resources, so it's a little lower level and
* the _bo variants.
*/
VkResult (*vm_bind)(struct anv_device *device,
struct anv_sparse_submission *submit);
struct anv_sparse_submission *submit,
enum anv_vm_bind_flags flags);
/*
* Fully bind or unbind a BO.

View File

@ -594,7 +594,7 @@ anv_sparse_bind_vm_bind(struct anv_device *device,
if (!queue)
assert(submit->wait_count == 0 && submit->signal_count == 0);
return device->kmd_backend->vm_bind(device, submit);
return device->kmd_backend->vm_bind(device, submit, ANV_VM_BIND_FLAG_NONE);
}
VkResult

View File

@ -227,7 +227,8 @@ i915_gem_mmap(struct anv_device *device, struct anv_bo *bo, uint64_t offset,
}
static VkResult
i915_vm_bind(struct anv_device *device, struct anv_sparse_submission *submit)
i915_vm_bind(struct anv_device *device, struct anv_sparse_submission *submit,
enum anv_vm_bind_flags flags)
{
return VK_SUCCESS;
}

View File

@ -171,9 +171,12 @@ anv_vm_bind_to_drm_xe_vm_bind(struct anv_device *device,
static inline VkResult
xe_vm_bind_op(struct anv_device *device,
struct anv_sparse_submission *submit,
bool signal_bind_timeline)
enum anv_vm_bind_flags flags)
{
VkResult result = VK_SUCCESS;
const bool signal_bind_timeline =
flags & ANV_VM_BIND_FLAG_SIGNAL_BIND_TIMELINE;
int num_syncs = submit->wait_count + submit->signal_count +
signal_bind_timeline;
STACK_ARRAY(struct drm_xe_sync, xe_syncs, num_syncs);
@ -269,9 +272,10 @@ out_syncs:
}
static VkResult
xe_vm_bind(struct anv_device *device, struct anv_sparse_submission *submit)
xe_vm_bind(struct anv_device *device, struct anv_sparse_submission *submit,
enum anv_vm_bind_flags flags)
{
return xe_vm_bind_op(device, submit, false);
return xe_vm_bind_op(device, submit, flags);
}
static VkResult
@ -292,7 +296,8 @@ xe_vm_bind_bo(struct anv_device *device, struct anv_bo *bo)
.wait_count = 0,
.signal_count = 0,
};
return xe_vm_bind_op(device, &submit, true);
return xe_vm_bind_op(device, &submit,
ANV_VM_BIND_FLAG_SIGNAL_BIND_TIMELINE);
}
static VkResult
@ -318,7 +323,8 @@ xe_vm_unbind_bo(struct anv_device *device, struct anv_bo *bo)
bind.size = bo->actual_size;
bind.op = ANV_VM_UNBIND;
}
return xe_vm_bind_op(device, &submit, true);
return xe_vm_bind_op(device, &submit,
ANV_VM_BIND_FLAG_SIGNAL_BIND_TIMELINE);
}
static uint32_t