Skip to contentSkip to conversation

drm/ttm: cleanup and add TTM_PL_FLAG_TEMPORARY flag

PATCH In review Lang Yu 3 participants 6 messages May 31, 2021

Subsystems (4)
lore
Share & tools
lore

Lang Yu

author
#0 lore raw

PATCH v2 1/3 drm/ttm: cleanup and add TTM_PL_FLAG_TEMPORARY flag

Cleanup and just make TTM_PL_FLAG_* start from zero.

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.

Add TTM_PL_FLAG_TEMPORARY flag for temporary GTT memory allocation under memory pressure. It may be useful for dirvers with a limited GTT memory size.

v2: add detailed comments

---
 include/drm/ttm/ttm_placement.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
include/drm/ttm/ttm_placement.h +3 -2
index aa6ba4d0cf78..9f5cfc7c2d5a 100644
@@ -47,8 +47,9 @@
  * 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)
+#define TTM_PL_FLAG_TEMPORARY   (1 << 2)
 
 /**
  * struct ttm_place
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 2/3 drm/ttm: check with temporary GTT memory in BO validation

If a BO's backing store is temporary GTT memory, we should move it in BO validation.

---
 drivers/gpu/drm/ttm/ttm_bo.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/ttm/ttm_bo.c +2 -0
index c32a37d0a460..80c8cb2c3f31 100644
@@ -944,6 +944,8 @@ static bool ttm_bo_places_compat(const struct ttm_place *places,
 		if ((mem->start < heap->fpfn ||
 		     (heap->lpfn != 0 && (mem->start + mem->num_pages) > heap->lpfn)))
 			continue;
+		if (mem->placement & TTM_PL_FLAG_TEMPORARY)
+			continue;
 
 		*new_flags = heap->flags;
 		if ((mem->mem_type == heap->mem_type) &&
Signature · 1 line
2.25.1
author
#3 lore raw

PATCH v2 3/3 drm/amdgpu: allow temporary GTT allocation under memory pressure

In reply to Lang Yu

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.

To solve the problem, we allow temporary GTT allocation under memory pressure and do the following:

1. Change mgr->available into mgr->used (invert the value).
2. Always account all GTT BOs to the used space.
3. Only when it is not a temporary allocation bail out.

v2: still account temporary GTT allocations

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 27 ++++++++++-----------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     |  4 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  2 +-
 3 files changed, 17 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +13 -14
index 8860545344c7..393f55f412b7 100644
@@ -111,14 +111,11 @@ 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) {
-		spin_unlock(&mgr->lock);
+	if ((atomic64_add_return(mem->num_pages, &mgr->used) > man->size) &&
+		!(mem->placement & TTM_PL_FLAG_TEMPORARY)) {
+		atomic64_sub(mem->num_pages, &mgr->used);
 		return -ENOSPC;
 	}
-	atomic64_sub(mem->num_pages, &mgr->available);
-	spin_unlock(&mgr->lock);
 
 	if (!place->lpfn) {
 		mem->mm_node = NULL;
@@ -152,7 +149,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
 	kfree(node);
 
 err_out:
-	atomic64_add(mem->num_pages, &mgr->available);
+	atomic64_sub(mem->num_pages, &mgr->used);
 
 	return r;
 }
@@ -178,7 +175,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
 		kfree(node);
 	}
 
-	atomic64_add(mem->num_pages, &mgr->available);
+	atomic64_sub(mem->num_pages, &mgr->used);
 }
 
 /**
@@ -191,9 +188,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;
 }
 
 /**
@@ -234,14 +230,17 @@ static void amdgpu_gtt_mgr_debug(struct ttm_resource_manager *man,
 				 struct drm_printer *printer)
 {
 	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
+	uint64_t used, used_pages;
 
 	spin_lock(&mgr->lock);
 	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);
+	used = amdgpu_gtt_mgr_usage(man);
+	used_pages = used/PAGE_SIZE;
+
+	drm_printf(printer, "man size:%llu pages,  gtt available:%lld pages, usage:%lluMB\n",
+		man->size, used_pages > man->size ? 0 : man->size - used_pages, used >> 20);
 }
 
 static const struct ttm_resource_manager_func amdgpu_gtt_mgr_func = {
@@ -274,7 +273,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);
 
 	ret = device_create_file(adev->dev, &dev_attr_mem_info_gtt_total);
 	if (ret) {
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -1
index c0aef327292a..129d39392859 100644
@@ -152,9 +152,11 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,
 			abo->placements[0].lpfn = 0;
 			abo->placement.busy_placement = &abo->placements[1];
 			abo->placement.num_busy_placement = 1;
+			abo->placements[1].flags |= TTM_PL_FLAG_TEMPORARY;
 		} else {
 			/* Move to GTT memory */
 			amdgpu_bo_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT);
+			abo->placements[0].flags |= TTM_PL_FLAG_TEMPORARY;
 		}
 		break;
 	case TTM_PL_TT:
@@ -538,7 +540,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;
 		}
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -1
index 2877a924086f..26b67af00550 100644
@@ -52,7 +52,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_preempt_mgr {
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#2 lore raw

Re: [PATCH 2/3] drm/ttm: check with temporary GTT memory in BO validation

In reply to Lang Yu

Am 31.05.21 um 10:22 schrieb Lang Yu:

Quoted 13 lines

If a BO's backing store is temporary GTT memory, we should move it in BO validation.

---
  drivers/gpu/drm/ttm/ttm_bo.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/gpu/drm/ttm/ttm_bo.c +0 -0
index c32a37d0a460..80c8cb2c3f31 100644

drivers/gpu/drm/ttm/ttm_bo.c static bool ttm_bo_places_compat(const struct ttm_place *places, · line 948

Quoted 5 lines
drivers/gpu/drm/ttm/ttm_bo.c +2 -0
@@ -944,6 +944,8 @@ static bool ttm_bo_places_compat(const struct ttm_place *places,
  		if ((mem->start < heap->fpfn ||
  		     (heap->lpfn != 0 && (mem->start + mem->num_pages) > heap->lpfn)))
  			continue;
+		if (mem->placement & TTM_PL_FLAG_TEMPORARY)
+			continue;

Oh, good idea. But please move the check outside of the loop since mem never changes here we can return false right away.

Thanks,
Christian.

Quoted 3 lines
drivers/gpu/drm/ttm/ttm_bo.c +0 -0
  		*new_flags = heap->flags;
  		if ((mem->mem_type == heap->mem_type) &&
maintainer
#4 lore raw

Re: [PATCH v2 3/3] drm/amdgpu: allow temporary GTT allocation under memory pressure

In reply to Lang Yu

On which branch are you working? I have problems applying that one to amd-staging-drm-next.

Christian.

Am 31.05.21 um 10:22 schrieb Lang Yu:

Quoted 135 lines

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.

To solve the problem, we allow temporary GTT allocation under memory pressure and do the following:

1. Change mgr->available into mgr->used (invert the value).
2. Always account all GTT BOs to the used space.
3. Only when it is not a temporary allocation bail out.

v2: still account temporary GTT allocations

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 27 ++++++++++-----------
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     |  4 ++-
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  2 +-
  3 files changed, 17 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +13 -14
index 8860545344c7..393f55f412b7 100644
@@ -111,14 +111,11 @@ 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) {
-		spin_unlock(&mgr->lock);
+	if ((atomic64_add_return(mem->num_pages, &mgr->used) > man->size) &&
+		!(mem->placement & TTM_PL_FLAG_TEMPORARY)) {
+		atomic64_sub(mem->num_pages, &mgr->used);
  		return -ENOSPC;
  	}
-	atomic64_sub(mem->num_pages, &mgr->available);
-	spin_unlock(&mgr->lock);
 
  	if (!place->lpfn) {
  		mem->mm_node = NULL;
@@ -152,7 +149,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
  	kfree(node);
 
  err_out:
-	atomic64_add(mem->num_pages, &mgr->available);
+	atomic64_sub(mem->num_pages, &mgr->used);
 
  	return r;
  }
@@ -178,7 +175,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
  		kfree(node);
  	}
 
-	atomic64_add(mem->num_pages, &mgr->available);
+	atomic64_sub(mem->num_pages, &mgr->used);
  }
 
  /**
@@ -191,9 +188,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;
  }
 
  /**
@@ -234,14 +230,17 @@ static void amdgpu_gtt_mgr_debug(struct ttm_resource_manager *man,
  				 struct drm_printer *printer)
  {
  	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
+	uint64_t used, used_pages;
 
  	spin_lock(&mgr->lock);
  	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);
+	used = amdgpu_gtt_mgr_usage(man);
+	used_pages = used/PAGE_SIZE;
+
+	drm_printf(printer, "man size:%llu pages,  gtt available:%lld pages, usage:%lluMB\n",
+		man->size, used_pages > man->size ? 0 : man->size - used_pages, used >> 20);
  }
 
  static const struct ttm_resource_manager_func amdgpu_gtt_mgr_func = {
@@ -274,7 +273,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);
 
  	ret = device_create_file(adev->dev, &dev_attr_mem_info_gtt_total);
  	if (ret) {
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -1
index c0aef327292a..129d39392859 100644
@@ -152,9 +152,11 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,
  			abo->placements[0].lpfn = 0;
  			abo->placement.busy_placement = &abo->placements[1];
  			abo->placement.num_busy_placement = 1;
+			abo->placements[1].flags |= TTM_PL_FLAG_TEMPORARY;
  		} else {
  			/* Move to GTT memory */
  			amdgpu_bo_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT);
+			abo->placements[0].flags |= TTM_PL_FLAG_TEMPORARY;
  		}
  		break;
  	case TTM_PL_TT:
