diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 14 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 31 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 4 |
3 files changed, 30 insertions, 19 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c index 9e05e257729f..0d15eb7d31d7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | |||
@@ -108,10 +108,10 @@ bool amdgpu_gtt_mgr_is_allocated(struct ttm_mem_reg *mem) | |||
108 | * | 108 | * |
109 | * Allocate the address space for a node. | 109 | * Allocate the address space for a node. |
110 | */ | 110 | */ |
111 | int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man, | 111 | static int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man, |
112 | struct ttm_buffer_object *tbo, | 112 | struct ttm_buffer_object *tbo, |
113 | const struct ttm_place *place, | 113 | const struct ttm_place *place, |
114 | struct ttm_mem_reg *mem) | 114 | struct ttm_mem_reg *mem) |
115 | { | 115 | { |
116 | struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); | 116 | struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); |
117 | struct amdgpu_gtt_mgr *mgr = man->priv; | 117 | struct amdgpu_gtt_mgr *mgr = man->priv; |
@@ -143,12 +143,8 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man, | |||
143 | fpfn, lpfn, mode); | 143 | fpfn, lpfn, mode); |
144 | spin_unlock(&mgr->lock); | 144 | spin_unlock(&mgr->lock); |
145 | 145 | ||
146 | if (!r) { | 146 | if (!r) |
147 | mem->start = node->start; | 147 | mem->start = node->start; |
148 | if (&tbo->mem == mem) | ||
149 | tbo->offset = (tbo->mem.start << PAGE_SHIFT) + | ||
150 | tbo->bdev->man[tbo->mem.mem_type].gpu_offset; | ||
151 | } | ||
152 | 148 | ||
153 | return r; | 149 | return r; |
154 | } | 150 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 8b2c294f6f79..1efe1cba7e11 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | |||
@@ -824,20 +824,39 @@ bool amdgpu_ttm_is_bound(struct ttm_tt *ttm) | |||
824 | 824 | ||
825 | int amdgpu_ttm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *bo_mem) | 825 | int amdgpu_ttm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *bo_mem) |
826 | { | 826 | { |
827 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); | ||
827 | struct ttm_tt *ttm = bo->ttm; | 828 | struct ttm_tt *ttm = bo->ttm; |
829 | struct ttm_mem_reg tmp; | ||
830 | |||
831 | struct ttm_placement placement; | ||
832 | struct ttm_place placements; | ||
828 | int r; | 833 | int r; |
829 | 834 | ||
830 | if (!ttm || amdgpu_ttm_is_bound(ttm)) | 835 | if (!ttm || amdgpu_ttm_is_bound(ttm)) |
831 | return 0; | 836 | return 0; |
832 | 837 | ||
833 | r = amdgpu_gtt_mgr_alloc(&bo->bdev->man[TTM_PL_TT], bo, | 838 | tmp = bo->mem; |
834 | NULL, bo_mem); | 839 | tmp.mm_node = NULL; |
835 | if (r) { | 840 | placement.num_placement = 1; |
836 | DRM_ERROR("Failed to allocate GTT address space (%d)\n", r); | 841 | placement.placement = &placements; |
842 | placement.num_busy_placement = 1; | ||
843 | placement.busy_placement = &placements; | ||
844 | placements.fpfn = 0; | ||
845 | placements.lpfn = adev->mc.gart_size >> PAGE_SHIFT; | ||
846 | placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT; | ||
847 | |||
848 | r = ttm_bo_mem_space(bo, &placement, &tmp, true, false); | ||
849 | if (unlikely(r)) | ||
837 | return r; | 850 | return r; |
838 | } | ||
839 | 851 | ||
840 | return amdgpu_ttm_do_bind(ttm, bo_mem); | 852 | r = ttm_bo_move_ttm(bo, true, false, &tmp); |
853 | if (unlikely(r)) | ||
854 | ttm_bo_mem_put(bo, &tmp); | ||
855 | else | ||
856 | bo->offset = (bo->mem.start << PAGE_SHIFT) + | ||
857 | bo->bdev->man[bo->mem.mem_type].gpu_offset; | ||
858 | |||
859 | return r; | ||
841 | } | 860 | } |
842 | 861 | ||
843 | int amdgpu_ttm_recover_gart(struct amdgpu_device *adev) | 862 | int amdgpu_ttm_recover_gart(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h index f22a4758719d..43093bffa2cf 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | |||
@@ -62,10 +62,6 @@ extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func; | |||
62 | extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func; | 62 | extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func; |
63 | 63 | ||
64 | bool amdgpu_gtt_mgr_is_allocated(struct ttm_mem_reg *mem); | 64 | bool amdgpu_gtt_mgr_is_allocated(struct ttm_mem_reg *mem); |
65 | int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man, | ||
66 | struct ttm_buffer_object *tbo, | ||
67 | const struct ttm_place *place, | ||
68 | struct ttm_mem_reg *mem); | ||
69 | uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man); | 65 | uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man); |
70 | 66 | ||
71 | uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man); | 67 | uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man); |