aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index a07c85815b7a..4f10f5aba00b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2757,6 +2757,37 @@ error_free_sched_entity:
2757} 2757}
2758 2758
2759/** 2759/**
2760 * amdgpu_vm_check_clean_reserved - check if a VM is clean
2761 *
2762 * @adev: amdgpu_device pointer
2763 * @vm: the VM to check
2764 *
2765 * check all entries of the root PD, if any subsequent PDs are allocated,
2766 * it means there are page table creating and filling, and is no a clean
2767 * VM
2768 *
2769 * Returns:
2770 * 0 if this VM is clean
2771 */
2772static int amdgpu_vm_check_clean_reserved(struct amdgpu_device *adev,
2773 struct amdgpu_vm *vm)
2774{
2775 enum amdgpu_vm_level root = adev->vm_manager.root_level;
2776 unsigned int entries = amdgpu_vm_num_entries(adev, root);
2777 unsigned int i = 0;
2778
2779 if (!(vm->root.entries))
2780 return 0;
2781
2782 for (i = 0; i < entries; i++) {
2783 if (vm->root.entries[i].base.bo)
2784 return -EINVAL;
2785 }
2786
2787 return 0;
2788}
2789
2790/**
2760 * amdgpu_vm_make_compute - Turn a GFX VM into a compute VM 2791 * amdgpu_vm_make_compute - Turn a GFX VM into a compute VM
2761 * 2792 *
2762 * @adev: amdgpu_device pointer 2793 * @adev: amdgpu_device pointer
@@ -2786,10 +2817,9 @@ int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm, uns
2786 return r; 2817 return r;
2787 2818
2788 /* Sanity checks */ 2819 /* Sanity checks */
2789 if (!RB_EMPTY_ROOT(&vm->va.rb_root) || vm->root.entries) { 2820 r = amdgpu_vm_check_clean_reserved(adev, vm);
2790 r = -EINVAL; 2821 if (r)
2791 goto unreserve_bo; 2822 goto unreserve_bo;
2792 }
2793 2823
2794 if (pasid) { 2824 if (pasid) {
2795 unsigned long flags; 2825 unsigned long flags;