[2/2] drm/amdgpu: add per vm bo validation order

Submitted by Zhou, David(ChunMing) on March 26, 2018, 8:47 a.m.

Details

Message ID 20180326084717.15465-2-david1.zhou@amd.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Zhou, David(ChunMing) March 26, 2018, 8:47 a.m.
Change-Id: I59f1da8a765efae8196c0b1599f47a8b8485c4d3
Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 +++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h |  6 ++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 7db411a282ce..4dd79276c579 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -205,12 +205,22 @@  int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 
 	spin_lock(&vm->status_lock);
 	while (!list_empty(&vm->evicted)) {
-		struct amdgpu_vm_bo_base *bo_base;
+		struct amdgpu_vm_bo_base *bo_base, *tmp;
 		struct amdgpu_bo *bo;
+		u64 bo_order;
 
 		bo_base = list_first_entry(&vm->evicted,
 					   struct amdgpu_vm_bo_base,
 					   vm_status);
+		bo_order = bo_base->order;
+		if (bo_order > 0) {
+			list_for_each_entry(tmp, &vm->evicted, vm_status) {
+				if (tmp->order < bo_order) {
+					bo_order = tmp->order;
+					bo_base = tmp;
+				}
+			}
+		}
 		spin_unlock(&vm->status_lock);
 
 		bo = bo_base->bo;
@@ -1903,6 +1913,7 @@  struct amdgpu_bo_va *amdgpu_vm_bo_add(struct amdgpu_device *adev,
 	 * */
 	spin_lock(&vm->status_lock);
 	list_move_tail(&bo_va->base.vm_status, &vm->evicted);
+	bo_va->base.order = (u64)atomic64_inc_return(&vm->bo_order);
 	spin_unlock(&vm->status_lock);
 
 	return bo_va;
@@ -2424,6 +2435,7 @@  int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	INIT_LIST_HEAD(&vm->relocated);
 	INIT_LIST_HEAD(&vm->moved);
 	INIT_LIST_HEAD(&vm->freed);
+	atomic64_set(&vm->bo_order, 0);
 
 	/* create scheduler entity for page table updates */
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index cf2c667ee538..bac5349d291e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -152,6 +152,9 @@  struct amdgpu_vm_bo_base {
 
 	/* protected by the BO being reserved */
 	bool				moved;
+
+	/* validate order */
+	u64				order;
 };
 
 struct amdgpu_vm_pt {
@@ -214,6 +217,9 @@  struct amdgpu_vm {
 
 	/* Limit non-retry fault storms */
 	unsigned int		fault_credit;
+
+	/* per vm bo order in this vm */
+	atomic64_t		bo_order;
 };
 
 struct amdgpu_vm_manager {