aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2018-04-19 05:08:24 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-05-24 11:07:53 -0400
commit789f3317ed33e34fa97c8918c075c68a62e51a4d (patch)
treeb0dd192762bdc382766c88be337cd8123c12f307 /drivers/gpu/drm/amd
parent91ccdd24a1955dbec97a6d61322be214b7de1974 (diff)
drm/amdgpu: further optimize amdgpu_vm_handle_moved
Splice the moved list to a local one to avoid taking the lock over and over again. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Chunming Zhou <david1.zhou@amd.com> Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 3be4d5fc60b3..4d88b060fbde 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1781,19 +1781,18 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev,
1781int amdgpu_vm_handle_moved(struct amdgpu_device *adev, 1781int amdgpu_vm_handle_moved(struct amdgpu_device *adev,
1782 struct amdgpu_vm *vm) 1782 struct amdgpu_vm *vm)
1783{ 1783{
1784 struct amdgpu_bo_va *bo_va, *tmp;
1785 struct list_head moved;
1784 bool clear; 1786 bool clear;
1785 int r = 0; 1787 int r;
1786 1788
1789 INIT_LIST_HEAD(&moved);
1787 spin_lock(&vm->moved_lock); 1790 spin_lock(&vm->moved_lock);
1788 while (!list_empty(&vm->moved)) { 1791 list_splice_init(&vm->moved, &moved);
1789 struct amdgpu_bo_va *bo_va; 1792 spin_unlock(&vm->moved_lock);
1790 struct reservation_object *resv;
1791
1792 bo_va = list_first_entry(&vm->moved,
1793 struct amdgpu_bo_va, base.vm_status);
1794 spin_unlock(&vm->moved_lock);
1795 1793
1796 resv = bo_va->base.bo->tbo.resv; 1794 list_for_each_entry_safe(bo_va, tmp, &moved, base.vm_status) {
1795 struct reservation_object *resv = bo_va->base.bo->tbo.resv;
1797 1796
1798 /* Per VM BOs never need to bo cleared in the page tables */ 1797 /* Per VM BOs never need to bo cleared in the page tables */
1799 if (resv == vm->root.base.bo->tbo.resv) 1798 if (resv == vm->root.base.bo->tbo.resv)
@@ -1806,17 +1805,19 @@ int amdgpu_vm_handle_moved(struct amdgpu_device *adev,
1806 clear = true; 1805 clear = true;
1807 1806
1808 r = amdgpu_vm_bo_update(adev, bo_va, clear); 1807 r = amdgpu_vm_bo_update(adev, bo_va, clear);
1809 if (r) 1808 if (r) {
1809 spin_lock(&vm->moved_lock);
1810 list_splice(&moved, &vm->moved);
1811 spin_unlock(&vm->moved_lock);
1810 return r; 1812 return r;
1813 }
1811 1814
1812 if (!clear && resv != vm->root.base.bo->tbo.resv) 1815 if (!clear && resv != vm->root.base.bo->tbo.resv)
1813 reservation_object_unlock(resv); 1816 reservation_object_unlock(resv);
1814 1817
1815 spin_lock(&vm->moved_lock);
1816 } 1818 }
1817 spin_unlock(&vm->moved_lock);
1818 1819
1819 return r; 1820 return 0;
1820} 1821}
1821 1822
1822/** 1823/**