iris: Implement the function to destroy VM in Xe

Signed-off-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/21937>
This commit is contained in:
José Roberto de Souza 2023-02-14 09:25:28 -08:00 committed by Marge Bot
parent 60f4bd61b6
commit c9fdfae334
4 changed files with 36 additions and 0 deletions

View File

@ -1617,6 +1617,21 @@ iris_bo_wait_rendering(struct iris_bo *bo)
iris_bo_wait(bo, -1);
}
static void
iris_bufmgr_destroy_global_vm(struct iris_bufmgr *bufmgr)
{
switch (bufmgr->devinfo.kmd_type) {
case INTEL_KMD_TYPE_I915:
/* Nothing to do in i915 */
break;
case INTEL_KMD_TYPE_XE:
iris_xe_destroy_global_vm(bufmgr);
break;
default:
unreachable("missing");
}
}
static void
iris_bufmgr_destroy(struct iris_bufmgr *bufmgr)
{
@ -1677,6 +1692,8 @@ iris_bufmgr_destroy(struct iris_bufmgr *bufmgr)
for (int z = 0; z < IRIS_MEMZONE_COUNT; z++)
util_vma_heap_finish(&bufmgr->vma_allocator[z]);
iris_bufmgr_destroy_global_vm(bufmgr);
close(bufmgr->fd);
simple_mtx_unlock(&bufmgr->lock);
@ -2372,6 +2389,7 @@ error_slabs_init:
pb_slabs_deinit(&bufmgr->bo_slabs[i]);
}
iris_bufmgr_destroy_global_vm(bufmgr);
error_init_vm:
error_engine_info:
close(bufmgr->fd);
@ -2497,3 +2515,9 @@ iris_bufmgr_get_kernel_driver_backend(struct iris_bufmgr *bufmgr)
{
return bufmgr->kmd_backend;
}
uint32_t
iris_bufmgr_get_global_vm_id(struct iris_bufmgr *bufmgr)
{
return bufmgr->global_vm_id;
}

View File

@ -584,6 +584,7 @@ uint64_t iris_bufmgr_sram_size(struct iris_bufmgr *bufmgr);
const struct intel_device_info *iris_bufmgr_get_device_info(struct iris_bufmgr *bufmgr);
const struct iris_kmd_backend *
iris_bufmgr_get_kernel_driver_backend(struct iris_bufmgr *bufmgr);
uint32_t iris_bufmgr_get_global_vm_id(struct iris_bufmgr *bufmgr);
enum iris_madvice {
IRIS_MADVICE_WILL_NEED = 0,

View File

@ -39,3 +39,13 @@ iris_xe_init_global_vm(struct iris_bufmgr *bufmgr, uint32_t *vm_id)
*vm_id = create.vm_id;
return true;
}
bool
iris_xe_destroy_global_vm(struct iris_bufmgr *bufmgr)
{
struct drm_xe_vm_destroy destroy = {
.vm_id = iris_bufmgr_get_global_vm_id(bufmgr),
};
return intel_ioctl(iris_bufmgr_get_fd(bufmgr), DRM_IOCTL_XE_VM_DESTROY,
&destroy) == 0;
}

View File

@ -28,3 +28,4 @@
struct iris_bufmgr;
bool iris_xe_init_global_vm(struct iris_bufmgr *bufmgr, uint32_t *vm_id);
bool iris_xe_destroy_global_vm(struct iris_bufmgr *bufmgr);