From b73960fc408eb3bcfa28e50eb4891dc8c71fa85c Mon Sep 17 00:00:00 2001 From: Sagar Ghuge Date: Tue, 23 May 2023 13:50:46 -0700 Subject: [PATCH] intel: Add helper to create/destroy i915 VM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sagar Ghuge Reviewed-by: José Roberto de Souza Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/i915/anv_device.c | 22 ++++++++++++++++++++++ src/intel/vulkan/i915/anv_device.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/intel/vulkan/i915/anv_device.c b/src/intel/vulkan/i915/anv_device.c index d666455885c..dd02e46817b 100644 --- a/src/intel/vulkan/i915/anv_device.c +++ b/src/intel/vulkan/i915/anv_device.c @@ -321,3 +321,25 @@ anv_i915_device_check_status(struct vk_device *vk_device) return VK_SUCCESS; } + +bool +anv_i915_device_destroy_vm(struct anv_device *device) +{ + struct drm_i915_gem_vm_control destroy = { + .vm_id = device->vm_id, + }; + + return intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_VM_DESTROY, &destroy) == 0; +} + +VkResult +anv_i915_device_setup_vm(struct anv_device *device) +{ + struct drm_i915_gem_vm_control create = {}; + if (intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_VM_CREATE, &create)) + return vk_errorf(device, VK_ERROR_INITIALIZATION_FAILED, + "vm creation failed"); + + device->vm_id = create.vm_id; + return VK_SUCCESS; +} diff --git a/src/intel/vulkan/i915/anv_device.h b/src/intel/vulkan/i915/anv_device.h index 5eecc0aa2d9..d77349c1cd1 100644 --- a/src/intel/vulkan/i915/anv_device.h +++ b/src/intel/vulkan/i915/anv_device.h @@ -39,3 +39,5 @@ anv_i915_device_setup_context(struct anv_device *device, const uint32_t num_queues); VkResult anv_i915_device_check_status(struct vk_device *vk_device); +bool anv_i915_device_destroy_vm(struct anv_device *device); +VkResult anv_i915_device_setup_vm(struct anv_device *device);