iris: Implement the function to destroy VM in Xe
authorJosé Roberto de Souza <jose.souza@intel.com>
Tue, 14 Feb 2023 17:25:28 +0000 (09:25 -0800)
committerMarge Bot <emma+marge@anholt.net>
Fri, 17 Mar 2023 19:31:56 +0000 (19:31 +0000)
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>

src/gallium/drivers/iris/iris_bufmgr.c
src/gallium/drivers/iris/iris_bufmgr.h
src/gallium/drivers/iris/xe/iris_bufmgr.c
src/gallium/drivers/iris/xe/iris_bufmgr.h

index f00e3ca..d7429c8 100644 (file)
@@ -1618,6 +1618,21 @@ iris_bo_wait_rendering(struct iris_bo *bo)
 }
 
 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)
 {
    iris_destroy_border_color_pool(&bufmgr->border_color_pool);
@@ -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;
+}
index e9fe711..b70bb95 100644 (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,
index 4af9a46..893420f 100644 (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;
+}
index 67ee58e..ae24a98 100644 (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);