drm/xe/vm: move xe_svm_init() earlier
In xe_vm_close_and_put() we need to be able to call xe_svm_fini(),
however during vm creation we can call this on the error path, before
having actually initialised the svm state, leading to various splats
followed by a fatal NPD.
Fixes: 6fd979c2f3 ("drm/xe: Add SVM init / close / fini to faulting VMs")
Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/4967
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://lore.kernel.org/r/20250514152424.149591-4-matthew.auld@intel.com
This commit is contained in:
@@ -1709,10 +1709,16 @@ struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags)
|
||||
xe_pm_runtime_get_noresume(xe);
|
||||
}
|
||||
|
||||
if (flags & XE_VM_FLAG_FAULT_MODE) {
|
||||
err = xe_svm_init(vm);
|
||||
if (err)
|
||||
goto err_no_resv;
|
||||
}
|
||||
|
||||
vm_resv_obj = drm_gpuvm_resv_object_alloc(&xe->drm);
|
||||
if (!vm_resv_obj) {
|
||||
err = -ENOMEM;
|
||||
goto err_no_resv;
|
||||
goto err_svm_fini;
|
||||
}
|
||||
|
||||
drm_gpuvm_init(&vm->gpuvm, "Xe VM", DRM_GPUVM_RESV_PROTECTED, &xe->drm,
|
||||
@@ -1783,12 +1789,6 @@ struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags)
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & XE_VM_FLAG_FAULT_MODE) {
|
||||
err = xe_svm_init(vm);
|
||||
if (err)
|
||||
goto err_close;
|
||||
}
|
||||
|
||||
if (number_tiles > 1)
|
||||
vm->composite_fence_ctx = dma_fence_context_alloc(1);
|
||||
|
||||
@@ -1802,6 +1802,11 @@ err_close:
|
||||
xe_vm_close_and_put(vm);
|
||||
return ERR_PTR(err);
|
||||
|
||||
err_svm_fini:
|
||||
if (flags & XE_VM_FLAG_FAULT_MODE) {
|
||||
vm->size = 0; /* close the vm */
|
||||
xe_svm_fini(vm);
|
||||
}
|
||||
err_no_resv:
|
||||
mutex_destroy(&vm->snap_mutex);
|
||||
for_each_tile(tile, xe, id)
|
||||
|
||||
Reference in New Issue
Block a user