intel: Add helper to create/destroy i915 VM

Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com>
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23661>
This commit is contained in:
Sagar Ghuge 2023-05-23 13:50:46 -07:00 committed by Marge Bot
parent 13b3d7f741
commit b73960fc40
2 changed files with 24 additions and 0 deletions

View file

@ -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;
}

View file

@ -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);