AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/amdgpu: re-validate per VM BOs if required
@ 2018-03-26  8:29 Chunming Zhou
       [not found] ` <20180326082955.11488-1-david1.zhou-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Chunming Zhou @ 2018-03-26  8:29 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Christian König, Christian König

From: Christian König <ckoenig.leichtzumerken@gmail.com>

If a per VM BO ends up in a allowed domain it never moves back into the
prefered domain.

Change-Id: Ifb3e561785d3b464da28c439b271c26825224c5e
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-and-Tested-by: Chunming Zhou <david1.zhou@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index e9a41dd05345..7db411a282ce 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1808,14 +1808,16 @@ int amdgpu_vm_handle_moved(struct amdgpu_device *adev,
 
 	spin_lock(&vm->status_lock);
 	while (!list_empty(&vm->moved)) {
-		struct amdgpu_bo_va *bo_va;
 		struct reservation_object *resv;
+		struct amdgpu_bo_va *bo_va;
+		struct amdgpu_bo *bo;
 
 		bo_va = list_first_entry(&vm->moved,
 			struct amdgpu_bo_va, base.vm_status);
 		spin_unlock(&vm->status_lock);
 
-		resv = bo_va->base.bo->tbo.resv;
+		bo = bo_va->base.bo;
+		resv = bo->tbo.resv;
 
 		/* Per VM BOs never need to bo cleared in the page tables */
 		if (resv == vm->root.base.bo->tbo.resv)
@@ -1835,6 +1837,15 @@ int amdgpu_vm_handle_moved(struct amdgpu_device *adev,
 			kcl_reservation_object_unlock(resv);
 
 		spin_lock(&vm->status_lock);
+
+		/* If the BO prefers to be in VRAM, but currently isn't add it
+		 * back to the evicted list so that it gets validated again on
+		 * the next command submission.
+		 */
+		if (resv == vm->root.base.bo->tbo.resv &&
+		    bo->preferred_domains == AMDGPU_GEM_DOMAIN_VRAM &&
+		    bo->tbo.mem.mem_type != TTM_PL_VRAM)
+			list_add_tail(&bo_va->base.vm_status, &vm->evicted);
 	}
 	spin_unlock(&vm->status_lock);
 
-- 
2.14.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] drm/amdgpu: add per vm bo validation order
       [not found] ` <20180326082955.11488-1-david1.zhou-5C7GfCeVMHo@public.gmane.org>
@ 2018-03-26  8:29   ` Chunming Zhou
       [not found]     ` <20180326082955.11488-2-david1.zhou-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Chunming Zhou @ 2018-03-26  8:29 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Chunming Zhou

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 {
-- 
2.14.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] drm/amdgpu: add per vm bo validation order
       [not found]     ` <20180326082955.11488-2-david1.zhou-5C7GfCeVMHo@public.gmane.org>
@ 2018-03-26  8:34       ` zhoucm1
  0 siblings, 0 replies; 4+ messages in thread
From: zhoucm1 @ 2018-03-26  8:34 UTC (permalink / raw)
  To: Chunming Zhou, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

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 {

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] drm/amdgpu: add per vm bo validation order
       [not found] ` <20180326084717.15465-1-david1.zhou-5C7GfCeVMHo@public.gmane.org>
@ 2018-03-26  8:47   ` Chunming Zhou
  0 siblings, 0 replies; 4+ messages in thread
From: Chunming Zhou @ 2018-03-26  8:47 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Chunming Zhou

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(-)

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 {
-- 
2.14.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-26  8:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-26  8:29 [PATCH 1/2] drm/amdgpu: re-validate per VM BOs if required Chunming Zhou
     [not found] ` <20180326082955.11488-1-david1.zhou-5C7GfCeVMHo@public.gmane.org>
2018-03-26  8:29   ` [PATCH 2/2] drm/amdgpu: add per vm bo validation order Chunming Zhou
     [not found]     ` <20180326082955.11488-2-david1.zhou-5C7GfCeVMHo@public.gmane.org>
2018-03-26  8:34       ` zhoucm1
  -- strict thread matches above, loose matches on Subject: below --
2018-03-26  8:47 [PATCH 1/2] drm/amdgpu: re-validate per VM BOs if required Chunming Zhou
     [not found] ` <20180326084717.15465-1-david1.zhou-5C7GfCeVMHo@public.gmane.org>
2018-03-26  8:47   ` [PATCH 2/2] drm/amdgpu: add per vm bo validation order Chunming Zhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox