Skip to content

Commit 4f296d7

Browse files
committed
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]
1 parent 96af397 commit 4f296d7

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
@@ -1709,10 +1709,16 @@ struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags)
17091709
xe_pm_runtime_get_noresume(xe);
17101710
}
17111711

1712+
if (flags & XE_VM_FLAG_FAULT_MODE) {
1713+
err = xe_svm_init(vm);
1714+
if (err)
1715+
goto err_no_resv;
1716+
}
1717+
17121718
vm_resv_obj = drm_gpuvm_resv_object_alloc(&xe->drm);
17131719
if (!vm_resv_obj) {
17141720
err = -ENOMEM;
1715-
goto err_no_resv;
1721+
goto err_svm_fini;
17161722
}
17171723

17181724
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)
17831789
}
17841790
}
17851791

1786-
if (flags & XE_VM_FLAG_FAULT_MODE) {
1787-
err = xe_svm_init(vm);
1788-
if (err)
1789-
goto err_close;
1790-
}
1791-
17921792
if (number_tiles > 1)
17931793
vm->composite_fence_ctx = dma_fence_context_alloc(1);
17941794

@@ -1802,6 +1802,11 @@ struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags)
18021802
xe_vm_close_and_put(vm);
18031803
return ERR_PTR(err);
18041804

1805+
err_svm_fini:
1806+
if (flags & XE_VM_FLAG_FAULT_MODE) {
1807+
vm->size = 0; /* close the vm */
1808+
xe_svm_fini(vm);
1809+
}
18051810
err_no_resv:
18061811
mutex_destroy(&vm->snap_mutex);
18071812
for_each_tile(tile, xe, id)

0 commit comments

Comments
 (0)