anv/xe: make vm_binds async
authorPaulo Zanoni <paulo.r.zanoni@intel.com>
Sat, 5 Aug 2023 00:00:04 +0000 (17:00 -0700)
committerMarge Bot <emma+marge@anholt.net>
Mon, 11 Sep 2023 16:04:01 +0000 (16:04 +0000)
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 <jose.souza@intel.com>
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/24681>

src/intel/vulkan/xe/anv_device.c
src/intel/vulkan/xe/anv_kmd_backend.c

index bdd4202..dbb1e2e 100644 (file)
@@ -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,
index 8551f4d..09a1433 100644 (file)
@@ -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;