From 1b04e4129dcd6f3a7303d93adb4c84717f98095a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Tue, 14 Feb 2017 14:50:50 +0100 Subject: [PATCH] drm/amdgpu: minor PRT turnoff fix (v2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When two VMs stop using PRT support at the same time we might not disable it in the right order otherwise. v2: agd: rebase Signed-off-by: Christian König Reviewed-by: Nicolai Hähnle Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index fa06b2a4645f..2510d255630f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -1200,7 +1200,8 @@ static void amdgpu_vm_prt_cb(struct dma_fence *fence, struct dma_fence_cb *_cb) { struct amdgpu_prt_cb *cb = container_of(_cb, struct amdgpu_prt_cb, cb); - amdgpu_vm_update_prt_state(cb->adev); + if (atomic_dec_return(&cb->adev->vm_manager.num_prt_mappings) == 0) + amdgpu_vm_update_prt_state(cb->adev); kfree(cb); } @@ -1219,17 +1220,14 @@ static void amdgpu_vm_free_mapping(struct amdgpu_device *adev, struct amdgpu_bo_va_mapping *mapping, struct dma_fence *fence) { - if ((mapping->flags & AMDGPU_PTE_PRT) && - atomic_dec_return(&adev->vm_manager.num_prt_mappings) == 0) { + if (mapping->flags & AMDGPU_PTE_PRT) { struct amdgpu_prt_cb *cb = kmalloc(sizeof(struct amdgpu_prt_cb), GFP_KERNEL); cb->adev = adev; if (!fence || dma_fence_add_callback(fence, &cb->cb, - amdgpu_vm_prt_cb)) { - amdgpu_vm_update_prt_state(adev); - kfree(cb); - } + amdgpu_vm_prt_cb)) + amdgpu_vm_prt_cb(fence, &cb->cb); } kfree(mapping); }