[09/13] drm/amdgpu: add bo index counter

Submitted by Zhou, David(ChunMing) on May 9, 2018, 6:45 a.m.

Details

Message ID 20180509064543.15937-10-david1.zhou@amd.com
State New
Headers show
Series "*** per vm lru ***" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Zhou, David(ChunMing) May 9, 2018, 6:45 a.m.
Change-Id: Iaec4e12164124c155753fc7aea85f76fde8d1ed6
Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c     | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h     | 1 +
 3 files changed, 3 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index a457738c512c..63faa271a7d1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -424,6 +424,7 @@  static int amdgpu_bo_do_create(struct amdgpu_device *adev,
 		bo->tbo.priority = 1;
 		bo->vm_lru = &adev->kernel_vm_lru;
 	}
+	bo->index = (u64)atomic64_inc_return(&bo->vm_lru->bo_index);
 
 	r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp->type,
 				 &bo->placement, page_align, &ctx, acc_size,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 1a09c07bbf20..5bef4ffa1c87 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -142,6 +142,7 @@  int amdgpu_vm_lru_init(struct amdgpu_vm_lru *vm_lru, struct amdgpu_device *adev,
 	spin_unlock(&glob->lru_lock);
 
 	vm_lru->resv = resv;
+	atomic64_set(&vm_lru->bo_index, 0);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 84400673d710..773f1bda2b98 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -141,6 +141,7 @@  struct amdgpu_vm_lru {
 	struct rb_root fixed_lru[TTM_NUM_MEM_TYPES][TTM_MAX_BO_PRIORITY];
 	struct list_head dynamic_lru[TTM_NUM_MEM_TYPES][TTM_MAX_BO_PRIORITY];
 	struct reservation_object *resv;
+	atomic64_t bo_index;
 };
 
 /* base structure for tracking BO usage in a VM */