Skip to content

Commit 8cf8cde

Browse files
matt-auldThomas Hellström
authored andcommitted
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: 6fd979c ("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 <[email protected]> Cc: Matthew Brost <[email protected]> Reviewed-by: Matthew Brost <[email protected]> Link: https://lore.kernel.org/r/[email protected] (cherry picked from commit 4f296d7) Signed-off-by: Thomas Hellström <[email protected]>
1 parent a63e99b commit 8cf8cde

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

drivers/gpu/drm/xe/xe_vm.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,10 +1683,16 @@ struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags)
16831683
xe_pm_runtime_get_noresume(xe);
16841684
}
16851685

1686+
if (flags & XE_VM_FLAG_FAULT_MODE) {
1687+
err = xe_svm_init(vm);
1688+
if (err)
1689+
goto err_no_resv;
1690+
}
1691+
16861692
vm_resv_obj = drm_gpuvm_resv_object_alloc(&xe->drm);
16871693
if (!vm_resv_obj) {
16881694
err = -ENOMEM;
1689-
goto err_no_resv;
1695+
goto err_svm_fini;
16901696
}
16911697

16921698
drm_gpuvm_init(&vm->gpuvm, "Xe VM", DRM_GPUVM_RESV_PROTECTED, &xe->drm,
@@ -1757,12 +1763,6 @@ struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags)
17571763
}
17581764
}
17591765

1760-
if (flags & XE_VM_FLAG_FAULT_MODE) {
1761-
err = xe_svm_init(vm);
1762-
if (err)
1763-
goto err_close;
1764-
}
1765-
17661766
if (number_tiles > 1)
17671767
vm->composite_fence_ctx = dma_fence_context_alloc(1);
17681768

@@ -1776,6 +1776,11 @@ struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags)
17761776
xe_vm_close_and_put(vm);
17771777
return ERR_PTR(err);
17781778

1779+
err_svm_fini:
1780+
if (flags & XE_VM_FLAG_FAULT_MODE) {
1781+
vm->size = 0; /* close the vm */
1782+
xe_svm_fini(vm);
1783+
}
17791784
err_no_resv:
17801785
mutex_destroy(&vm->snap_mutex);
17811786
for_each_tile(tile, xe, id)

0 commit comments

Comments
 (0)