[PATCH 2/2] drm/amdgpu: stop bookkeeping of temporary GTT allocation
Lang Yu
Lang.Yu at amd.com
Thu May 27 01:30:51 UTC 2021
To improve buffer migration performace, stop bookkeeping of
temporary GTT allocation, including allocation for BO evicted
from VRAM and bounce buffer.
Signed-off-by: Lang Yu <Lang.Yu at amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 16 ++++++++++------
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 +++-
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 8860545344c7..32fedd495c7f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
@@ -111,14 +111,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 (!(mem->placement & 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;
@@ -178,6 +179,9 @@ static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
kfree(node);
}
+ if (mem->placement & TTM_PL_FLAG_TEMPORARY)
+ return;
+
atomic64_add(mem->num_pages, &mgr->available);
}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index c0aef327292a..129d39392859 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -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;
}
--
2.25.1
More information about the amd-gfx
mailing list