[PATCH 1/3] drm/amdgpu: make all per vm BOs list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



the list decides the lru order.

Change-Id: I8baf85aefd5781501599ff672949a9b71099a30e
Signed-off-by: Chunming Zhou <david1.zhou at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 7 +++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index e9a41dd05345..5e35e23511cf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1866,6 +1866,7 @@ struct amdgpu_bo_va *amdgpu_vm_bo_add(struct amdgpu_device *adev,
 	}
 	bo_va->base.vm = vm;
 	bo_va->base.bo = bo;
+	INIT_LIST_HEAD(&bo_va->base.vm_bo);
 	INIT_LIST_HEAD(&bo_va->base.bo_list);
 	INIT_LIST_HEAD(&bo_va->base.vm_status);
 
@@ -1881,6 +1882,10 @@ struct amdgpu_bo_va *amdgpu_vm_bo_add(struct amdgpu_device *adev,
 	if (bo->tbo.resv != vm->root.base.bo->tbo.resv)
 		return bo_va;
 
+	spin_lock(&vm->status_lock);
+	list_add_tail(&bo_va->base.vm_bo, &vm->vm_bo_list);
+	spin_unlock(&vm->status_lock);
+
 	if (bo->preferred_domains &
 	    amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type))
 		return bo_va;
@@ -2237,6 +2242,7 @@ void amdgpu_vm_bo_rmv(struct amdgpu_device *adev,
 
 	spin_lock(&vm->status_lock);
 	list_del(&bo_va->base.vm_status);
+	list_del(&bo_va->base.vm_bo);
 	spin_unlock(&vm->status_lock);
 
 	list_for_each_entry_safe(mapping, next, &bo_va->valids, list) {
@@ -2409,6 +2415,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	for (i = 0; i < AMDGPU_MAX_VMHUBS; i++)
 		vm->reserved_vmid[i] = NULL;
 	spin_lock_init(&vm->status_lock);
+	INIT_LIST_HEAD(&vm->vm_bo_list);
 	INIT_LIST_HEAD(&vm->evicted);
 	INIT_LIST_HEAD(&vm->relocated);
 	INIT_LIST_HEAD(&vm->moved);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index cf2c667ee538..1886a561c84e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -144,6 +144,9 @@ struct amdgpu_vm_bo_base {
 	struct amdgpu_vm		*vm;
 	struct amdgpu_bo		*bo;
 
+	/* protected by vm status lock */
+	struct list_head		vm_bo;
+
 	/* protected by bo being reserved */
 	struct list_head		bo_list;
 
@@ -177,6 +180,9 @@ struct amdgpu_vm {
 	/* protecting invalidated */
 	spinlock_t		status_lock;
 
+	/* protected by status lock */
+	struct list_head	vm_bo_list;
+
 	/* BOs who needs a validation */
 	struct list_head	evicted;
 
-- 
2.14.1



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux