drm/amdgpu: rework moved handling in the VM v2
authorChristian König <christian.koenig@amd.com>
Wed, 23 Aug 2017 14:13:33 +0000 (16:13 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 29 Aug 2017 19:28:02 +0000 (15:28 -0400)
Instead of using the vm_state use a separate flag to note
that the BO was moved.

v2: reorder patches to avoid temporary lockless access

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h

index 67c37b22f8ef36d66d5bfea85a9a783c820a71be..1b36c62997b3a27a8e0f05839bc1ed5d0b3efe3e 100644 (file)
@@ -1788,10 +1788,16 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,
        else
                flags = 0x0;
 
-       spin_lock(&vm->status_lock);
-       if (!list_empty(&bo_va->base.vm_status))
+       if (!clear && bo_va->base.moved) {
+               bo_va->base.moved = false;
                list_splice_init(&bo_va->valids, &bo_va->invalids);
-       spin_unlock(&vm->status_lock);
+
+       } else {
+               spin_lock(&vm->status_lock);
+               if (!list_empty(&bo_va->base.vm_status))
+                       list_splice_init(&bo_va->valids, &bo_va->invalids);
+               spin_unlock(&vm->status_lock);
+       }
 
        list_for_each_entry(mapping, &bo_va->invalids, list) {
                r = amdgpu_vm_bo_split_mapping(adev, exclusive, pages_addr, vm,
@@ -2419,6 +2425,7 @@ void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev,
        struct amdgpu_vm_bo_base *bo_base;
 
        list_for_each_entry(bo_base, &bo->va, bo_list) {
+               bo_base->moved = true;
                spin_lock(&bo_base->vm->status_lock);
                if (list_empty(&bo_base->vm_status))
                        list_add(&bo_base->vm_status,
index 9347d28c3c1e5ccda9ef41c958b0e404d9e605d6..1b478e62a948af508ea8fd1f36f31468f0f4d7c6 100644 (file)
@@ -105,6 +105,9 @@ struct amdgpu_vm_bo_base {
 
        /* protected by spinlock */
        struct list_head                vm_status;
+
+       /* protected by the BO being reserved */
+       bool                            moved;
 };
 
 struct amdgpu_vm_pt {