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

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

Details

Message ID 20180326082955.11488-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:29 a.m.
Change-Id: I59f1da8a765efae8196c0b1599f47a8b8485c4d3
Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 +++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h |  6 ++++++
 2 files changed, 17 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..3543e394adac 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -205,12 +205,20 @@  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;
+		list_for_each_entry(tmp, &vm->evicted, vm_status) {
+			if (tmp->order < bo_order) {
+				bo_order = bo_base->order;
+				bo_base = tmp;
+			}
+		}
 		spin_unlock(&vm->status_lock);
 
 		bo = bo_base->bo;
@@ -1903,6 +1911,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 +2433,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 {

Comments

pls ignore this one, will re-send it.


On 2018年03月26日 16:29, Chunming Zhou wrote:
> Change-Id: I59f1da8a765efae8196c0b1599f47a8b8485c4d3
> Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 +++++++++++-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h |  6 ++++++
>   2 files changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 7db411a282ce..3543e394adac 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -205,12 +205,20 @@ 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;
> +		list_for_each_entry(tmp, &vm->evicted, vm_status) {
> +			if (tmp->order < bo_order) {
> +				bo_order = bo_base->order;
> +				bo_base = tmp;
> +			}
> +		}
>   		spin_unlock(&vm->status_lock);
>   
>   		bo = bo_base->bo;
> @@ -1903,6 +1911,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 +2433,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 {