All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] drm/ttm: add allow_reserved_eviction and resv into ttm_operation_ctx
@ 2017-12-13  5:17 Roger He
       [not found] ` <1513142278-4294-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Roger He @ 2017-12-13  5:17 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Roger He, Christian.Koenig-5C7GfCeVMHo

allow_reserved_eviction: Allow eviction of reserved BOs
resv: Reservation object to allow reserved evictions with

Change-Id: I01ea482e8c7470014196eb218e2ff8913306eef0
Signed-off-by: Roger He <Hongbo.He@amd.com>
---
 include/drm/ttm/ttm_bo_api.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 368eb02..c126330 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -263,6 +263,8 @@ struct ttm_bo_kmap_obj {
  *
  * @interruptible: Sleep interruptible if sleeping.
  * @no_wait_gpu: Return immediately if the GPU is busy.
+ * @allow_reserved_eviction: Allow eviction of reserved BOs.
+ * @resv: Reservation object to allow reserved evictions with.
  *
  * Context for TTM operations like changing buffer placement or general memory
  * allocation.
@@ -270,6 +272,8 @@ struct ttm_bo_kmap_obj {
 struct ttm_operation_ctx {
 	bool interruptible;
 	bool no_wait_gpu;
+	bool allow_reserved_eviction;
+	struct reservation_object *resv;
 	uint64_t bytes_moved;
 };
 
-- 
2.7.4

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

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

* [PATCH 2/3] drm/amd/amdgpu: init allow_reserved_eviction and resv when create a new bo
       [not found] ` <1513142278-4294-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
@ 2017-12-13  5:17   ` Roger He
       [not found]     ` <1513142278-4294-2-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
  2017-12-13 10:03     ` Michel Dänzer
  2017-12-13  5:17   ` [PATCH 3/3] drm/ttm: enable eviction for Per-VM-BO Roger He
  2017-12-13  9:58   ` [PATCH 1/3] drm/ttm: add allow_reserved_eviction and resv into ttm_operation_ctx Christian König
  2 siblings, 2 replies; 7+ messages in thread
From: Roger He @ 2017-12-13  5:17 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Roger He, Christian.Koenig-5C7GfCeVMHo

Change-Id: I0c6571c2a64e6c5bdad80ccbcccb40eba1c20b4e
Signed-off-by: Roger He <Hongbo.He@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index dc0a8be..7c7f56f5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -327,7 +327,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
 			       uint64_t init_value,
 			       struct amdgpu_bo **bo_ptr)
 {
-	struct ttm_operation_ctx ctx = { !kernel, false };
+	struct ttm_operation_ctx ctx = { !kernel, false, true, resv };
 	struct amdgpu_bo *bo;
 	enum ttm_bo_type type;
 	unsigned long page_align;
-- 
2.7.4

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

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

* [PATCH 3/3] drm/ttm: enable eviction for Per-VM-BO
       [not found] ` <1513142278-4294-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
  2017-12-13  5:17   ` [PATCH 2/3] drm/amd/amdgpu: init allow_reserved_eviction and resv when create a new bo Roger He
@ 2017-12-13  5:17   ` Roger He
       [not found]     ` <1513142278-4294-3-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
  2017-12-13  9:58   ` [PATCH 1/3] drm/ttm: add allow_reserved_eviction and resv into ttm_operation_ctx Christian König
  2 siblings, 1 reply; 7+ messages in thread
From: Roger He @ 2017-12-13  5:17 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Roger He, Christian.Koenig-5C7GfCeVMHo

Change-Id: I0c6ece0decd18d30ccc94e5c7ca106d351941c62
Signed-off-by: Roger He <Hongbo.He@amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 098b22e..e7438b0 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -707,7 +707,6 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
 EXPORT_SYMBOL(ttm_bo_eviction_valuable);
 
 static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
-			       struct reservation_object *resv,
 			       uint32_t mem_type,
 			       const struct ttm_place *place,
 			       struct ttm_operation_ctx *ctx)
