drm/amdgpu: Rename vm invalidate lock to status_lock
authorPhilip Yang <Philip.Yang@amd.com>
Fri, 16 Sep 2022 02:33:52 +0000 (22:33 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 21 Sep 2022 19:24:06 +0000 (15:24 -0400)
The vm status_lock will be used to protect all vm status lists.

Signed-off-by: Philip Yang <Philip.Yang@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Acked-by: Felix Kuehling <Felix.Kuehling@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 690fd4f..596f1ea 100644 (file)
@@ -225,9 +225,9 @@ static void amdgpu_vm_bo_idle(struct amdgpu_vm_bo_base *vm_bo)
  */
 static void amdgpu_vm_bo_invalidated(struct amdgpu_vm_bo_base *vm_bo)
 {
-       spin_lock(&vm_bo->vm->invalidated_lock);
+       spin_lock(&vm_bo->vm->status_lock);
        list_move(&vm_bo->vm_status, &vm_bo->vm->invalidated);
-       spin_unlock(&vm_bo->vm->invalidated_lock);
+       spin_unlock(&vm_bo->vm->status_lock);
 }
 
 /**
@@ -256,9 +256,9 @@ static void amdgpu_vm_bo_relocated(struct amdgpu_vm_bo_base *vm_bo)
  */
 static void amdgpu_vm_bo_done(struct amdgpu_vm_bo_base *vm_bo)
 {
-       spin_lock(&vm_bo->vm->invalidated_lock);
+       spin_lock(&vm_bo->vm->status_lock);
        list_move(&vm_bo->vm_status, &vm_bo->vm->done);
-       spin_unlock(&vm_bo->vm->invalidated_lock);
+       spin_unlock(&vm_bo->vm->status_lock);
 }
 
 /**
@@ -936,7 +936,7 @@ void amdgpu_vm_get_memory(struct amdgpu_vm *vm, uint64_t *vram_mem,
                amdgpu_bo_get_memory(bo_va->base.bo, vram_mem,
                                gtt_mem, cpu_mem);
        }
-       spin_lock(&vm->invalidated_lock);
+       spin_lock(&vm->status_lock);
        list_for_each_entry_safe(bo_va, tmp, &vm->invalidated, base.vm_status) {
                if (!bo_va->base.bo)
                        continue;
@@ -949,7 +949,7 @@ void amdgpu_vm_get_memory(struct amdgpu_vm *vm, uint64_t *vram_mem,
                amdgpu_bo_get_memory(bo_va->base.bo, vram_mem,
                                gtt_mem, cpu_mem);
        }
-       spin_unlock(&vm->invalidated_lock);
+       spin_unlock(&vm->status_lock);
 }
 /**
  * amdgpu_vm_bo_update - update all BO mappings in the vm page table
@@ -1290,12 +1290,12 @@ int amdgpu_vm_handle_moved(struct amdgpu_device *adev,
                        return r;
        }
 
-       spin_lock(&vm->invalidated_lock);
+       spin_lock(&vm->status_lock);
        while (!list_empty(&vm->invalidated)) {
                bo_va = list_first_entry(&vm->invalidated, struct amdgpu_bo_va,
                                         base.vm_status);
                resv = bo_va->base.bo->tbo.base.resv;
-               spin_unlock(&vm->invalidated_lock);
+               spin_unlock(&vm->status_lock);
 
                /* Try to reserve the BO to avoid clearing its ptes */
                if (!amdgpu_vm_debug && dma_resv_trylock(resv))
@@ -1310,9 +1310,9 @@ int amdgpu_vm_handle_moved(struct amdgpu_device *adev,
 
                if (!clear)
                        dma_resv_unlock(resv);
-               spin_lock(&vm->invalidated_lock);
+               spin_lock(&vm->status_lock);
        }
-       spin_unlock(&vm->invalidated_lock);
+       spin_unlock(&vm->status_lock);
 
        return 0;
 }
@@ -1763,9 +1763,9 @@ void amdgpu_vm_bo_del(struct amdgpu_device *adev,
                }
        }
 
-       spin_lock(&vm->invalidated_lock);
+       spin_lock(&vm->status_lock);
        list_del(&bo_va->base.vm_status);
-       spin_unlock(&vm->invalidated_lock);
+       spin_unlock(&vm->status_lock);
 
        list_for_each_entry_safe(mapping, next, &bo_va->valids, list) {
                list_del(&mapping->list);
@@ -2019,7 +2019,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)
        INIT_LIST_HEAD(&vm->moved);
        INIT_LIST_HEAD(&vm->idle);
        INIT_LIST_HEAD(&vm->invalidated);
-       spin_lock_init(&vm->invalidated_lock);
+       spin_lock_init(&vm->status_lock);
        INIT_LIST_HEAD(&vm->freed);
        INIT_LIST_HEAD(&vm->done);
 
@@ -2584,7 +2584,7 @@ void amdgpu_debugfs_vm_bo_info(struct amdgpu_vm *vm, struct seq_file *m)
        id = 0;
 
        seq_puts(m, "\tInvalidated BOs:\n");
-       spin_lock(&vm->invalidated_lock);
+       spin_lock(&vm->status_lock);
        list_for_each_entry_safe(bo_va, tmp, &vm->invalidated, base.vm_status) {
                if (!bo_va->base.bo)
                        continue;
@@ -2599,7 +2599,7 @@ void amdgpu_debugfs_vm_bo_info(struct amdgpu_vm *vm, struct seq_file *m)
                        continue;
                total_done += amdgpu_bo_print_info(id++, bo_va->base.bo, m);
        }
-       spin_unlock(&vm->invalidated_lock);
+       spin_unlock(&vm->status_lock);
        total_done_objs = id;
 
        seq_printf(m, "\tTotal idle size:        %12lld\tobjs:\t%d\n", total_idle,
index 9ecb7f6..e6dd112 100644 (file)
@@ -254,6 +254,9 @@ struct amdgpu_vm {
        bool                    evicting;
        unsigned int            saved_flags;
 
+       /* Lock to protect vm_bo add/del/move on all lists of vm */
+       spinlock_t              status_lock;
+
        /* BOs who needs a validation */
        struct list_head        evicted;
 
@@ -268,7 +271,6 @@ struct amdgpu_vm {
 
        /* regular invalidated BOs, but not yet updated in the PT */
        struct list_head        invalidated;
-       spinlock_t              invalidated_lock;
 
        /* BO mappings freed, but not yet updated in the PT */
        struct list_head        freed;