From a54451075d4c8bb5ce6ade53b95c4c29812125cf Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Fri, 4 Aug 2023 16:35:11 -0700 Subject: [PATCH] anv: rename the vm_bind vfuncs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: José Roberto de Souza Signed-off-by: Paulo Zanoni Part-of: --- src/intel/vulkan/anv_allocator.c | 8 ++++---- src/intel/vulkan/anv_gem_stubs.c | 12 +++--------- src/intel/vulkan/anv_kmd_backend.h | 5 +++-- src/intel/vulkan/i915/anv_kmd_backend.c | 12 +++--------- src/intel/vulkan/xe/anv_kmd_backend.c | 14 +++++++------- 5 files changed, 20 insertions(+), 31 deletions(-) diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c index 34ffe05..2108f9c 100644 --- a/src/intel/vulkan/anv_allocator.c +++ b/src/intel/vulkan/anv_allocator.c @@ -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"); diff --git a/src/intel/vulkan/anv_gem_stubs.c b/src/intel/vulkan/anv_gem_stubs.c index 80c0e76..7cede99 100644 --- a/src/intel/vulkan/anv_gem_stubs.c +++ b/src/intel/vulkan/anv_gem_stubs.c @@ -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, }; diff --git a/src/intel/vulkan/anv_kmd_backend.h b/src/intel/vulkan/anv_kmd_backend.h index 2dd53ea..c1e8243 100644 --- a/src/intel/vulkan/anv_kmd_backend.h +++ b/src/intel/vulkan/anv_kmd_backend.h @@ -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, diff --git a/src/intel/vulkan/i915/anv_kmd_backend.c b/src/intel/vulkan/i915/anv_kmd_backend.c index bcae3c8..b4828f1 100644 --- a/src/intel/vulkan/i915/anv_kmd_backend.c +++ b/src/intel/vulkan/i915/anv_kmd_backend.c @@ -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, diff --git a/src/intel/vulkan/xe/anv_kmd_backend.c b/src/intel/vulkan/xe/anv_kmd_backend.c index 727faf9..8a7ecb3 100644 --- a/src/intel/vulkan/xe/anv_kmd_backend.c +++ b/src/intel/vulkan/xe/anv_kmd_backend.c @@ -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, -- 2.7.4