@@ -722,10 +721,8 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
 	spin_lock(&glob->lru_lock);
 	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
 		list_for_each_entry(bo, &man->lru[i], lru) {
-			if (bo->resv == resv) {
-				if (list_empty(&bo->ddestroy))
-					continue;
-			} else {
+			if (!ctx->allow_reserved_eviction ||
+				bo->resv != ctx->resv) {
 				locked = reservation_object_trylock(bo->resv);
 				if (!locked)
 					continue;
@@ -835,7 +832,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
 			return ret;
 		if (mem->mm_node)
 			break;
-		ret = ttm_mem_evict_first(bdev, bo->resv, mem_type, place, ctx);
+		ret = ttm_mem_evict_first(bdev, mem_type, place, ctx);
 		if (unlikely(ret != 0))
 			return ret;
 	} while (1);
@@ -1332,8 +1329,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
 	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
 		while (!list_empty(&man->lru[i])) {
 			spin_unlock(&glob->lru_lock);
-			ret = ttm_mem_evict_first(bdev, NULL, mem_type,
-						  NULL, &ctx);
+			ret = ttm_mem_evict_first(bdev, mem_type, NULL, &ctx);
 			if (ret)
 				return ret;
 			spin_lock(&glob->lru_lock);
-- 
2.7.4

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

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

* Re: [PATCH 3/3] drm/ttm: enable eviction for Per-VM-BO
       [not found]     ` <1513142278-4294-3-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
@ 2017-12-13  9:54       ` Christian König
  0 siblings, 0 replies; 7+ messages in thread
From: Christian König @ 2017-12-13  9:54 UTC (permalink / raw)
  To: Roger He, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Am 13.12.2017 um 06:17 schrieb Roger He:
> Change-Id: I0c6ece0decd18d30ccc94e5c7ca106d351941c62
> Signed-off-by: Roger He <Hongbo.He@amd.com>
> ---
>   drivers/gpu/drm/ttm/ttm_bo.c | 12 ++++--------
>   1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 098b22e..e7438b0 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -707,7 +707,6 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
>   EXPORT_SYMBOL(ttm_bo_eviction_valuable);
>   
>   static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
> -			       struct reservation_object *resv,
>   			       uint32_t mem_type,
>   			       const struct ttm_place *place,
>   			       struct ttm_operation_ctx *ctx)
> @@ -722,10 +721,8 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
>   	spin_lock(&glob->lru_lock);
>   	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
>   		list_for_each_entry(bo, &man->lru[i], lru) {
> -			if (bo->resv == resv) {
> -				if (list_empty(&bo->ddestroy))
> -					continue;
> -			} else {
> +			if (!ctx->allow_reserved_eviction ||
> +				bo->resv != ctx->resv) {

That will still disable destroyed BO handling during command submission 
which isn't a good idea I think.

Apart from that the "bo->resv != ctx->resv" is still indented to far to 
the right. This makes it look like it belongs to the "locked = ..." on 
the line below.

Christian.

>   				locked = reservation_object_trylock(bo->resv);
>   				if (!locked)
>   					continue;
> @@ -835,7 +832,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
>   			return ret;
>   		if (mem->mm_node)
>   			break;
> -		ret = ttm_mem_evict_first(bdev, bo->resv, mem_type, place, ctx);
> +		ret = ttm_mem_evict_first(bdev, mem_type, place, ctx);
>   		if (unlikely(ret != 0))
>   			return ret;
>   	} while (1);
> @@ -1332,8 +1329,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
>   	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
>   		while (!list_empty(&man->lru[i])) {
>   			spin_unlock(&glob->lru_lock);
> -			ret = ttm_mem_evict_first(bdev, NULL, mem_type,
> -						  NULL, &ctx);
> +			ret = ttm_mem_evict_first(bdev, mem_type, NULL, &ctx);
>   			if (ret)
>   				return ret;
>   			spin_lock(&glob->lru_lock);

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

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

* Re: [PATCH 1/3] drm/ttm: add allow_reserved_eviction and resv into ttm_operation_ctx
       [not found] ` <1513142278-4294-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
  2017-12-13  5:17   ` [PATCH 2/3] drm/amd/amdgpu: init allow_reserved_eviction and resv when create a new bo Roger He
  2017-12-13  5:17   ` [PATCH 3/3] drm/ttm: enable eviction for Per-VM-BO Roger He
@ 2017-12-13  9:58   ` Christian König
  2 siblings, 0 replies; 7+ messages in thread
From: Christian König @ 2017-12-13  9:58 UTC (permalink / raw)
  To: Roger He, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Am 13.12.2017 um 06:17 schrieb Roger He:
> allow_reserved_eviction: Allow eviction of reserved BOs
> resv: Reservation object to allow reserved evictions with
>
> Change-Id: I01ea482e8c7470014196eb218e2ff8913306eef0
> Signed-off-by: Roger He <Hongbo.He@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   include/drm/ttm/ttm_bo_api.h | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
> index 368eb02..c126330 100644
> --- a/include/drm/ttm/ttm_bo_api.h
> +++ b/include/drm/ttm/ttm_bo_api.h
> @@ -263,6 +263,8 @@ struct ttm_bo_kmap_obj {
>    *
>    * @interruptible: Sleep interruptible if sleeping.
>    * @no_wait_gpu: Return immediately if the GPU is busy.
> + * @allow_reserved_eviction: Allow eviction of reserved BOs.
> + * @resv: Reservation object to allow reserved evictions with.
>    *
>    * Context for TTM operations like changing buffer placement or general memory
>    * allocation.
> @@ -270,6 +272,8 @@ struct ttm_bo_kmap_obj {
>   struct ttm_operation_ctx {
>   	bool interruptible;
>   	bool no_wait_gpu;
> +	bool allow_reserved_eviction;
> +	struct reservation_object *resv;
>   	uint64_t bytes_moved;
>   };
>   

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

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

* Re: [PATCH 2/3] drm/amd/amdgpu: init allow_reserved_eviction and resv when create a new bo
       [not found]     ` <1513142278-4294-2-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
@ 2017-12-13 10:00       ` Christian König
  0 siblings, 0 replies; 7+ messages in thread
From: Christian König @ 2017-12-13 10:00 UTC (permalink / raw)
  To: Roger He, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Am 13.12.2017 um 06:17 schrieb Roger He:
> Change-Id: I0c6571c2a64e6c5bdad80ccbcccb40eba1c20b4e
> Signed-off-by: Roger He <Hongbo.He@amd.com>

We should supply the resv object in amdgpu_cs_bo_validate() as well, or 
otherwise the deleted object handling won't work as desired any more.

Apart from that looks good to me.

Christian.

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index dc0a8be..7c7f56f5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -327,7 +327,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
>   			       uint64_t init_value,
>   			       struct amdgpu_bo **bo_ptr)
>   {
> -	struct ttm_operation_ctx ctx = { !kernel, false };
> +	struct ttm_operation_ctx ctx = { !kernel, false, true, resv };
>   	struct amdgpu_bo *bo;
>   	enum ttm_bo_type type;
>   	unsigned long page_align;

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

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

* Re: [PATCH 2/3] drm/amd/amdgpu: init allow_reserved_eviction and resv when create a new bo
  2017-12-13  5:17   ` [PATCH 2/3] drm/amd/amdgpu: init allow_reserved_eviction and resv when create a new bo Roger He
       [not found]     ` <1513142278-4294-2-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
@ 2017-12-13 10:03     ` Michel Dänzer
  1 sibling, 0 replies; 7+ messages in thread
From: Michel Dänzer @ 2017-12-13 10:03 UTC (permalink / raw)
  To: Roger He; +Cc: dri-devel, amd-gfx, Christian.Koenig

On 2017-12-13 06:17 AM, Roger He wrote:
> Change-Id: I0c6571c2a64e6c5bdad80ccbcccb40eba1c20b4e
> Signed-off-by: Roger He <Hongbo.He@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index dc0a8be..7c7f56f5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -327,7 +327,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
>  			       uint64_t init_value,
>  			       struct amdgpu_bo **bo_ptr)
>  {
> -	struct ttm_operation_ctx ctx = { !kernel, false };
> +	struct ttm_operation_ctx ctx = { !kernel, false, true, resv };

Please use named initializers, to make it easier to understand which
field is initialized to which value.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2017-12-13 10:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-13  5:17 [PATCH 1/3] drm/ttm: add allow_reserved_eviction and resv into ttm_operation_ctx Roger He
     [not found] ` <1513142278-4294-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-12-13  5:17   ` [PATCH 2/3] drm/amd/amdgpu: init allow_reserved_eviction and resv when create a new bo Roger He
     [not found]     ` <1513142278-4294-2-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-12-13 10:00       ` Christian König
2017-12-13 10:03     ` Michel Dänzer
2017-12-13  5:17   ` [PATCH 3/3] drm/ttm: enable eviction for Per-VM-BO Roger He
     [not found]     ` <1513142278-4294-3-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-12-13  9:54       ` Christian König
2017-12-13  9:58   ` [PATCH 1/3] drm/ttm: add allow_reserved_eviction and resv into ttm_operation_ctx Christian König

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.