All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Unbind SPM VMID before freeing VM page tables
@ 2026-12-02  6:44 Srinivasan Shanmugam
  2026-12-02  6:55 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Srinivasan Shanmugam @ 2026-12-02  6:44 UTC (permalink / raw)
  To: Christian König, Alex Deucher
  Cc: amd-gfx, Srinivasan Shanmugam, Sunil Khatri

If a VM is closed while its SPM VMID is still reserved, amdgpu_vm_fini()
frees the root page table before releasing that VMID. The SPM VMID can
therefore remain bound to a page table that is being torn down.

Move the fallback VMID release after the existing waits and before
page-table cleanup. Releasing it points the VMID at a faulting address
and flushes its TLB.

Fixes: 7241de50e0cb ("drm/amdgpu: bind the SPM VMID's page table to the reserving VM")
Cc: Sunil Khatri <sunil.khatri@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 2f47a9c29c5f..19177ff37ac8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2913,6 +2913,13 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 	dma_fence_put(vm->last_seq_flush);
 	dma_fence_put(vm->last_tlb_inv);
 
+	/*
+	 * Unbind the fixed SPM VMID before freeing the root page table.
+	 * This also invalidates translations cached for that VMID.
+	 */
+	for (i = 0; i < AMDGPU_MAX_VMHUBS; i++)
+		amdgpu_vmid_free_spm(adev, vm, i);
+
 	list_for_each_entry_safe(mapping, tmp, &vm->freed, list) {
 		if (mapping->flags & AMDGPU_VM_PAGE_PRT && prt_fini_needed) {
 			amdgpu_vm_prt_fini(adev, vm);
@@ -2944,10 +2951,6 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 
 	dma_fence_put(vm->last_update);
 
-	for (i = 0; i < AMDGPU_MAX_VMHUBS; i++) {
-		amdgpu_vmid_free_spm(adev, vm, i);
-	}
-
 	ttm_lru_bulk_move_fini(&adev->mman.bdev, &vm->lru_bulk_move);
 
 	if (!amdgpu_vm_stats_is_zero(vm)) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-02  6:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02  6:44 [PATCH] drm/amdgpu: Unbind SPM VMID before freeing VM page tables Srinivasan Shanmugam
2026-12-02  6:55 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.