From 935a1d2c8ff6ebe152221c04e699ddecb867e4ff Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Fri, 4 Aug 2023 17:00:04 -0700 Subject: [PATCH] anv/xe: make vm_binds async MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Our sparse implementation will require us to issue partial unbinds, but partial unbinds are not supported in synchronous vm_bind ioctls, requiring us to to have our VM be marked with the ASYNC flag. This is not properly documented and is subject to change in the next iterations of the API. Error handling with async binds is also not documented anywhere and is being actively discussed in the mailing lists, so whatever we decide to implement here is likely to end up changing in a few weeks. Also, I haven't seen these errors happening in the real world, so for now they're a very corner case. So for now just foward errors to user-space and hope things work. Reviewed-by: José Roberto de Souza Reviewed-by: Lionel Landwerlin Signed-off-by: Paulo Zanoni Part-of: --- src/intel/vulkan/xe/anv_device.c | 3 ++- src/intel/vulkan/xe/anv_kmd_backend.c | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/intel/vulkan/xe/anv_device.c b/src/intel/vulkan/xe/anv_device.c index bdd4202..dbb1e2e 100644 --- a/src/intel/vulkan/xe/anv_device.c +++ b/src/intel/vulkan/xe/anv_device.c @@ -37,7 +37,8 @@ bool anv_xe_device_destroy_vm(struct anv_device *device) VkResult anv_xe_device_setup_vm(struct anv_device *device) { struct drm_xe_vm_create create = { - .flags = DRM_XE_VM_CREATE_SCRATCH_PAGE, + .flags = DRM_XE_VM_CREATE_SCRATCH_PAGE | + DRM_XE_VM_CREATE_ASYNC_BIND_OPS, }; if (intel_ioctl(device->fd, DRM_IOCTL_XE_VM_CREATE, &create) != 0) return vk_errorf(device, VK_ERROR_INITIALIZATION_FAILED, diff --git a/src/intel/vulkan/xe/anv_kmd_backend.c b/src/intel/vulkan/xe/anv_kmd_backend.c index 8551f4d..09a1433 100644 --- a/src/intel/vulkan/xe/anv_kmd_backend.c +++ b/src/intel/vulkan/xe/anv_kmd_backend.c @@ -153,6 +153,12 @@ xe_vm_bind_op(struct anv_device *device, int num_binds, } } + /* TODO: do proper error handling here, once the way to do it is + * settled. As of right now the final interface is still under + * discussion. + */ + xe_bind->op |= XE_VM_BIND_FLAG_ASYNC; + /* userptr and bo_offset are an union! */ if (bo && bo->from_host_ptr) xe_bind->userptr = (uintptr_t)bo->map; -- 2.7.4