From b22720d7a7012280e10e3319977ad772ea72e9eb Mon Sep 17 00:00:00 2001 From: jsg Date: Wed, 10 Jun 2026 00:19:24 +0000 Subject: [PATCH] drm/amdgpu: fix calling VM invalidation in amdgpu_hmm_invalidate_gfx From Christian Koenig fa372f4e8aeff6d0d3dd2f14b9165b4013e72a6d in linux-6.18.y/6.18.35 1c824497d8acd3187d585d6187cedc1897dcc871 in mainline linux --- sys/dev/pci/drm/amd/amdgpu/amdgpu_hmm.c | 1 + sys/dev/pci/drm/amd/amdgpu/amdgpu_vm.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_hmm.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_hmm.c index 2c6a6b85811..621c57cf24b 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_hmm.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_hmm.c @@ -78,6 +78,7 @@ static bool amdgpu_hmm_invalidate_gfx(struct mmu_interval_notifier *mni, mmu_interval_set_seq(mni, cur_seq); + amdgpu_vm_bo_invalidate(bo, false); r = dma_resv_wait_timeout(bo->tbo.base.resv, DMA_RESV_USAGE_BOOKKEEP, false, MAX_SCHEDULE_TIMEOUT); mutex_unlock(&adev->notifier_lock); diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_vm.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_vm.c index c824cbfee45..3b4aa9abe30 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_vm.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_vm.c @@ -1672,6 +1672,7 @@ int amdgpu_vm_handle_moved(struct amdgpu_device *adev, { struct amdgpu_bo_va *bo_va; struct dma_resv *resv; + struct amdgpu_bo *bo; bool clear, unlock; int r; @@ -1691,11 +1692,13 @@ int amdgpu_vm_handle_moved(struct amdgpu_device *adev, while (!list_empty(&vm->invalidated)) { bo_va = list_first_entry(&vm->invalidated, struct amdgpu_bo_va, base.vm_status); - resv = bo_va->base.bo->tbo.base.resv; + bo = bo_va->base.bo; + resv = bo->tbo.base.resv; spin_unlock(&vm->status_lock); /* Try to reserve the BO to avoid clearing its ptes */ - if (!adev->debug_vm && dma_resv_trylock(resv)) { + if (!adev->debug_vm && !amdgpu_ttm_tt_get_usermm(bo->tbo.ttm) && + dma_resv_trylock(resv)) { clear = false; unlock = true; /* The caller is already holding the reservation lock */