From 34d7be5dc28041b95254da517fd0f0f740544ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Thu, 24 Aug 2017 12:32:55 +0200 Subject: drm/amdgpu: fix and cleanup VM ready check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stop checking the mapped BO itself, cause that one is certainly not a page table. Additional to that move the code into amdgpu_vm.c Signed-off-by: Christian König Reviewed-by: Chunming Zhou Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c') diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index db63ff5c80f2..67c37b22f8ef 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -231,6 +231,38 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, adev->mman.bdev.glob); } +/** + * amdgpu_vm_check - helper for amdgpu_vm_ready + */ +static int amdgpu_vm_check(void *param, struct amdgpu_bo *bo) +{ + /* if anything is swapped out don't swap it in here, + just abort and wait for the next CS */ + if (!amdgpu_bo_gpu_accessible(bo)) + return -ERESTARTSYS; + + if (bo->shadow && !amdgpu_bo_gpu_accessible(bo->shadow)) + return -ERESTARTSYS; + + return 0; +} + +/** + * amdgpu_vm_ready - check VM is ready for updates + * + * @adev: amdgpu device + * @vm: VM to check + * + * Check if all VM PDs/PTs are ready for updates + */ +bool amdgpu_vm_ready(struct amdgpu_device *adev, struct amdgpu_vm *vm) +{ + if (amdgpu_vm_check(NULL, vm->root.bo)) + return false; + + return !amdgpu_vm_validate_pt_bos(adev, vm, amdgpu_vm_check, NULL); +} + /** * amdgpu_vm_alloc_levels - allocate the PD/PT levels * -- cgit v1.2.2