Skip to contentSkip to conversation

drm/ttm: add TTM_PL_FLAG_TEMPORARY flag v3

PATCH In review Christian König 4 participants 12 messages Jun 1, 2021 – Jun 7, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 drm/ttm: add TTM_PL_FLAG_TEMPORARY flag v3

From: Lang Yu <[email protected]>

Sometimes drivers need to use bounce buffers to evict BOs. While those reside in some domain they are not necessarily suitable for CS.

Add a flag so that drivers can note that a bounce buffers needs to be reallocated during validation.

v2: add detailed comments
v3 (chk): merge commits and rework commit message

---
 drivers/gpu/drm/ttm/ttm_bo.c    | 3 +++
 include/drm/ttm/ttm_placement.h | 7 +++++--
 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +3 -0
index 51a94fd63bd7..6b393502198e 100644
@@ -929,6 +929,9 @@ static bool ttm_bo_places_compat(const struct ttm_place *places,
 {
 	unsigned i;
 
+	if (mem->placement & TTM_PL_FLAG_TEMPORARY)
+		return false;
+
 	for (i = 0; i < num_placement; i++) {
 		const struct ttm_place *heap = &places[i];
 
include/drm/ttm/ttm_placement.h +5 -2
index aa6ba4d0cf78..8995c9e4ec1b 100644
@@ -47,8 +47,11 @@
  * top of the memory area, instead of the bottom.
  */
 
-#define TTM_PL_FLAG_CONTIGUOUS  (1 << 19)
-#define TTM_PL_FLAG_TOPDOWN     (1 << 22)
+#define TTM_PL_FLAG_CONTIGUOUS  (1 << 0)
+#define TTM_PL_FLAG_TOPDOWN     (1 << 1)
+
+/* For multihop handling */
+#define TTM_PL_FLAG_TEMPORARY   (1 << 2)
 
 /**
  * struct ttm_place
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/4 drm/amdgpu: user temporary GTT as bounce buffer

From: Lang Yu <[email protected]>

Currently, we have a limitted GTT memory size and need a bounce buffer when doing buffer migration between VRAM and SYSTEM domain.

The problem is under GTT memory pressure we can't do buffer migration between VRAM and SYSTEM domain. But in some cases we really need that. Eespecially when validating a VRAM backing store BO which resides in SYSTEM domain.

v2: still account temporary GTT allocations
v3 (chk): revert to the simpler change for now

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 19 +++++++++++--------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     |  2 +-
 2 files changed, 12 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +11 -8
index 6a84c9778cc0..5e6b76441449 100644
@@ -121,14 +121,15 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
 	struct amdgpu_gtt_node *node;
 	int r;
 
-	spin_lock(&mgr->lock);
-	if ((&tbo->mem == mem || tbo->mem.mem_type != TTM_PL_TT) &&
-	    atomic64_read(&mgr->available) < mem->num_pages) {
+	if (!(place->flags & TTM_PL_FLAG_TEMPORARY)) {
+		spin_lock(&mgr->lock);
+		if (atomic64_read(&mgr->available) < mem->num_pages) {
+			spin_unlock(&mgr->lock);
+			return -ENOSPC;
+		}
+		atomic64_sub(mem->num_pages, &mgr->available);
 		spin_unlock(&mgr->lock);
-		return -ENOSPC;
 	}
-	atomic64_sub(mem->num_pages, &mgr->available);
-	spin_unlock(&mgr->lock);
 
 	if (!place->lpfn) {
 		mem->mm_node = NULL;
@@ -162,7 +163,8 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
 	kfree(node);
 
 err_out:
-	atomic64_add(mem->num_pages, &mgr->available);
+	if (!(place->flags & TTM_PL_FLAG_TEMPORARY))
+		atomic64_add(mem->num_pages, &mgr->available);
 
 	return r;
 }
@@ -188,7 +190,8 @@ static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
 		kfree(node);
 	}
 
-	atomic64_add(mem->num_pages, &mgr->available);
+	if (!(mem->placement & TTM_PL_FLAG_TEMPORARY))
+		atomic64_add(mem->num_pages, &mgr->available);
 }
 
 /**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
index 80437b6ba5f3..6bdff9005a47 100644
@@ -514,7 +514,7 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
 			hop->fpfn = 0;
 			hop->lpfn = 0;
 			hop->mem_type = TTM_PL_TT;
-			hop->flags = 0;
+			hop->flags = TTM_PL_FLAG_TEMPORARY;
 			return -EMULTIHOP;
 		}
 
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/4 drm/amdgpu: always allow evicting to SYSTEM domain

In reply to Christian König

When we run out of GTT we should still be able to evict VRAM->SYSTEM with a bounce bufferdrm/amdgpu: always allow evicting to SYSTEM domain

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -2
index 6bdff9005a47..0faf9765ef41 100644
@@ -147,14 +147,16 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,
 			 * BOs to be evicted from VRAM
 			 */
 			amdgpu_bo_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM |
-							 AMDGPU_GEM_DOMAIN_GTT);
+							AMDGPU_GEM_DOMAIN_GTT |
+							AMDGPU_GEM_DOMAIN_CPU);
 			abo->placements[0].fpfn = adev->gmc.visible_vram_size >> PAGE_SHIFT;
 			abo->placements[0].lpfn = 0;
 			abo->placement.busy_placement = &abo->placements[1];
 			abo->placement.num_busy_placement = 1;
 		} else {
 			/* Move to GTT memory */
-			amdgpu_bo_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT);
+			amdgpu_bo_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT |
+							AMDGPU_GEM_DOMAIN_CPU);
 		}
 		break;
 	case TTM_PL_TT:
Signature · 1 line
2.25.1
#3 lore raw

RE: [PATCH 3/4] drm/amdgpu: always allow evicting to SYSTEM domain

Quoted 47 lines

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, June 1, 2021 8:25 PM
To: Yu, Lang <[email protected]>; [email protected]
Cc: [email protected]
Subject: [PATCH 3/4] drm/amdgpu: always allow evicting to SYSTEM domain

When we run out of GTT we should still be able to evict VRAM->SYSTEM with a bounce bufferdrm/amdgpu: always allow evicting to SYSTEM domain

---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 ++++--

1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
index 6bdff9005a47..0faf9765ef41 100644
@@ -147,14 +147,16 @@ static void amdgpu_evict_flags(struct
 ttm_buffer_object *bo,
 			 * BOs to be evicted from VRAM
 			 */
 			amdgpu_bo_placement_from_domain(abo,

AMDGPU_GEM_DOMAIN_VRAM |
-
AMDGPU_GEM_DOMAIN_GTT);
+
AMDGPU_GEM_DOMAIN_GTT |
+

	AMDGPU_GEM_DOMAIN_CPU);
			abo->placements[0].fpfn = adev-
Quoted 1 line

gmc.visible_vram_size >> PAGE_SHIFT;

			abo->placements[0].lpfn = 0;
			abo->placement.busy_placement = &abo-
Quoted 1 line

placements[1];

			abo->placement.num_busy_placement = 1;
		} else {
			/* Move to GTT memory */
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
-			amdgpu_bo_placement_from_domain(abo,

AMDGPU_GEM_DOMAIN_GTT);

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -0
+			amdgpu_bo_placement_from_domain(abo,

AMDGPU_GEM_DOMAIN_GTT |
+

Quoted 6 lines
	AMDGPU_GEM_DOMAIN_CPU);
		}
		break;
	case TTM_PL_TT:

--
2.25.1

[Yu, Lang]
Yeah, that's it.

#4 lore raw

PATCH 4/4 drm/amdgpu: switch gtt_mgr to counting used pages

In reply to Christian König

From: Lang Yu <[email protected]>

Change mgr->available into mgr->used (invert the value).

Makes more sense to do it this way since we don't need the spinlock any more to double check the handling.

v3 (chk): separated from the TEMPOARAY FLAG change.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 26 ++++++++-------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  2 +-
 2 files changed, 11 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +10 -16
index 5e6b76441449..4d7e34a8d3fd 100644
@@ -121,14 +121,10 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
 	struct amdgpu_gtt_node *node;
 	int r;
 
-	if (!(place->flags & TTM_PL_FLAG_TEMPORARY)) {
-		spin_lock(&mgr->lock);
-		if (atomic64_read(&mgr->available) < mem->num_pages) {
-			spin_unlock(&mgr->lock);
-			return -ENOSPC;
-		}
-		atomic64_sub(mem->num_pages, &mgr->available);
-		spin_unlock(&mgr->lock);
+	if (!(place->flags & TTM_PL_FLAG_TEMPORARY) &&
+	    atomic64_add_return(mem->num_pages, &mgr->used) >  man->size) {
+		atomic64_sub(mem->num_pages, &mgr->used);
+		return -ENOSPC;
 	}
 
 	if (!place->lpfn) {
@@ -164,7 +160,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
 
 err_out:
 	if (!(place->flags & TTM_PL_FLAG_TEMPORARY))
-		atomic64_add(mem->num_pages, &mgr->available);
+		atomic64_sub(mem->num_pages, &mgr->used);
 
 	return r;
 }
@@ -191,7 +187,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
 	}
 
 	if (!(mem->placement & TTM_PL_FLAG_TEMPORARY))
-		atomic64_add(mem->num_pages, &mgr->available);
+		atomic64_sub(mem->num_pages, &mgr->used);
 }
 
 /**
@@ -204,9 +200,8 @@ static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
 uint64_t amdgpu_gtt_mgr_usage(struct ttm_resource_manager *man)
 {
 	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
-	s64 result = man->size - atomic64_read(&mgr->available);
 
-	return (result > 0 ? result : 0) * PAGE_SIZE;
+	return atomic64_read(&mgr->used) * PAGE_SIZE;
 }
 
 /**
@@ -252,9 +247,8 @@ static void amdgpu_gtt_mgr_debug(struct ttm_resource_manager *man,
 	drm_mm_print(&mgr->mm, printer);
 	spin_unlock(&mgr->lock);
 
-	drm_printf(printer, "man size:%llu pages, gtt available:%lld pages, usage:%lluMB\n",
-		   man->size, (u64)atomic64_read(&mgr->available),
-		   amdgpu_gtt_mgr_usage(man) >> 20);
+	drm_printf(printer, "man size:%llu pages,  gtt used:%llu pages\n",
+		   man->size, atomic64_read(&mgr->used));
 }
 
 static const struct ttm_resource_manager_func amdgpu_gtt_mgr_func = {
@@ -286,7 +280,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
 	size = (adev->gmc.gart_size >> PAGE_SHIFT) - start;
 	drm_mm_init(&mgr->mm, start, size);
 	spin_lock_init(&mgr->lock);
-	atomic64_set(&mgr->available, gtt_size >> PAGE_SHIFT);
+	atomic64_set(&mgr->used, 0);
 
 	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, &mgr->manager);
 	ttm_resource_manager_set_used(man, true);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -1
index b2c97b19cbe1..64a78da33805 100644
@@ -51,7 +51,7 @@ struct amdgpu_gtt_mgr {
 	struct ttm_resource_manager manager;
 	struct drm_mm mm;
 	spinlock_t lock;
-	atomic64_t available;
+	atomic64_t used;
 };
 
 struct amdgpu_mman {
Signature · 1 line
2.25.1
#5 lore raw
In reply to Christian König

Thomas any comments on this?

Is the purpose of this now clear enough?

Thanks,
Christian.

Am 01.06.21 um 14:25 schrieb Christian König:

Quoted 51 lines

From: Lang Yu <[email protected]>

Sometimes drivers need to use bounce buffers to evict BOs. While those reside in some domain they are not necessarily suitable for CS.

Add a flag so that drivers can note that a bounce buffers needs to be reallocated during validation.

v2: add detailed comments
v3 (chk): merge commits and rework commit message

---
  drivers/gpu/drm/ttm/ttm_bo.c    | 3 +++
  include/drm/ttm/ttm_placement.h | 7 +++++--
  2 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +3 -0
index 51a94fd63bd7..6b393502198e 100644
@@ -929,6 +929,9 @@ static bool ttm_bo_places_compat(const struct ttm_place *places,
  {
  	unsigned i;
 
+	if (mem->placement & TTM_PL_FLAG_TEMPORARY)
+		return false;
+
  	for (i = 0; i < num_placement; i++) {
  		const struct ttm_place *heap = &places[i];
 
include/drm/ttm/ttm_placement.h +5 -2
index aa6ba4d0cf78..8995c9e4ec1b 100644
@@ -47,8 +47,11 @@
   * top of the memory area, instead of the bottom.
   */
 
-#define TTM_PL_FLAG_CONTIGUOUS  (1 << 19)
-#define TTM_PL_FLAG_TOPDOWN     (1 << 22)
+#define TTM_PL_FLAG_CONTIGUOUS  (1 << 0)
+#define TTM_PL_FLAG_TOPDOWN     (1 << 1)
+
+/* For multihop handling */
+#define TTM_PL_FLAG_TEMPORARY   (1 << 2)
 
  /**
   * struct ttm_place
Reviewed-by Thomas Hellström
#6 lore raw

Sure. LGTM,

Quoted 56 lines · Christian König

Thomas any comments on this?

Is the purpose of this now clear enough?

Thanks,
Christian.

Am 01.06.21 um 14:25 schrieb Christian König:

Quoted 48 lines

From: Lang Yu <[email protected]>

Sometimes drivers need to use bounce buffers to evict BOs. While those reside in some domain they are not necessarily suitable for CS.

Add a flag so that drivers can note that a bounce buffers needs to be reallocated during validation.

v2: add detailed comments
v3 (chk): merge commits and rework commit message

---
  drivers/gpu/drm/ttm/ttm_bo.c    | 3 +++
  include/drm/ttm/ttm_placement.h | 7 +++++--

  2 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +2 -0
index 51a94fd63bd7..6b393502198e 100644
@@ -929,6 +929,9 @@ static bool ttm_bo_places_compat(const struct 
 ttm_place *places,
   {
       unsigned i;
   +    if (mem->placement & TTM_PL_FLAG_TEMPORARY)
+        return false;
+
       for (i = 0; i < num_placement; i++) {
           const struct ttm_place *heap = &places[i];

  diff --git a/include/drm/ttm/ttm_placement.h b/include/drm/ttm/ttm_placement.h index aa6ba4d0cf78..8995c9e4ec1b 100644

include/drm/ttm/ttm_placement.h +5 -1
@@ -47,8 +47,11 @@
    * top of the memory area, instead of the bottom.
    */
   -#define TTM_PL_FLAG_CONTIGUOUS  (1 << 19)
-#define TTM_PL_FLAG_TOPDOWN     (1 << 22)
+#define TTM_PL_FLAG_CONTIGUOUS  (1 << 0)
+#define TTM_PL_FLAG_TOPDOWN     (1 << 1)
+
+/* For multihop handling */
+#define TTM_PL_FLAG_TEMPORARY   (1 << 2)
     /**
    * struct ttm_place
#7 lore raw

Thanks!

Lang can anybody from your team give as an reviewed-by/test-by on the amdgpu patches? I just want another pair of eyes looking over it.

If nobody else has time I will ask Nirmoy for a quick testing round.

Thanks,
Christian.

Am 07.06.21 um 14:38 schrieb Thomas Hellström (Intel):

Quoted 62 lines

Sure. LGTM,

Quoted 56 lines · Christian König

Thomas any comments on this?

Is the purpose of this now clear enough?

Thanks,
Christian.

Am 01.06.21 um 14:25 schrieb Christian König:

Quoted 48 lines

From: Lang Yu <[email protected]>

Sometimes drivers need to use bounce buffers to evict BOs. While those reside in some domain they are not necessarily suitable for CS.

Add a flag so that drivers can note that a bounce buffers needs to be reallocated during validation.

v2: add detailed comments
v3 (chk): merge commits and rework commit message

---
  drivers/gpu/drm/ttm/ttm_bo.c    | 3 +++
  include/drm/ttm/ttm_placement.h | 7 +++++--

  2 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +2 -0
index 51a94fd63bd7..6b393502198e 100644
@@ -929,6 +929,9 @@ static bool ttm_bo_places_compat(const struct 
 ttm_place *places,
   {
       unsigned i;
   +    if (mem->placement & TTM_PL_FLAG_TEMPORARY)
+        return false;
+
       for (i = 0; i < num_placement; i++) {
           const struct ttm_place *heap = &places[i];

  diff --git a/include/drm/ttm/ttm_placement.h b/include/drm/ttm/ttm_placement.h index aa6ba4d0cf78..8995c9e4ec1b 100644

include/drm/ttm/ttm_placement.h +5 -1
@@ -47,8 +47,11 @@
    * top of the memory area, instead of the bottom.
    */
   -#define TTM_PL_FLAG_CONTIGUOUS  (1 << 19)
-#define TTM_PL_FLAG_TOPDOWN     (1 << 22)
+#define TTM_PL_FLAG_CONTIGUOUS  (1 << 0)
+#define TTM_PL_FLAG_TOPDOWN     (1 << 1)
+
+/* For multihop handling */
+#define TTM_PL_FLAG_TEMPORARY   (1 << 2)
     /**
    * struct ttm_place
#8 lore raw

[AMD Official Use Only]

Thanks,please let Nirmoy do it.

Regards,
Lang

获取 Outlook for iOS<https://aka.ms/o0ukef>
________________________________
发件人: Christian König <[email protected]>
发送时间: Monday, June 7, 2021 8:41:49 PM
收件人: Thomas Hellström (Intel) <[email protected]>; Yu, Lang <[email protected]> 抄送: [email protected] <[email protected]> 主题: Re: [PATCH 1/4] drm/ttm: add TTM_PL_FLAG_TEMPORARY flag v3

Thanks!

Lang can anybody from your team give as an reviewed-by/test-by on the amdgpu patches? I just want another pair of eyes looking over it.

If nobody else has time I will ask Nirmoy for a quick testing round.

Thanks,
Christian.

Am 07.06.21 um 14:38 schrieb Thomas Hellström (Intel):

Quoted 65 lines

Sure. LGTM,

Quoted 59 lines · Christian König

Thomas any comments on this?

Is the purpose of this now clear enough?

Thanks,
Christian.

Am 01.06.21 um 14:25 schrieb Christian König:

Quoted 51 lines

From: Lang Yu <[email protected]>

Sometimes drivers need to use bounce buffers to evict BOs. While those reside
in some domain they are not necessarily suitable for CS.

Add a flag so that drivers can note that a bounce buffers needs to be reallocated during validation.

v2: add detailed comments
v3 (chk): merge commits and rework commit message

---
  drivers/gpu/drm/ttm/ttm_bo.c    | 3 +++
  include/drm/ttm/ttm_placement.h | 7 +++++--
  2 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +2 -0
index 51a94fd63bd7..6b393502198e 100644
@@ -929,6 +929,9 @@ static bool ttm_bo_places_compat(const struct
 ttm_place *places,
  {
      unsigned i;
  +    if (mem->placement & TTM_PL_FLAG_TEMPORARY)
+        return false;
+
      for (i = 0; i < num_placement; i++) {
          const struct ttm_place *heap = &places[i];
  diff --git a/include/drm/ttm/ttm_placement.h

b/include/drm/ttm/ttm_placement.h
index aa6ba4d0cf78..8995c9e4ec1b 100644

include/drm/ttm/ttm_placement.h +5 -1
@@ -47,8 +47,11 @@
   * top of the memory area, instead of the bottom.
   */
  -#define TTM_PL_FLAG_CONTIGUOUS  (1 << 19)
-#define TTM_PL_FLAG_TOPDOWN     (1 << 22)
+#define TTM_PL_FLAG_CONTIGUOUS  (1 << 0)
+#define TTM_PL_FLAG_TOPDOWN     (1 << 1)
+
+/* For multihop handling */
+#define TTM_PL_FLAG_TEMPORARY   (1 << 2)
    /**
   * struct ttm_place
#9 lore raw

Hi Nirmoy,

can you give that patch set a testing round and an review?

The memory stress test with low VRAM on APUs should be sufficient and you should have that setup still around.

Thanks in advance,
Christian.

Am 07.06.21 um 14:58 schrieb Yu, Lang:

Quoted 93 lines

[AMD Official Use Only]

Thanks,please let Nirmoy do it.

Regards,
Lang

获取 Outlook for iOS <https://aka.ms/o0ukef>
------------------------------------------------------------------------
*发件人:* Christian König <[email protected]>
*发送时间:* Monday, June 7, 2021 8:41:49 PM
*收件人:* Thomas Hellström (Intel) <[email protected]>; Yu, Lang <[email protected]> *抄送:* [email protected] <[email protected]> *主题:* Re: [PATCH 1/4] drm/ttm: add TTM_PL_FLAG_TEMPORARY flag v3 Thanks!

Lang can anybody from your team give as an reviewed-by/test-by on the amdgpu patches? I just want another pair of eyes looking over it.

If nobody else has time I will ask Nirmoy for a quick testing round.

Thanks,
Christian.

Am 07.06.21 um 14:38 schrieb Thomas Hellström (Intel):

Quoted 65 lines

Sure. LGTM,

Quoted 59 lines · Christian König

Thomas any comments on this?

Is the purpose of this now clear enough?

Thanks,
Christian.

Am 01.06.21 um 14:25 schrieb Christian König:

Quoted 51 lines

From: Lang Yu <[email protected]>

Sometimes drivers need to use bounce buffers to evict BOs. While those reside
in some domain they are not necessarily suitable for CS.

Add a flag so that drivers can note that a bounce buffers needs to be reallocated during validation.

v2: add detailed comments
v3 (chk): merge commits and rework commit message

---
  drivers/gpu/drm/ttm/ttm_bo.c    | 3 +++
  include/drm/ttm/ttm_placement.h | 7 +++++--

  2 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +2 -0
index 51a94fd63bd7..6b393502198e 100644
@@ -929,6 +929,9 @@ static bool ttm_bo_places_compat(const struct
 ttm_place *places,
   {
       unsigned i;
   +    if (mem->placement & TTM_PL_FLAG_TEMPORARY)
+        return false;
+
       for (i = 0; i < num_placement; i++) {
           const struct ttm_place *heap = &places[i];

  diff --git a/include/drm/ttm/ttm_placement.h
b/include/drm/ttm/ttm_placement.h
index aa6ba4d0cf78..8995c9e4ec1b 100644

include/drm/ttm/ttm_placement.h +5 -1
@@ -47,8 +47,11 @@
    * top of the memory area, instead of the bottom.
    */
   -#define TTM_PL_FLAG_CONTIGUOUS  (1 << 19)
-#define TTM_PL_FLAG_TOPDOWN     (1 << 22)
+#define TTM_PL_FLAG_CONTIGUOUS  (1 << 0)
+#define TTM_PL_FLAG_TOPDOWN     (1 << 1)
+
+/* For multihop handling */
+#define TTM_PL_FLAG_TEMPORARY   (1 << 2)
     /**
    * struct ttm_place
#10 lore raw
Quoted 3 lines · Christian König

Hi Nirmoy,

can you give that patch set a testing round and an review?

Sure! I will get back asap.

Quoted 101 lines

The memory stress test with low VRAM on APUs should be sufficient and you should have that setup still around.

Thanks in advance,
Christian.

Am 07.06.21 um 14:58 schrieb Yu, Lang:

Quoted 93 lines

[AMD Official Use Only]

Thanks,please let Nirmoy do it.

Regards,
Lang

获取 Outlook for iOS <https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2Fo0ukef&data=04%7C01%7Cnirmoy.das%40amd.com%7Ca1e4256424cb46841b6b08d929b45120%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637586676695741160%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=m6t3vxIQ%2BgRQJvI27G9gHtR2XN7Hoyg6WXkG6uDRTbc%3D&reserved=0>
------------------------------------------------------------------------
*发件人:* Christian König <[email protected]>
*发送时间:* Monday, June 7, 2021 8:41:49 PM
*收件人:* Thomas Hellström (Intel) <[email protected]>; Yu, Lang <[email protected]>
*抄送:* [email protected] <[email protected]>
*主题:* Re: [PATCH 1/4] drm/ttm: add TTM_PL_FLAG_TEMPORARY flag v3
Thanks!

Lang can anybody from your team give as an reviewed-by/test-by on the amdgpu patches? I just want another pair of eyes looking over it.

If nobody else has time I will ask Nirmoy for a quick testing round.

Thanks,
Christian.

Am 07.06.21 um 14:38 schrieb Thomas Hellström (Intel):

Quoted 65 lines

Sure. LGTM,

Quoted 59 lines · Christian König

Thomas any comments on this?

Is the purpose of this now clear enough?

Thanks,
Christian.

Am 01.06.21 um 14:25 schrieb Christian König:

Quoted 51 lines

From: Lang Yu <[email protected]>

Sometimes drivers need to use bounce buffers to evict BOs. While those reside
in some domain they are not necessarily suitable for CS.

Add a flag so that drivers can note that a bounce buffers needs to be reallocated during validation.

v2: add detailed comments
v3 (chk): merge commits and rework commit message

---
  drivers/gpu/drm/ttm/ttm_bo.c    | 3 +++
  include/drm/ttm/ttm_placement.h | 7 +++++--

  2 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +2 -0
index 51a94fd63bd7..6b393502198e 100644
@@ -929,6 +929,9 @@ static bool ttm_bo_places_compat(const struct
 ttm_place *places,
   {
       unsigned i;
   +    if (mem->placement & TTM_PL_FLAG_TEMPORARY)
+        return false;
+
       for (i = 0; i < num_placement; i++) {
           const struct ttm_place *heap = &places[i];

  diff --git a/include/drm/ttm/ttm_placement.h
b/include/drm/ttm/ttm_placement.h
index aa6ba4d0cf78..8995c9e4ec1b 100644

include/drm/ttm/ttm_placement.h +5 -1
@@ -47,8 +47,11 @@
    * top of the memory area, instead of the bottom.
    */
   -#define TTM_PL_FLAG_CONTIGUOUS  (1 << 19)
-#define TTM_PL_FLAG_TOPDOWN     (1 << 22)
+#define TTM_PL_FLAG_CONTIGUOUS  (1 << 0)
+#define TTM_PL_FLAG_TOPDOWN     (1 << 1)
+
+/* For multihop handling */
+#define TTM_PL_FLAG_TEMPORARY   (1 << 2)
     /**
    * struct ttm_place
#11 lore raw

Hi Christian and Lang,

I can't apply it cleanly because of https://patchwork.freedesktop.org/patch/436305/. This series needs a rebase.

Regards,

Nirmoy

Quoted 112 lines · Nirmoy
Quoted 3 lines · Christian König

Hi Nirmoy,

can you give that patch set a testing round and an review?

Sure! I will get back asap.

Quoted 102 lines

The memory stress test with low VRAM on APUs should be sufficient and you should have that setup still around.

Thanks in advance,
Christian.

Am 07.06.21 um 14:58 schrieb Yu, Lang:

Quoted 94 lines

[AMD Official Use Only]

Thanks,please let Nirmoy do it.

Regards,
Lang

获取 Outlook for iOS <https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2Fo0ukef&data=04%7C01%7Cnirmoy.das%40amd.com%7Cd789a01a337743638ed308d929c28fa0%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637586737878220366%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=TkIx1d6hvZtrP6iQihfUlrB6oBP9QZGfNa08anYm4X4%3D&reserved=0>
------------------------------------------------------------------------
*发件人:* Christian König <[email protected]>
*发送时间:* Monday, June 7, 2021 8:41:49 PM
*收件人:* Thomas Hellström (Intel) <[email protected]>; Yu, Lang <[email protected]>
*抄送:* [email protected] <[email protected]>
*主题:* Re: [PATCH 1/4] drm/ttm: add TTM_PL_FLAG_TEMPORARY flag v3
Thanks!

Lang can anybody from your team give as an reviewed-by/test-by on the amdgpu patches? I just want another pair of eyes looking over it.

If nobody else has time I will ask Nirmoy for a quick testing round.

Thanks,
Christian.

Am 07.06.21 um 14:38 schrieb Thomas Hellström (Intel):

Quoted 21 lines

Sure. LGTM,

Quoted 15 lines · Christian König

Thomas any comments on this?

Is the purpose of this now clear enough?

Thanks,
Christian.

Am 01.06.21 um 14:25 schrieb Christian König:

Quoted 7 lines

From: Lang Yu <[email protected]>

Sometimes drivers need to use bounce buffers to evict BOs. While those reside
in some domain they are not necessarily suitable for CS.

Add a flag so that drivers can note that a bounce buffers needs

to be

Quoted 44 lines
Quoted 44 lines
Quoted 44 lines

reallocated during validation.

v2: add detailed comments
v3 (chk): merge commits and rework commit message

---
  drivers/gpu/drm/ttm/ttm_bo.c    | 3 +++
  include/drm/ttm/ttm_placement.h | 7 +++++--

  2 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +2 -0
index 51a94fd63bd7..6b393502198e 100644
@@ -929,6 +929,9 @@ static bool ttm_bo_places_compat(const struct
 ttm_place *places,
   {
       unsigned i;
   +    if (mem->placement & TTM_PL_FLAG_TEMPORARY)
+        return false;
+
       for (i = 0; i < num_placement; i++) {
           const struct ttm_place *heap = &places[i];

  diff --git a/include/drm/ttm/ttm_placement.h
b/include/drm/ttm/ttm_placement.h
index aa6ba4d0cf78..8995c9e4ec1b 100644

include/drm/ttm/ttm_placement.h +5 -1
@@ -47,8 +47,11 @@
    * top of the memory area, instead of the bottom.
    */
   -#define TTM_PL_FLAG_CONTIGUOUS  (1 << 19)
-#define TTM_PL_FLAG_TOPDOWN     (1 << 22)
+#define TTM_PL_FLAG_CONTIGUOUS  (1 << 0)
+#define TTM_PL_FLAG_TOPDOWN     (1 << 1)
+
+/* For multihop handling */
+#define TTM_PL_FLAG_TEMPORARY   (1 << 2)
     /**
    * struct ttm_place