@@ -538,7 +540,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;
  		}
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
index 2877a924086f..26b67af00550 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h struct amdgpu_gtt_mgr { · line 58

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -1
@@ -52,7 +52,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_preempt_mgr {

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#5 lore raw

RE: [PATCH v2 3/3] drm/amdgpu: allow temporary GTT allocation under memory pressure

[AMD Official Use Only]

Quoted 11 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Monday, May 31, 2021 8:49 PM
To: Yu, Lang <[email protected]>; [email protected]; dri- [email protected]
Cc: Thomas Hellströ <[email protected]>; Olsak, Marek <[email protected]>; Huang, Ray <[email protected]>; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH v2 3/3] drm/amdgpu: allow temporary GTT allocation under memory pressure

Quoted 3 lines

On which branch are you working? I have problems applying that one to amd- staging-drm-next.

[Yu, Lang]
amd-staging-drm-next.

Regards,
Lang

Quoted 164 lines

Christian.

Am 31.05.21 um 10:22 schrieb Lang Yu:

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c static int amdgpu_gtt_mgr_new(struct

Quoted 30 lines

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.

To solve the problem, we allow temporary GTT allocation under memory pressure and do the following:

1. Change mgr->available into mgr->used (invert the value).
2. Always account all GTT BOs to the used space.
3. Only when it is not a temporary allocation bail out.

v2: still account temporary GTT allocations

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 27 ++++++++++-----------
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     |  4 ++-
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  2 +-
  3 files changed, 17 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
index 8860545344c7..393f55f412b7 100644
@@ -111,14 +111,11 @@ static int amdgpu_gtt_mgr_new(struct

ttm_resource_manager *man,

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -4
  	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) {
-		spin_unlock(&mgr->lock);
+	if ((atomic64_add_return(mem->num_pages, &mgr->used) > man->size)

&&

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c static int amdgpu_gtt_mgr_new(struct

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +2 -2
+		!(mem->placement & TTM_PL_FLAG_TEMPORARY)) {
+		atomic64_sub(mem->num_pages, &mgr->used);
  		return -ENOSPC;
  	}
-	atomic64_sub(mem->num_pages, &mgr->available);
-	spin_unlock(&mgr->lock);
 
  	if (!place->lpfn) {
  		mem->mm_node = NULL;
@@ -152,7 +149,7 @@ static int amdgpu_gtt_mgr_new(struct

ttm_resource_manager *man,

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c static void amdgpu_gtt_mgr_del(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -1
  	kfree(node);
 
  err_out:
-	atomic64_add(mem->num_pages, &mgr->available);
+	atomic64_sub(mem->num_pages, &mgr->used);
 
  	return r;
  }
@@ -178,7 +175,7 @@ static void amdgpu_gtt_mgr_del(struct

ttm_resource_manager *man,

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c static void amdgpu_gtt_mgr_del(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -1
  		kfree(node);
  	}
 
-	atomic64_add(mem->num_pages, &mgr->available);
+	atomic64_sub(mem->num_pages, &mgr->used);
  }
 
  /**
@@ -191,9 +188,8 @@ static void amdgpu_gtt_mgr_del(struct

ttm_resource_manager *man,

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c static void amdgpu_gtt_mgr_debug(struct

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -2
  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;
  }
 
  /**
@@ -234,14 +230,17 @@ static void amdgpu_gtt_mgr_debug(struct

ttm_resource_manager *man,

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c static void amdgpu_gtt_mgr_debug(struct ttm_resource_manager *man,

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -1
  				 struct drm_printer *printer)
  {
  	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
+	uint64_t used, used_pages;
 
  	spin_lock(&mgr->lock);
  	drm_mm_print(&mgr->mm, printer);
  	spin_unlock(&mgr->lock);
 
-	drm_printf(printer, "man size:%llu pages, gtt available:%lld pages,

usage:%lluMB\n",

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c static void amdgpu_gtt_mgr_debug(struct ttm_resource_manager *man,

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +4 -2
-		   man->size, (u64)atomic64_read(&mgr->available),
-		   amdgpu_gtt_mgr_usage(man) >> 20);
+	used = amdgpu_gtt_mgr_usage(man);
+	used_pages = used/PAGE_SIZE;
+
+	drm_printf(printer, "man size:%llu pages,  gtt available:%lld pages,

usage:%lluMB\n",

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +2 -0
+		man->size, used_pages > man->size ? 0 : man->size - used_pages,
+used >> 20);
  }
 
  static const struct ttm_resource_manager_func amdgpu_gtt_mgr_func =

{ @@ -274,7 +273,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev,

uint64_t gtt_size)

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void amdgpu_evict_flags(struct

Quoted 14 lines
  	size = (adev->gmc.gart_size >> PAGE_SHIFT) - start;
  	drm_mm_init(&mgr->mm, start, size);
  	spin_lock_init(&mgr->lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -1
-	atomic64_set(&mgr->available, gtt_size >> PAGE_SHIFT);
+	atomic64_set(&mgr->used, 0);
 
  	ret = device_create_file(adev->dev, &dev_attr_mem_info_gtt_total);
  	if (ret) {
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
index c0aef327292a..129d39392859 100644
@@ -152,9 +152,11 @@ static void amdgpu_evict_flags(struct

ttm_buffer_object *bo,

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void amdgpu_evict_flags(struct · line 156

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -0
  			abo->placements[0].lpfn = 0;
  			abo->placement.busy_placement = &abo-
 placements[1];
  			abo->placement.num_busy_placement = 1;
+			abo->placements[1].flags |=

TTM_PL_FLAG_TEMPORARY;

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void amdgpu_evict_flags(struct ttm_buffer_object *bo,

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
  		} else {
  			/* Move to GTT memory */
  			amdgpu_bo_placement_from_domain(abo,

AMDGPU_GEM_DOMAIN_GTT);

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void amdgpu_evict_flags(struct · line 160

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -0
+			abo->placements[0].flags |=

TTM_PL_FLAG_TEMPORARY;

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_bo_move(struct ttm_buffer_object

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
  		}
  		break;

case TTM_PL_TT:

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -538,7 +540,7 @@ static int amdgpu_bo_move(struct ttm_buffer_object

*bo, bool evict,

Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
  			hop->fpfn = 0;
  			hop->lpfn = 0;
  			hop->mem_type = TTM_PL_TT;
-			hop->flags = 0;
+			hop->flags |= TTM_PL_FLAG_TEMPORARY;
  			return -EMULTIHOP;
  		}
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -1
index 2877a924086f..26b67af00550 100644
@@ -52,7 +52,7 @@ struct amdgpu_gtt_mgr {
  	struct ttm_resource_manager manager;
  	struct drm_mm mm;
  	spinlock_t lock;
-	atomic64_t available;
+	atomic64_t used;
  };
 
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h struct amdgpu_gtt_mgr { · line 58

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
  struct amdgpu_preempt_mgr {

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx