Change-Id: Ifea42c8ae2206143d7e22b35eea537ba9e928fe8 Signed-off-by: Chunming Zhou <David1.Zhou at amd.com> --- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 13 ++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 6 ------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c index 85de145..db7bbde 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c @@ -97,6 +97,7 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man, { struct amdgpu_gtt_mgr *mgr = man->priv; struct drm_mm_node *node = mem->mm_node; + struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); enum drm_mm_search_flags sflags = DRM_MM_SEARCH_BEST; enum drm_mm_allocator_flags aflags = DRM_MM_CREATE_DEFAULT; unsigned long fpfn, lpfn; @@ -124,8 +125,10 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man, r = drm_mm_insert_node_in_range_generic(&mgr->mm, node, mem->num_pages, mem->page_alignment, 0, fpfn, lpfn, sflags, aflags); - if (!r) + if (!r) { mgr->available -= mem->num_pages; + atomic64_add(mem->size, &adev->gtt_usage); + } spin_unlock(&mgr->lock); if (!r) { @@ -140,10 +143,12 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man, void amdgpu_gtt_mgr_print(struct seq_file *m, struct ttm_mem_type_manager *man) { + struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); struct amdgpu_gtt_mgr *mgr = man->priv; - seq_printf(m, "man size:%llu pages, gtt available:%llu pages\n", - man->size, mgr->available); + seq_printf(m, "man size:%llu pages, gtt available:%llu pages, usage:%lluMB\n", + man->size, mgr->available, + (u64)atomic64_read(&adev->gtt_usage) >> 20); } /** * amdgpu_gtt_mgr_new - allocate a new node @@ -214,6 +219,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man, { struct amdgpu_gtt_mgr *mgr = man->priv; struct drm_mm_node *node = mem->mm_node; + struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); if (!node) return; @@ -222,6 +228,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man, if (node->start != AMDGPU_BO_INVALID_OFFSET) { drm_mm_remove_node(node); mgr->available += mem->num_pages; + atomic64_sub(mem->size, &adev->gtt_usage); } spin_unlock(&mgr->lock); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 3cde1c9..2249eb6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -61,9 +61,6 @@ static void amdgpu_update_memory_usage(struct amdgpu_device *adev, if (new_mem) { switch (new_mem->mem_type) { - case TTM_PL_TT: - atomic64_add(new_mem->size, &adev->gtt_usage); - break; case TTM_PL_VRAM: atomic64_add(new_mem->size, &adev->vram_usage); vis_size = amdgpu_get_vis_part_size(adev, new_mem); @@ -80,9 +77,6 @@ static void amdgpu_update_memory_usage(struct amdgpu_device *adev, if (old_mem) { switch (old_mem->mem_type) { - case TTM_PL_TT: - atomic64_sub(old_mem->size, &adev->gtt_usage); - break; case TTM_PL_VRAM: atomic64_sub(old_mem->size, &adev->vram_usage); vis_size = amdgpu_get_vis_part_size(adev, old_mem); -- 1.9.1