aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2017-10-27 08:17:09 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-12-04 16:41:32 -0500
commit3da917b6c6843ad0162e9768c40a83b6c4448646 (patch)
treec5982ec901b7e976dd905e9caa875f187fa6112b /drivers/gpu/drm
parent34a4d2bf06b3ab92024b8e26d6049411369d1f1a (diff)
drm/amdgpu: nuke amdgpu_ttm_is_bound() v2
Rename amdgpu_gtt_mgr_is_allocated() to amdgpu_gtt_mgr_has_gart_addr() and use that instead. v2: rename the function as well. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Chunming Zhou <david1.zhou@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.h2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c24
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h3
5 files changed, 15 insertions, 22 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 00e0ce10862f..f7669dc6909b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
@@ -79,13 +79,13 @@ static int amdgpu_gtt_mgr_fini(struct ttm_mem_type_manager *man)
79} 79}
80 80
81/** 81/**
82 * amdgpu_gtt_mgr_is_allocated - Check if mem has address space 82 * amdgpu_gtt_mgr_has_gart_addr - Check if mem has address space
83 * 83 *
84 * @mem: the mem object to check 84 * @mem: the mem object to check
85 * 85 *
86 * Check if a mem object has already address space allocated. 86 * Check if a mem object has already address space allocated.
87 */ 87 */
88bool amdgpu_gtt_mgr_is_allocated(struct ttm_mem_reg *mem) 88bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem)
89{ 89{
90 struct drm_mm_node *node = mem->mm_node; 90 struct drm_mm_node *node = mem->mm_node;
91 91
@@ -114,7 +114,7 @@ static int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man,
114 unsigned long fpfn, lpfn; 114 unsigned long fpfn, lpfn;
115 int r; 115 int r;
116 116
117 if (amdgpu_gtt_mgr_is_allocated(mem)) 117 if (amdgpu_gtt_mgr_has_gart_addr(mem))
118 return 0; 118 return 0;
119 119
120 if (place) 120 if (place)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 589aa5099881..ff6f842655d1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -982,7 +982,7 @@ u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo)
982{ 982{
983 WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_SYSTEM); 983 WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_SYSTEM);
984 WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_TT && 984 WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_TT &&
985 !amdgpu_ttm_is_bound(bo->tbo.ttm)); 985 !amdgpu_gtt_mgr_has_gart_addr(&bo->tbo.mem));
986 WARN_ON_ONCE(!ww_mutex_is_locked(&bo->tbo.resv->lock) && 986 WARN_ON_ONCE(!ww_mutex_is_locked(&bo->tbo.resv->lock) &&
987 !bo->pin_count); 987 !bo->pin_count);
988 WARN_ON_ONCE(bo->tbo.mem.start == AMDGPU_BO_INVALID_OFFSET); 988 WARN_ON_ONCE(bo->tbo.mem.start == AMDGPU_BO_INVALID_OFFSET);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index 428aae048f4b..33615e2ea2e6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -187,7 +187,7 @@ static inline u64 amdgpu_bo_mmap_offset(struct amdgpu_bo *bo)
187static inline bool amdgpu_bo_gpu_accessible(struct amdgpu_bo *bo) 187static inline bool amdgpu_bo_gpu_accessible(struct amdgpu_bo *bo)
188{ 188{
189 switch (bo->tbo.mem.mem_type) { 189 switch (bo->tbo.mem.mem_type) {
190 case TTM_PL_TT: return amdgpu_ttm_is_bound(bo->tbo.ttm); 190 case TTM_PL_TT: return amdgpu_gtt_mgr_has_gart_addr(&bo->tbo.mem);
191 case TTM_PL_VRAM: return true; 191 case TTM_PL_VRAM: return true;
192 default: return false; 192 default: return false;
193 } 193 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 6a724f9f1b86..3d02c2dd06e5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -282,8 +282,7 @@ static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo,
282{ 282{
283 uint64_t addr = 0; 283 uint64_t addr = 0;
284 284
285 if (mem->mem_type != TTM_PL_TT || 285 if (mem->mem_type != TTM_PL_TT || amdgpu_gtt_mgr_has_gart_addr(mem)) {
286 amdgpu_gtt_mgr_is_allocated(mem)) {
287 addr = mm_node->start << PAGE_SHIFT; 286 addr = mm_node->start << PAGE_SHIFT;
288 addr += bo->bdev->man[mem->mem_type].gpu_offset; 287 addr += bo->bdev->man[mem->mem_type].gpu_offset;
289 } 288 }
@@ -369,7 +368,7 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
369 * dst to window 1 368 * dst to window 1
370 */ 369 */
371 if (src->mem->mem_type == TTM_PL_TT && 370 if (src->mem->mem_type == TTM_PL_TT &&
372 !amdgpu_gtt_mgr_is_allocated(src->mem)) { 371 !amdgpu_gtt_mgr_has_gart_addr(src->mem)) {
373 r = amdgpu_map_buffer(src->bo, src->mem, 372 r = amdgpu_map_buffer(src->bo, src->mem,
374 PFN_UP(cur_size + src_page_offset), 373 PFN_UP(cur_size + src_page_offset),
375 src_node_start, 0, ring, 374 src_node_start, 0, ring,
@@ -383,7 +382,7 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
383 } 382 }
384 383
385 if (dst->mem->mem_type == TTM_PL_TT && 384 if (dst->mem->mem_type == TTM_PL_TT &&
386 !amdgpu_gtt_mgr_is_allocated(dst->mem)) { 385 !amdgpu_gtt_mgr_has_gart_addr(dst->mem)) {
387 r = amdgpu_map_buffer(dst->bo, dst->mem, 386 r = amdgpu_map_buffer(dst->bo, dst->mem,
388 PFN_UP(cur_size + dst_page_offset), 387 PFN_UP(cur_size + dst_page_offset),
389 dst_node_start, 1, ring, 388 dst_node_start, 1, ring,
@@ -861,8 +860,10 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,
861 bo_mem->mem_type == AMDGPU_PL_OA) 860 bo_mem->mem_type == AMDGPU_PL_OA)
862 return -EINVAL; 861 return -EINVAL;
863 862
864 if (!amdgpu_gtt_mgr_is_allocated(bo_mem)) 863 if (!amdgpu_gtt_mgr_has_gart_addr(bo_mem)) {
864 gtt->offset = AMDGPU_BO_INVALID_OFFSET;
865 return 0; 865 return 0;
866 }
866 867
867 spin_lock(&gtt->adev->gtt_list_lock); 868 spin_lock(&gtt->adev->gtt_list_lock);
868 flags = amdgpu_ttm_tt_pte_flags(gtt->adev, ttm, bo_mem); 869 flags = amdgpu_ttm_tt_pte_flags(gtt->adev, ttm, bo_mem);
@@ -882,23 +883,16 @@ error_gart_bind:
882 return r; 883 return r;
883} 884}
884 885
885bool amdgpu_ttm_is_bound(struct ttm_tt *ttm)
886{
887 struct amdgpu_ttm_tt *gtt = (void *)ttm;
888
889 return gtt && !list_empty(&gtt->list);
890}
891
892int amdgpu_ttm_bind(struct ttm_buffer_object *bo) 886int amdgpu_ttm_bind(struct ttm_buffer_object *bo)
893{ 887{
894 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); 888 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
895 struct ttm_tt *ttm = bo->ttm;
896 struct ttm_mem_reg tmp; 889 struct ttm_mem_reg tmp;
897 struct ttm_placement placement; 890 struct ttm_placement placement;
898 struct ttm_place placements; 891 struct ttm_place placements;
899 int r; 892 int r;
900 893
901 if (!ttm || amdgpu_ttm_is_bound(ttm)) 894 if (bo->mem.mem_type != TTM_PL_TT ||
895 amdgpu_gtt_mgr_has_gart_addr(&bo->mem))
902 return 0; 896 return 0;
903 897
904 tmp = bo->mem; 898 tmp = bo->mem;
@@ -959,7 +953,7 @@ static int amdgpu_ttm_backend_unbind(struct ttm_tt *ttm)
959 if (gtt->userptr) 953 if (gtt->userptr)
960 amdgpu_ttm_tt_unpin_userptr(ttm); 954 amdgpu_ttm_tt_unpin_userptr(ttm);
961 955
962 if (!amdgpu_ttm_is_bound(ttm)) 956 if (gtt->offset == AMDGPU_BO_INVALID_OFFSET)
963 return 0; 957 return 0;
964 958
965 /* unbind shouldn't be done for GDS/GWS/OA in ttm_bo_clean_mm */ 959 /* unbind shouldn't be done for GDS/GWS/OA in ttm_bo_clean_mm */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index 0108a59559cd..016d2af05d34 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
@@ -67,7 +67,7 @@ struct amdgpu_copy_mem {
67extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func; 67extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
68extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func; 68extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;
69 69
70bool amdgpu_gtt_mgr_is_allocated(struct ttm_mem_reg *mem); 70bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem);
71uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man); 71uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man);
72 72
73uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man); 73uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man);
@@ -90,7 +90,6 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
90 struct dma_fence **fence); 90 struct dma_fence **fence);
91 91
92int amdgpu_mmap(struct file *filp, struct vm_area_struct *vma); 92int amdgpu_mmap(struct file *filp, struct vm_area_struct *vma);
93bool amdgpu_ttm_is_bound(struct ttm_tt *ttm);
94int amdgpu_ttm_bind(struct ttm_buffer_object *bo); 93int amdgpu_ttm_bind(struct ttm_buffer_object *bo);
95int amdgpu_ttm_recover_gart(struct amdgpu_device *adev); 94int amdgpu_ttm_recover_gart(struct amdgpu_device *adev);
96 95