anv: rename the vm_bind vfuncs
authorPaulo Zanoni <paulo.r.zanoni@intel.com>
Fri, 4 Aug 2023 23:35:11 +0000 (16:35 -0700)
committerMarge Bot <emma+marge@anholt.net>
Mon, 11 Sep 2023 16:04:01 +0000 (16:04 +0000)
The only driver that has a vm_bind ioctl is xe.ko, and its vm_bind
ioctl is not called GEM vm_bind, it's just DRM_IOCTL_XE_VM_BIND
(without GEM anywhere). Back when i915.ko was going to have a vm_bind
ioctl it had GEM on its name, so I guess that's how "gem" appeared in
the naming here, but now nothing does, so let's get rid of it.

Also, these vfuncs we have are specifically made to bind and unbind
whole BOs, so rename them to vm_bind_bo() and vm_unbind_bo() in order
to try to clarify what they mean. The goal is to add a more generic
vm_bind() later that can do anything.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
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/24681>

src/intel/vulkan/anv_allocator.c
src/intel/vulkan/anv_gem_stubs.c
src/intel/vulkan/anv_kmd_backend.h
src/intel/vulkan/i915/anv_kmd_backend.c
src/intel/vulkan/xe/anv_kmd_backend.c

index 34ffe05..2108f9c 100644 (file)
@@ -1388,7 +1388,7 @@ static void
 anv_bo_finish(struct anv_device *device, struct anv_bo *bo)
 {
    /* Not releasing vma in case unbind fails */
-   if (device->kmd_backend->gem_vm_unbind(device, bo) == 0)
+   if (device->kmd_backend->vm_unbind_bo(device, bo) == 0)
       anv_bo_vma_free(device, bo);
 
    anv_bo_unmap_close(device, bo);
@@ -1560,7 +1560,7 @@ anv_device_alloc_bo(struct anv_device *device,
    if (result != VK_SUCCESS)
       return result;
 
-   if (device->kmd_backend->gem_vm_bind(device, &new_bo)) {
+   if (device->kmd_backend->vm_bind_bo(device, &new_bo)) {
       anv_bo_vma_free(device, &new_bo);
       anv_bo_unmap_close(device, &new_bo);
       return vk_errorf(device, VK_ERROR_UNKNOWN, "vm bind failed");
@@ -1708,7 +1708,7 @@ anv_device_import_bo_from_host_ptr(struct anv_device *device,
          return result;
       }
 
-      if (device->kmd_backend->gem_vm_bind(device, &new_bo)) {
+      if (device->kmd_backend->vm_bind_bo(device, &new_bo)) {
          VkResult res = vk_errorf(device, VK_ERROR_UNKNOWN, "vm bind failed: %m");
          anv_bo_vma_free(device, &new_bo);
          pthread_mutex_unlock(&cache->mutex);
@@ -1840,7 +1840,7 @@ anv_device_import_bo(struct anv_device *device,
          return result;
       }
 
-      if (device->kmd_backend->gem_vm_bind(device, &new_bo)) {
+      if (device->kmd_backend->vm_bind_bo(device, &new_bo)) {
          anv_bo_vma_free(device, &new_bo);
          pthread_mutex_unlock(&cache->mutex);
          return vk_errorf(device, VK_ERROR_UNKNOWN, "vm bind failed");
index 80c0e76..7cede99 100644 (file)
@@ -152,13 +152,7 @@ anv_gem_fd_to_handle(struct anv_device *device, int fd)
 }
 
 static int
-stub_gem_vm_bind(struct anv_device *device, struct anv_bo *bo)
-{
-   return 0;
-}
-
-static int
-stub_gem_vm_unbind(struct anv_device *device, struct anv_bo *bo)
+stub_vm_bind_bo(struct anv_device *device, struct anv_bo *bo)
 {
    return 0;
 }
@@ -170,8 +164,8 @@ const struct anv_kmd_backend *anv_stub_kmd_backend_get(void)
       .gem_create_userptr = stub_gem_create_userptr,
       .gem_close = stub_gem_close,
       .gem_mmap = stub_gem_mmap,
-      .gem_vm_bind = stub_gem_vm_bind,
-      .gem_vm_unbind = stub_gem_vm_unbind,
+      .vm_bind_bo = stub_vm_bind_bo,
+      .vm_unbind_bo = stub_vm_bind_bo,
       .execute_simple_batch = stub_execute_simple_batch,
       .queue_exec_locked = stub_queue_exec_locked,
    };
index 2dd53ea..c1e8243 100644 (file)
@@ -55,8 +55,9 @@ struct anv_kmd_backend {
    void *(*gem_mmap)(struct anv_device *device, struct anv_bo *bo,
                      uint64_t offset, uint64_t size,
                      VkMemoryPropertyFlags property_flags);
-   int (*gem_vm_bind)(struct anv_device *device, struct anv_bo *bo);
-   int (*gem_vm_unbind)(struct anv_device *device, struct anv_bo *bo);
+   /* 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);
    VkResult (*execute_simple_batch)(struct anv_queue *queue,
                                     struct anv_bo *batch_bo,
                                     uint32_t batch_bo_size,
index bcae3c8..b4828f1 100644 (file)
@@ -169,13 +169,7 @@ i915_gem_mmap(struct anv_device *device, struct anv_bo *bo, uint64_t offset,
 }
 
 static int
-i915_gem_vm_bind(struct anv_device *device, struct anv_bo *bo)
-{
-   return 0;
-}
-
-static int
-i915_gem_vm_unbind(struct anv_device *device, struct anv_bo *bo)
+i915_vm_bind_bo(struct anv_device *device, struct anv_bo *bo)
 {
    return 0;
 }
@@ -207,8 +201,8 @@ anv_i915_kmd_backend_get(void)
       .gem_create_userptr = i915_gem_create_userptr,
       .gem_close = i915_gem_close,
       .gem_mmap = i915_gem_mmap,
-      .gem_vm_bind = i915_gem_vm_bind,
-      .gem_vm_unbind = i915_gem_vm_unbind,
+      .vm_bind_bo = i915_vm_bind_bo,
+      .vm_unbind_bo = i915_vm_bind_bo,
       .execute_simple_batch = i915_execute_simple_batch,
       .queue_exec_locked = i915_queue_exec_locked,
       .queue_exec_trace = i915_queue_exec_trace,
index 727faf9..8a7ecb3 100644 (file)
@@ -94,7 +94,7 @@ xe_gem_mmap(struct anv_device *device, struct anv_bo *bo, uint64_t offset,
 }
 
 static inline int
-xe_gem_vm_bind_op(struct anv_device *device, struct anv_bo *bo, uint32_t op)
+xe_vm_bind_op(struct anv_device *device, struct anv_bo *bo, uint32_t op)
 {
    uint32_t syncobj_handle;
    int ret = drmSyncobjCreate(device->fd, 0, &syncobj_handle);
@@ -145,14 +145,14 @@ bind_error:
    return ret;
 }
 
-static int xe_gem_vm_bind(struct anv_device *device, struct anv_bo *bo)
+static int xe_vm_bind_bo(struct anv_device *device, struct anv_bo *bo)
 {
-   return xe_gem_vm_bind_op(device, bo, XE_VM_BIND_OP_MAP);
+   return xe_vm_bind_op(device, bo, XE_VM_BIND_OP_MAP);
 }
 
-static int xe_gem_vm_unbind(struct anv_device *device, struct anv_bo *bo)
+static int xe_vm_unbind_bo(struct anv_device *device, struct anv_bo *bo)
 {
-   return xe_gem_vm_bind_op(device, bo, XE_VM_BIND_OP_UNMAP);
+   return xe_vm_bind_op(device, bo, XE_VM_BIND_OP_UNMAP);
 }
 
 static uint32_t
@@ -173,8 +173,8 @@ anv_xe_kmd_backend_get(void)
       .gem_create_userptr = xe_gem_create_userptr,
       .gem_close = xe_gem_close,
       .gem_mmap = xe_gem_mmap,
-      .gem_vm_bind = xe_gem_vm_bind,
-      .gem_vm_unbind = xe_gem_vm_unbind,
+      .vm_bind_bo = xe_vm_bind_bo,
+      .vm_unbind_bo = xe_vm_unbind_bo,
       .execute_simple_batch = xe_execute_simple_batch,
       .queue_exec_locked = xe_queue_exec_locked,
       .queue_exec_trace = xe_queue_exec_utrace_locked,