aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Kuehling <Felix.Kuehling@amd.com>2018-03-15 17:27:41 -0400
committerOded Gabbay <oded.gabbay@gmail.com>2018-03-15 17:27:41 -0400
commit3486625bbfb629621f8a2402e2b24e7ab0a86ef4 (patch)
tree1ed69aa567002c2dc3183f3b053e2c3013ff7bf8
parent5b21d3e5fd2110df5a57a508188308351e698a5a (diff)
drm/amdgpu: Fix initial validation of PD BO for KFD VMs
Make sure the PD BO is valid and attach the eviction fence during VM creation. This ensures that the pd_phys_address is actually valid and an eviction that would invalidate it triggers a KFD process eviction like it should. v2: Use uninterruptible waiting in initial PD validation Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com> Acked-by: Christian König <christian.koenig@amd.com> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 64c33acb6cd8..cafe8a571636 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -812,7 +812,7 @@ int amdgpu_amdkfd_gpuvm_create_process_vm(struct kgd_dev *kgd, void **vm,
812{ 812{
813 int ret; 813 int ret;
814 struct amdgpu_vm *new_vm; 814 struct amdgpu_vm *new_vm;
815 struct amdkfd_process_info *info; 815 struct amdkfd_process_info *info = NULL;
816 struct amdgpu_device *adev = get_amdgpu_device(kgd); 816 struct amdgpu_device *adev = get_amdgpu_device(kgd);
817 817
818 new_vm = kzalloc(sizeof(*new_vm), GFP_KERNEL); 818 new_vm = kzalloc(sizeof(*new_vm), GFP_KERNEL);
@@ -851,6 +851,23 @@ int amdgpu_amdkfd_gpuvm_create_process_vm(struct kgd_dev *kgd, void **vm,
851 851
852 new_vm->process_info = *process_info; 852 new_vm->process_info = *process_info;
853 853
854 /* Validate page directory and attach eviction fence */
855 ret = amdgpu_bo_reserve(new_vm->root.base.bo, true);
856 if (ret)
857 goto reserve_pd_fail;
858 ret = vm_validate_pt_pd_bos(new_vm);
859 if (ret) {
860 pr_err("validate_pt_pd_bos() failed\n");
861 goto validate_pd_fail;
862 }
863 ret = ttm_bo_wait(&new_vm->root.base.bo->tbo, false, false);
864 if (ret)
865 goto wait_pd_fail;
866 amdgpu_bo_fence(new_vm->root.base.bo,
867 &new_vm->process_info->eviction_fence->base, true);
868 amdgpu_bo_unreserve(new_vm->root.base.bo);
869
870 /* Update process info */
854 mutex_lock(&new_vm->process_info->lock); 871 mutex_lock(&new_vm->process_info->lock);
855 list_add_tail(&new_vm->vm_list_node, 872 list_add_tail(&new_vm->vm_list_node,
856 &(new_vm->process_info->vm_list_head)); 873 &(new_vm->process_info->vm_list_head));
@@ -863,6 +880,10 @@ int amdgpu_amdkfd_gpuvm_create_process_vm(struct kgd_dev *kgd, void **vm,
863 880
864 return ret; 881 return ret;
865 882
883wait_pd_fail:
884validate_pd_fail:
885 amdgpu_bo_unreserve(new_vm->root.base.bo);
886reserve_pd_fail:
866create_evict_fence_fail: 887create_evict_fence_fail:
867 mutex_destroy(&info->lock); 888 mutex_destroy(&info->lock);
868 kfree(info); 889 kfree(info);