aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/radeon_gart.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_gart.c')
-rw-r--r--drivers/gpu/drm/radeon/radeon_gart.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
index 1b1c001e269a..2c594910064d 100644
--- a/drivers/gpu/drm/radeon/radeon_gart.c
+++ b/drivers/gpu/drm/radeon/radeon_gart.c
@@ -662,7 +662,31 @@ void radeon_vm_fence(struct radeon_device *rdev,
662 vm->fence = radeon_fence_ref(fence); 662 vm->fence = radeon_fence_ref(fence);
663} 663}
664 664
665/* object have to be reserved */ 665/**
666 * radeon_vm_bo_find - find the bo_va for a specific vm & bo
667 *
668 * @vm: requested vm
669 * @bo: requested buffer object
670 *
671 * Find @bo inside the requested vm (cayman+).
672 * Search inside the @bos vm list for the requested vm
673 * Returns the found bo_va or NULL if none is found
674 *
675 * Object has to be reserved!
676 */
677struct radeon_bo_va *radeon_vm_bo_find(struct radeon_vm *vm,
678 struct radeon_bo *bo)
679{
680 struct radeon_bo_va *bo_va;
681
682 list_for_each_entry(bo_va, &bo->va, bo_list) {
683 if (bo_va->vm == vm) {
684 return bo_va;
685 }
686 }
687 return NULL;
688}
689
666/** 690/**
667 * radeon_vm_bo_add - add a bo to a specific vm 691 * radeon_vm_bo_add - add a bo to a specific vm
668 * 692 *
@@ -676,6 +700,8 @@ void radeon_vm_fence(struct radeon_device *rdev,
676 * Add @bo to the list of bos associated with the vm and validate 700 * Add @bo to the list of bos associated with the vm and validate
677 * the offset requested within the vm address space. 701 * the offset requested within the vm address space.
678 * Returns 0 for success, error for failure. 702 * Returns 0 for success, error for failure.
703 *
704 * Object has to be reserved!
679 */ 705 */
680int radeon_vm_bo_add(struct radeon_device *rdev, 706int radeon_vm_bo_add(struct radeon_device *rdev,
681 struct radeon_vm *vm, 707 struct radeon_vm *vm,
@@ -823,7 +849,7 @@ int radeon_vm_bo_update_pte(struct radeon_device *rdev,
823 if (vm->sa_bo == NULL) 849 if (vm->sa_bo == NULL)
824 return 0; 850 return 0;
825 851
826 bo_va = radeon_bo_va(bo, vm); 852 bo_va = radeon_vm_bo_find(vm, bo);
827 if (bo_va == NULL) { 853 if (bo_va == NULL) {
828 dev_err(rdev->dev, "bo %p not in vm %p\n", bo, vm); 854 dev_err(rdev->dev, "bo %p not in vm %p\n", bo, vm);
829 return -EINVAL; 855 return -EINVAL;
@@ -912,7 +938,7 @@ int radeon_vm_bo_rmv(struct radeon_device *rdev,
912 struct radeon_bo_va *bo_va; 938 struct radeon_bo_va *bo_va;
913 int r; 939 int r;
914 940
915 bo_va = radeon_bo_va(bo, vm); 941 bo_va = radeon_vm_bo_find(vm, bo);
916 if (bo_va == NULL) 942 if (bo_va == NULL)
917 return 0; 943 return 0;
918 944
@@ -1009,7 +1035,7 @@ void radeon_vm_fini(struct radeon_device *rdev, struct radeon_vm *vm)
1009 */ 1035 */
1010 r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false); 1036 r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false);
1011 if (!r) { 1037 if (!r) {
1012 bo_va = radeon_bo_va(rdev->ring_tmp_bo.bo, vm); 1038 bo_va = radeon_vm_bo_find(vm, rdev->ring_tmp_bo.bo);
1013 list_del_init(&bo_va->bo_list); 1039 list_del_init(&bo_va->bo_list);
1014 list_del_init(&bo_va->vm_list); 1040 list_del_init(&bo_va->vm_list);
1015 radeon_bo_unreserve(rdev->ring_tmp_bo.bo); 1041 radeon_bo_unreserve(rdev->ring_tmp_bo.bo);