drm/amdgpu: nuke amdgpu_ttm_is_bound() v2
Subsystems (3)
PATCH 1/5 drm/amdgpu: nuke amdgpu_ttm_is_bound() v2
From: Christian König <[email protected]>
Rename amdgpu_gtt_mgr_is_allocated() to amdgpu_gtt_mgr_has_gart_addr() and use that instead.
v2: rename the function as well.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 24 +++++++++--------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 +-- 5 files changed, 15 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +3 -3
@@ -85,13 +85,13 @@ static int amdgpu_gtt_mgr_fini(struct ttm_mem_type_manager *man) }/** -* amdgpu_gtt_mgr_is_allocated - Check if mem has address space +* amdgpu_gtt_mgr_has_gart_addr - Check if mem has address space * * @mem: the mem object to check * * Check if a mem object has already address space allocated. */ -bool amdgpu_gtt_mgr_is_allocated (struct ttm_mem_reg *mem) +bool amdgpu_gtt_mgr_has_gart_addr (struct ttm_mem_reg *mem) {struct drm_mm_node *node = mem->mm_node;
@@ -120,7 +120,7 @@ static int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man,unsigned long fpfn, lpfn;int r; -if (amdgpu_gtt_mgr_is_allocated (mem)) +if (amdgpu_gtt_mgr_has_gart_addr (mem))return 0 ;if (place)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
@@ -982,7 +982,7 @@ u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo) {WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_SYSTEM );WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_TT && - !amdgpu_ttm_is_bound (bo->tbo.ttm)); + !amdgpu_gtt_mgr_has_gart_addr (&bo->tbo.mem));WARN_ON_ONCE (!ww_mutex_is_locked (&bo->tbo.resv->lock) && !bo->pin_count);WARN_ON_ONCE (bo->tbo.mem.start ==AMDGPU_BO_INVALID_OFFSET );
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +1 -1
@@ -187,7 +187,7 @@ static inline u64 amdgpu_bo_mmap_offset(struct amdgpu_bo *bo)static inline bool amdgpu_bo_gpu_accessible (struct amdgpu_bo *bo) {switch (bo->tbo.mem.mem_type) { -case TTM_PL_TT :return amdgpu_ttm_is_bound (bo->tbo.ttm); +case TTM_PL_TT :return amdgpu_gtt_mgr_has_gart_addr (&bo->tbo.mem);case TTM_PL_VRAM :return true;default :return false; }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +9 -15
@@ -282,8 +282,7 @@ static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo, {uint64_t addr =0 ; -if (mem->mem_type !=TTM_PL_TT || -amdgpu_gtt_mgr_is_allocated (mem)) { +if (mem->mem_type !=TTM_PL_TT ||amdgpu_gtt_mgr_has_gart_addr (mem)) { addr = mm_node->start <<PAGE_SHIFT ; addr += bo->bdev->man[mem->mem_type].gpu_offset; }
@@ -369,7 +368,7 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,* dst to window 1 */ if (src->mem->mem_type ==TTM_PL_TT && - !amdgpu_gtt_mgr_is_allocated (src->mem)) { + !amdgpu_gtt_mgr_has_gart_addr (src->mem)) { r = amdgpu_map_buffer(src->bo, src->mem, PFN_UP(cur_size + src_page_offset), src_node_start, 0, ring,
@@ -383,7 +382,7 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev, }if (dst->mem->mem_type ==TTM_PL_TT && - !amdgpu_gtt_mgr_is_allocated (dst->mem)) { + !amdgpu_gtt_mgr_has_gart_addr (dst->mem)) { r = amdgpu_map_buffer(dst->bo, dst->mem, PFN_UP(cur_size + dst_page_offset), dst_node_start, 1, ring,
@@ -861,8 +860,10 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, bo_mem->mem_type == AMDGPU_PL_OA)return -EINVAL ; -if (!amdgpu_gtt_mgr_is_allocated (bo_mem)) +if (!amdgpu_gtt_mgr_has_gart_addr (bo_mem)) { + gtt->offset =AMDGPU_BO_INVALID_OFFSET ;return 0 ; + }spin_lock (>t->adev->gtt_list_lock); flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem);
@@ -882,24 +883,17 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,return r; } -bool amdgpu_ttm_is_bound (struct ttm_tt *ttm) -{ -struct amdgpu_ttm_tt *gtt = (void *)ttm; - -return gtt && !list_empty (>t->list); -} -int amdgpu_ttm_bind (struct ttm_buffer_object *bo) {struct amdgpu_device *adev =amdgpu_ttm_adev (bo->bdev); -struct ttm_tt *ttm = bo->ttm;struct ttm_mem_reg tmp;struct ttm_placement placement;struct ttm_place placements;int r; -if (!ttm ||amdgpu_ttm_is_bound (ttm)) +if (bo->mem.mem_type !=TTM_PL_TT || +amdgpu_gtt_mgr_has_gart_addr (&bo->mem))return 0 ; tmp = bo->mem;
@@ -960,7 +954,7 @@ static int amdgpu_ttm_backend_unbind(struct ttm_tt *ttm)if (gtt->userptr)amdgpu_ttm_tt_unpin_userptr (ttm); -if (!amdgpu_ttm_is_bound (ttm)) +if (gtt->offset ==AMDGPU_BO_INVALID_OFFSET )return 0 ;/* unbind shouldn't be done for GDS/GWS/OA in ttm_bo_clean_mm */
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -2
@@ -67,7 +67,7 @@ struct amdgpu_copy_mem {extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func; -bool amdgpu_gtt_mgr_is_allocated (struct ttm_mem_reg *mem); +bool amdgpu_gtt_mgr_has_gart_addr (struct ttm_mem_reg *mem);uint64_t amdgpu_gtt_mgr_usage (struct ttm_mem_type_manager *man);uint64_t amdgpu_vram_mgr_usage (struct ttm_mem_type_manager *man);
@@ -90,7 +90,6 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, struct dma_fence **fence);int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma); -bool amdgpu_ttm_is_bound (struct ttm_tt *ttm);int amdgpu_ttm_bind (struct ttm_buffer_object *bo);int amdgpu_ttm_recover_gart (struct amdgpu_device *adev);
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1509115410-2557-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
PATCH 2/5 drm/amdgpu: move GART recovery into GTT manager
From: Christian König <[email protected]>
The GTT manager handles the GART address space anyway, so it is completely pointless to keep the same information around twice.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 -- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 53 +++++++++++++++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 51 ++++++++------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 +- 5 files changed, 59 insertions(+), 59 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -3
@@ -1633,9 +1633,6 @@ struct amdgpu_device {/* link all shadow bo */ struct list_head shadow_list;struct mutex shadow_list_lock; -/* link all gtt */ -spinlock_t gtt_list_lock; -struct list_head gtt_list;/* keep an lru list of rings by HW IP */ struct list_head ring_lru_list;spinlock_t ring_lru_list_lock;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -5
@@ -2177,9 +2177,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,INIT_LIST_HEAD (&adev->shadow_list);mutex_init (&adev->shadow_list_lock); -INIT_LIST_HEAD (&adev->gtt_list); -spin_lock_init (&adev->gtt_list_lock); -INIT_LIST_HEAD (&adev->ring_lru_list);spin_lock_init (&adev->ring_lru_list_lock);
@@ -2893,7 +2890,7 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, struct amdgpu_job *job)amdgpu_sriov_reinit_early (adev);/* we need recover gart prior to run SMC/CP/SDMA resume */ -amdgpu_ttm_recover_gart (adev); +amdgpu_gtt_mgr_recover (&adev->mman.bdev.man[TTM_PL_TT ]);/* now we are okay to resume SMC/CP/SDMA */ amdgpu_sriov_reinit_late (adev);
@@ -3034,7 +3031,8 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)DRM_ERROR ("VRAM is lost!\n" );atomic_inc (&adev->vram_lost_counter); } - r =amdgpu_ttm_recover_gart (adev); + r =amdgpu_gtt_mgr_recover ( + &adev->mman.bdev.man[TTM_PL_TT ]);if (r) goto out; r =amdgpu_resume_phase2 (adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +39 -14
116 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +15 -36
95 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +2 -1
@@ -69,6 +69,7 @@ extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;bool amdgpu_gtt_mgr_has_gart_addr (struct ttm_mem_reg *mem);uint64_t amdgpu_gtt_mgr_usage (struct ttm_mem_type_manager *man); +int amdgpu_gtt_mgr_recover (struct ttm_mem_type_manager *man);uint64_t amdgpu_vram_mgr_usage (struct ttm_mem_type_manager *man);uint64_t amdgpu_vram_mgr_vis_usage (struct ttm_mem_type_manager *man);
@@ -91,7 +92,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma);int amdgpu_ttm_bind (struct ttm_buffer_object *bo); -int amdgpu_ttm_recover_gart (struct amdgpu_device *adev); +int amdgpu_ttm_recover_gart (struct ttm_buffer_object *tbo);int amdgpu_ttm_tt_get_user_pages (struct ttm_tt *ttm,struct page **pages);void amdgpu_ttm_tt_set_user_pages (struct ttm_tt *ttm,struct page **pages);
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1509115410-2557-2-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Re: [PATCH 2/5] drm/amdgpu: move GART recovery into GTT manager
Quoted 6 lines · Christian König
From: Christian König <[email protected]>
The GTT manager handles the GART address space anyway, so it is completely pointless to keep the same information around twice.
Signed-off-by Christian König <[email protected]>
Good cleanup, Reviewed-by: Chunming Zhou <[email protected]>
Quoted 301 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 -- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 53 +++++++++++++++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 51 ++++++++------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 +- 5 files changed, 59 insertions(+), 59 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-3@@ -1633,9 +1633,6 @@ struct amdgpu_device {/* link all shadow bo */ struct list_head shadow_list;struct mutex shadow_list_lock; -/* link all gtt */ -spinlock_t gtt_list_lock; -struct list_head gtt_list;/* keep an lru list of rings by HW IP */ struct list_head ring_lru_list;spinlock_t ring_lru_list_lock;drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-5@@ -2177,9 +2177,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,INIT_LIST_HEAD (&adev->shadow_list);mutex_init (&adev->shadow_list_lock); -INIT_LIST_HEAD (&adev->gtt_list); -spin_lock_init (&adev->gtt_list_lock); -INIT_LIST_HEAD (&adev->ring_lru_list);spin_lock_init (&adev->ring_lru_list_lock);@@ -2893,7 +2890,7 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, struct amdgpu_job *job)amdgpu_sriov_reinit_early (adev);/* we need recover gart prior to run SMC/CP/SDMA resume */ -amdgpu_ttm_recover_gart (adev); +amdgpu_gtt_mgr_recover (&adev->mman.bdev.man[TTM_PL_TT ]);/* now we are okay to resume SMC/CP/SDMA */ amdgpu_sriov_reinit_late (adev);@@ -3034,7 +3031,8 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)DRM_ERROR ("VRAM is lost!\n" );atomic_inc (&adev->vram_lost_counter); } - r =amdgpu_ttm_recover_gart (adev); + r =amdgpu_gtt_mgr_recover ( + &adev->mman.bdev.man[TTM_PL_TT ]);if (r) goto out; r =amdgpu_resume_phase2 (adev);drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +39
-14@@ -31,6 +31,11 @@ struct amdgpu_gtt_mgr {atomic64_t available; }; +struct amdgpu_gtt_node { +struct drm_mm_node node; +struct ttm_buffer_object *tbo; +}; +/** * amdgpu_gtt_mgr_init - init GTT manager and DRM MM * @@ -93,9 +98,9 @@ static int amdgpu_gtt_mgr_fini(struct ttm_mem_type_manager *man)*/ bool amdgpu_gtt_mgr_has_gart_addr (struct ttm_mem_reg *mem) { -struct drm_mm_node *node = mem->mm_node; +struct amdgpu_gtt_node *node = mem->mm_node; -return (node->start !=AMDGPU_BO_INVALID_OFFSET ); +return (node->node.start !=AMDGPU_BO_INVALID_OFFSET ); }/** @@ -115,7 +120,7 @@ static int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man, {struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev);struct amdgpu_gtt_mgr *mgr = man->priv; -struct drm_mm_node *node = mem->mm_node; +struct amdgpu_gtt_node *node = mem->mm_node;enum drm_mm_insert_mode mode;unsigned long fpfn, lpfn;int r;@@ -138,13 +143,13 @@ static int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man, mode =DRM_MM_INSERT_HIGH ;spin_lock (&mgr->lock); - r =drm_mm_insert_node_in_range (&mgr->mm, node, - mem->num_pages, mem->page_alignment,0 , - fpfn, lpfn, mode); + r =drm_mm_insert_node_in_range (&mgr->mm, &node->node, mem->num_pages, + mem->page_alignment,0 , fpfn, lpfn, + mode);spin_unlock (&mgr->lock);if (!r) - mem->start = node->start; + mem->start = node->node.start;return r; }@@ -165,7 +170,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man, struct ttm_mem_reg *mem) {struct amdgpu_gtt_mgr *mgr = man->priv; -struct drm_mm_node *node; +struct amdgpu_gtt_node *node;int r;spin_lock (&mgr->lock);@@ -183,8 +188,9 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man, goto err_out; } - node->start =AMDGPU_BO_INVALID_OFFSET ; - node->size = mem->num_pages; + node->node.start =AMDGPU_BO_INVALID_OFFSET ; + node->node.size = mem->num_pages; + node->tbo = tbo; mem->mm_node = node;if (place->fpfn || place->lpfn || place->flags &TTM_PL_FLAG_TOPDOWN ) {@@ -196,7 +202,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man, goto err_out; } }else { - mem->start = node->start; + mem->start = node->node.start; }return 0 ;@@ -220,14 +226,14 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *mem) {struct amdgpu_gtt_mgr *mgr = man->priv; -struct drm_mm_node *node = mem->mm_node; +struct amdgpu_gtt_node *node = mem->mm_node;if (!node)return ;spin_lock (&mgr->lock); -if (node->start !=AMDGPU_BO_INVALID_OFFSET ) -drm_mm_remove_node (node); +if (node->node.start !=AMDGPU_BO_INVALID_OFFSET ) +drm_mm_remove_node (&node->node);spin_unlock (&mgr->lock);atomic64_add (mem->num_pages, &mgr->available);@@ -250,6 +256,25 @@ uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man)return (result >0 ? result :0 ) *PAGE_SIZE ; } +int amdgpu_gtt_mgr_recover (struct ttm_mem_type_manager *man) +{ +struct amdgpu_gtt_mgr *mgr = man->priv; +struct amdgpu_gtt_node *node; +struct drm_mm_node *mm_node; +int r =0 ; + +spin_lock (&mgr->lock); +drm_mm_for_each_node (mm_node, &mgr->mm) { + node = container_of(mm_node, struct amdgpu_gtt_node, node); + r =amdgpu_ttm_recover_gart (node->tbo); +if (r) +break ; + } +spin_unlock (&mgr->lock); + +return r; +} +/** * amdgpu_gtt_mgr_debug - dump VRAM table * drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +15
-36@@ -689,7 +689,6 @@ struct amdgpu_ttm_tt {struct list_head guptasks;atomic_t mmu_invalidations;uint32_t last_set_pages; -struct list_head list; };int amdgpu_ttm_tt_get_user_pages (struct ttm_tt *ttm,struct page **pages)@@ -865,21 +864,14 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,return 0 ; } -spin_lock (>t->adev->gtt_list_lock); flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem); gtt->offset = (u64 )bo_mem->start <<PAGE_SHIFT ; r =amdgpu_gart_bind (gtt->adev, gtt->offset, ttm->num_pages, ttm->pages, gtt->ttm.dma_address, flags); -if (r) { +if (r)DRM_ERROR ("failed to bind %lu pages at 0x%08llX\n" , ttm->num_pages, gtt->offset); - goto error_gart_bind; - } - -list_add_tail (>t->list, >t->adev->gtt_list); -error_gart_bind: -spin_unlock (>t->adev->gtt_list_lock);return r; }@@ -921,29 +913,23 @@ int amdgpu_ttm_bind(struct ttm_buffer_object *bo)return r; } -int amdgpu_ttm_recover_gart (struct amdgpu_device *adev) +int amdgpu_ttm_recover_gart (struct ttm_buffer_object *tbo) { -struct amdgpu_ttm_tt *gtt, *tmp; -struct ttm_mem_reg bo_mem; +struct amdgpu_device *adev =amdgpu_ttm_adev (tbo->bdev); +struct amdgpu_ttm_tt *gtt = (void *)tbo->ttm;uint64_t flags;int r; - bo_mem.mem_type =TTM_PL_TT ; -spin_lock (&adev->gtt_list_lock); -list_for_each_entry_safe (gtt, tmp, &adev->gtt_list, list) { - flags =amdgpu_ttm_tt_pte_flags (gtt->adev, >t->ttm.ttm, &bo_mem); - r =amdgpu_gart_bind (adev, gtt->offset, gtt->ttm.ttm.num_pages, - gtt->ttm.ttm.pages, gtt->ttm.dma_address, - flags); -if (r) { -spin_unlock (&adev->gtt_list_lock); -DRM_ERROR ("failed to bind %lu pages at 0x%08llX\n" , - gtt->ttm.ttm.num_pages, gtt->offset); -return r; - } - } -spin_unlock (&adev->gtt_list_lock); -return 0 ; +if (!gtt) +return 0 ; + + flags =amdgpu_ttm_tt_pte_flags (adev, >t->ttm.ttm, &tbo->mem); + r =amdgpu_gart_bind (adev, gtt->offset, gtt->ttm.ttm.num_pages, + gtt->ttm.ttm.pages, gtt->ttm.dma_address, flags); +if (r) +DRM_ERROR ("failed to bind %lu pages at 0x%08llX\n" , + gtt->ttm.ttm.num_pages, gtt->offset); +return r; }static int amdgpu_ttm_backend_unbind (struct ttm_tt *ttm)@@ -958,16 +944,10 @@ static int amdgpu_ttm_backend_unbind(struct ttm_tt *ttm)return 0 ;/* unbind shouldn't be done for GDS/GWS/OA in ttm_bo_clean_mm */ -spin_lock (>t->adev->gtt_list_lock); r =amdgpu_gart_unbind (gtt->adev, gtt->offset, ttm->num_pages); -if (r) { +if (r)DRM_ERROR ("failed to unbind %lu pages at 0x%08llX\n" , gtt->ttm.ttm.num_pages, gtt->offset); - goto error_unbind; - } -list_del_init (>t->list); -error_unbind: -spin_unlock (>t->adev->gtt_list_lock);return r; }@@ -1004,7 +984,6 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_bo_device *bdev,kfree (gtt);return NULL ; } -INIT_LIST_HEAD (>t->list);return >t->ttm.ttm; }drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1
-0@@ -69,6 +69,7 @@ extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;bool amdgpu_gtt_mgr_has_gart_addr (struct ttm_mem_reg *mem);uint64_t amdgpu_gtt_mgr_usage (struct ttm_mem_type_manager *man); +int amdgpu_gtt_mgr_recover (struct ttm_mem_type_manager *man);uint64_t amdgpu_vram_mgr_usage (struct ttm_mem_type_manager *man);uint64_t amdgpu_vram_mgr_vis_usage (struct ttm_mem_type_manager *man);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h int amdgpu_fill_buffer(struct amdgpu_bo *bo, · line 98
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1
-1@@ -91,7 +92,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma);int amdgpu_ttm_bind (struct ttm_buffer_object *bo); -int amdgpu_ttm_recover_gart (struct amdgpu_device *adev); +int amdgpu_ttm_recover_gart (struct ttm_buffer_object *tbo);int amdgpu_ttm_tt_get_user_pages (struct ttm_tt *ttm,struct page **pages);void amdgpu_ttm_tt_set_user_pages (struct ttm_tt *ttm,struct page **pages);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/5 drm/amdgpu: rename amdgpu_ttm_bind to amdgpu_ttm_alloc_gart
In reply to a message not in the archiveFrom: Christian König <[email protected]>
We actually don't bind here, but rather allocate GART space if necessary.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -2
@@ -681,7 +681,7 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,if (!r && p->uf_entry.robj) {struct amdgpu_bo *uf = p->uf_entry.robj; - r =amdgpu_ttm_bind (&uf->tbo); + r =amdgpu_ttm_alloc_gart (&uf->tbo); p->job->uf_addr +=amdgpu_bo_gpu_offset (uf); }
@@ -1596,5 +1596,5 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,return r; } -return amdgpu_ttm_bind (&(*bo)->tbo); +return amdgpu_ttm_alloc_gart (&(*bo)->tbo); }
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
@@ -688,7 +688,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, goto error; } - r =amdgpu_ttm_bind (&bo->tbo); + r =amdgpu_ttm_alloc_gart (&bo->tbo);if (unlikely (r)) {dev_err (adev->dev,"%p bind failed\n" , bo); goto error;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -2
@@ -875,7 +875,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,return r; } -int amdgpu_ttm_bind (struct ttm_buffer_object *bo) +int amdgpu_ttm_alloc_gart (struct ttm_buffer_object *bo) {struct amdgpu_device *adev =amdgpu_ttm_adev (bo->bdev);struct ttm_mem_reg tmp;
@@ -1605,7 +1605,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, }if (bo->tbo.mem.mem_type ==TTM_PL_TT ) { - r =amdgpu_ttm_bind (&bo->tbo); + r =amdgpu_ttm_alloc_gart (&bo->tbo);if (r)return r; }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -1
@@ -91,7 +91,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, struct dma_fence **fence);int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma); -int amdgpu_ttm_bind (struct ttm_buffer_object *bo); +int amdgpu_ttm_alloc_gart (struct ttm_buffer_object *bo);int amdgpu_ttm_recover_gart (struct ttm_buffer_object *tbo);int amdgpu_ttm_tt_get_user_pages (struct ttm_tt *ttm,struct page **pages);
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1509115410-2557-3-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Re: [PATCH 3/5] drm/amdgpu: rename amdgpu_ttm_bind to amdgpu_ttm_alloc_gart
Ping? Any objects or can I push this?
Asking because the next patch is desperately needed upstream.
Christian.
Am 27.10.2017 um 16:43 schrieb Christian König:
Quoted 72 lines
From: Christian König <[email protected]>
We actually don't bind here, but rather allocate GART space if necessary.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2
-2@@ -681,7 +681,7 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,if (!r && p->uf_entry.robj) {struct amdgpu_bo *uf = p->uf_entry.robj; - r =amdgpu_ttm_bind (&uf->tbo); + r =amdgpu_ttm_alloc_gart (&uf->tbo); p->job->uf_addr +=amdgpu_bo_gpu_offset (uf); }@@ -1596,5 +1596,5 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,return r; } -return amdgpu_ttm_bind (&(*bo)->tbo); +return amdgpu_ttm_alloc_gart (&(*bo)->tbo); }drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1
-1@@ -688,7 +688,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, goto error; } - r =amdgpu_ttm_bind (&bo->tbo); + r =amdgpu_ttm_alloc_gart (&bo->tbo);if (unlikely (r)) {dev_err (adev->dev,"%p bind failed\n" , bo); goto error;drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2
-2@@ -875,7 +875,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,return r; } -int amdgpu_ttm_bind (struct ttm_buffer_object *bo) +int amdgpu_ttm_alloc_gart (struct ttm_buffer_object *bo) {struct amdgpu_device *adev =amdgpu_ttm_adev (bo->bdev);struct ttm_mem_reg tmp;@@ -1605,7 +1605,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, }if (bo->tbo.mem.mem_type ==TTM_PL_TT ) { - r =amdgpu_ttm_bind (&bo->tbo); + r =amdgpu_ttm_alloc_gart (&bo->tbo);if (r)return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h int amdgpu_fill_buffer(struct amdgpu_bo *bo, · line 97
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1
-1@@ -91,7 +91,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, struct dma_fence **fence);int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma); -int amdgpu_ttm_bind (struct ttm_buffer_object *bo); +int amdgpu_ttm_alloc_gart (struct ttm_buffer_object *bo);int amdgpu_ttm_recover_gart (struct ttm_buffer_object *tbo);int amdgpu_ttm_tt_get_user_pages (struct ttm_tt *ttm,struct page **pages);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): fe91cd2e-d312-fbec-04c5-aefbe38eed24-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH 3/5] drm/amdgpu: rename amdgpu_ttm_bind to amdgpu_ttm_alloc_gart
I'm not sue if it's properly, and have no strong opinion, Alex or others can have a look.
发自坚果 Pro
Christian K鰊ig <[email protected]> 于 2017年11月2日 下午8:19写道:
Ping? Any objects or can I push this?
Asking because the next patch is desperately needed upstream.
Christian.
Am 27.10.2017 um 16:43 schrieb Christian König:
Quoted 72 lines
From: Christian König <[email protected]>
We actually don't bind here, but rather allocate GART space if necessary.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2
-2@@ -681,7 +681,7 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,if (!r && p->uf_entry.robj) {struct amdgpu_bo *uf = p->uf_entry.robj; - r =amdgpu_ttm_bind (&uf->tbo); + r =amdgpu_ttm_alloc_gart (&uf->tbo); p->job->uf_addr +=amdgpu_bo_gpu_offset (uf); }@@ -1596,5 +1596,5 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,return r; } -return amdgpu_ttm_bind (&(*bo)->tbo); +return amdgpu_ttm_alloc_gart (&(*bo)->tbo); }drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1
-1@@ -688,7 +688,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, goto error; } - r =amdgpu_ttm_bind (&bo->tbo); + r =amdgpu_ttm_alloc_gart (&bo->tbo);if (unlikely (r)) {dev_err (adev->dev,"%p bind failed\n" , bo); goto error;drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2
-2@@ -875,7 +875,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,return r; } -int amdgpu_ttm_bind (struct ttm_buffer_object *bo) +int amdgpu_ttm_alloc_gart (struct ttm_buffer_object *bo) {struct amdgpu_device *adev =amdgpu_ttm_adev (bo->bdev);struct ttm_mem_reg tmp;@@ -1605,7 +1605,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, }if (bo->tbo.mem.mem_type ==TTM_PL_TT ) { - r =amdgpu_ttm_bind (&bo->tbo); + r =amdgpu_ttm_alloc_gart (&bo->tbo);if (r)return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h int amdgpu_fill_buffer(struct amdgpu_bo *bo, · line 97
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1
-1@@ -91,7 +91,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, struct dma_fence **fence);int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma); -int amdgpu_ttm_bind (struct ttm_buffer_object *bo); +int amdgpu_ttm_alloc_gart (struct ttm_buffer_object *bo);int amdgpu_ttm_recover_gart (struct ttm_buffer_object *tbo);int amdgpu_ttm_tt_get_user_pages (struct ttm_tt *ttm,struct page **pages);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
Reviewed-byRe: [PATCH 3/5] drm/amdgpu: rename amdgpu_ttm_bind to amdgpu_ttm_alloc_gart
In reply to a message not in the archiveQuoted 5 lines · Christian König
From: Christian König <[email protected]>
We actually don't bind here, but rather allocate GART space if necessary.
Signed-off-by Christian König <[email protected]>
Definitely makes things clearer in my opinion.
Quoted 78 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2
-2@@ -681,7 +681,7 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,if (!r && p->uf_entry.robj) {struct amdgpu_bo *uf = p->uf_entry.robj; - r =amdgpu_ttm_bind (&uf->tbo); + r =amdgpu_ttm_alloc_gart (&uf->tbo); p->job->uf_addr +=amdgpu_bo_gpu_offset (uf); }@@ -1596,5 +1596,5 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,return r; } -return amdgpu_ttm_bind (&(*bo)->tbo); +return amdgpu_ttm_alloc_gart (&(*bo)->tbo); }drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1
-1@@ -688,7 +688,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, goto error; } - r =amdgpu_ttm_bind (&bo->tbo); + r =amdgpu_ttm_alloc_gart (&bo->tbo);if (unlikely (r)) {dev_err (adev->dev,"%p bind failed\n" , bo); goto error;drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2
-2@@ -875,7 +875,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,return r; } -int amdgpu_ttm_bind (struct ttm_buffer_object *bo) +int amdgpu_ttm_alloc_gart (struct ttm_buffer_object *bo) {struct amdgpu_device *adev =amdgpu_ttm_adev (bo->bdev);struct ttm_mem_reg tmp;@@ -1605,7 +1605,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, }if (bo->tbo.mem.mem_type ==TTM_PL_TT ) { - r =amdgpu_ttm_bind (&bo->tbo); + r =amdgpu_ttm_alloc_gart (&bo->tbo);if (r)return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1
-2@@ -91,7 +91,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, struct dma_fence **fence);int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma); -int amdgpu_ttm_bind (struct ttm_buffer_object *bo); +int amdgpu_ttm_alloc_gart (struct ttm_buffer_object *bo);int amdgpu_ttm_recover_gart (struct ttm_buffer_object *tbo);int amdgpu_ttm_tt_get_user_pages (struct ttm_tt *ttm,struct page **pages); --2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/5 drm/amdgpu: don't use ttm_bo_move_ttm in amdgpu_ttm_bind v2
In reply to a message not in the archiveFrom: Christian König <[email protected]>
Just allocate the GART space and fill it.
This prevents forcing the BO to be idle.
v2: don't unbind/bind at all, just fill the allocated GART space
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +15 -6
@@ -878,10 +878,12 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,int amdgpu_ttm_alloc_gart (struct ttm_buffer_object *bo) {struct amdgpu_device *adev =amdgpu_ttm_adev (bo->bdev); +struct amdgpu_ttm_tt *gtt = (void *)bo->ttm;struct ttm_mem_reg tmp;struct ttm_placement placement;struct ttm_place placements; +uint64_t flags;int r; if (bo->mem.mem_type != TTM_PL_TT ||
@@ -903,14 +905,21 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)if (unlikely (r))return r; - r =ttm_bo_move_ttm (bo, true, false, &tmp); -if (unlikely (r)) + flags =amdgpu_ttm_tt_pte_flags (adev, bo->ttm, &tmp); + gtt->offset = (u64 )tmp.start <<PAGE_SHIFT ; + r =amdgpu_gart_bind (adev, gtt->offset, bo->ttm->num_pages, + bo->ttm->pages, gtt->ttm.dma_address, flags); +if (unlikely (r)) {ttm_bo_mem_put (bo, &tmp); -else - bo->offset = (bo->mem.start <<PAGE_SHIFT ) + - bo->bdev->man[bo->mem.mem_type].gpu_offset; +return r; + } -return r; +ttm_bo_mem_put (bo, &bo->mem); + bo->mem = tmp; + bo->offset = (bo->mem.start <<PAGE_SHIFT ) + + bo->bdev->man[bo->mem.mem_type].gpu_offset; + +return 0 ; }int amdgpu_ttm_recover_gart (struct ttm_buffer_object *tbo)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1509115410-2557-4-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Re: [PATCH 4/5] drm/amdgpu: don't use ttm_bo_move_ttm in amdgpu_ttm_bind v2
Quoted 7 lines · Christian König
From: Christian König <[email protected]>
Just allocate the GART space and fill it.
This prevents forcing the BO to be idle.
v2: don't unbind/bind at all, just fill the allocated GART space
Could you explain what 'unbind/bind' is? My old understanding is 'bind' is to filling gart space, isn't it?
one comment in line...
Quoted 33 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +6
-2@@ -878,10 +878,12 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,int amdgpu_ttm_alloc_gart (struct ttm_buffer_object *bo) {struct amdgpu_device *adev =amdgpu_ttm_adev (bo->bdev); +struct amdgpu_ttm_tt *gtt = (void *)bo->ttm;struct ttm_mem_reg tmp;struct ttm_placement placement;struct ttm_place placements; +uint64_t flags;int r; if (bo->mem.mem_type != TTM_PL_TT ||@@ -903,14 +905,21 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)if (unlikely (r))return r; - r =ttm_bo_move_ttm (bo, true, false, &tmp); -if (unlikely (r)) + flags =amdgpu_ttm_tt_pte_flags (adev, bo->ttm, &tmp); + gtt->offset = (u64 )tmp.start <<PAGE_SHIFT ; + r =amdgpu_gart_bind (adev, gtt->offset, bo->ttm->num_pages, + bo->ttm->pages, gtt->ttm.dma_address, flags);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo) · line 917
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4
-4+if (unlikely (r)) {ttm_bo_mem_put (bo, &tmp); - else - bo->offset = (bo->mem.start << PAGE_SHIFT) + - bo->bdev->man[bo->mem.mem_type].gpu_offset; +return r; + } -return r; +ttm_bo_mem_put (bo, &bo->mem);
The old node doesn't need to wait before put it? if another user allocate in same place immediately, doesn't it result in problem?
Regards,
David Zhou
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo) · line 925
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5
-0+ bo->mem = tmp; + bo->offset = (bo->mem.start <<PAGE_SHIFT ) + + bo->bdev->man[bo->mem.mem_type].gpu_offset; + +return 0 ; }int amdgpu_ttm_recover_gart (struct ttm_buffer_object *tbo)
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 58469022-bcbe-91af-05ad-aef18e98d99e-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 4/5] drm/amdgpu: don't use ttm_bo_move_ttm in amdgpu_ttm_bind v2
Am 30.10.2017 um 04:25 schrieb Chunming Zhou:
Quoted 11 lines · Christian König
Quoted 7 lines
From: Christian König <[email protected]>
Just allocate the GART space and fill it.
This prevents forcing the BO to be idle.
v2: don't unbind/bind at all, just fill the allocated GART space
Could you explain what 'unbind/bind' is? My old understanding is 'bind' is to filling gart space, isn't it?
Bind means that TTM is telling us that a ttm_tt (which represent a bunch of system pages) is going to be used by the GPU.
Mapping the TTM to GART space is just one thing we could do during that callback, but that is purely optional.
Quoted 36 lines
one comment in line...
Quoted 34 lines
Signed-off-by Christian König <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c| 21 +++++++++++++++------1 file changed, 15 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2
-0@@ -878,10 +878,12 @@ static int amdgpu_ttm_backend_bind(structttm_tt *ttm, int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo) { struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); + struct amdgpu_ttm_tt *gtt = (void*)bo->ttm; struct ttm_mem_reg tmp; struct ttm_placement placement; struct ttm_place placements; + uint64_t flags; int r;if (
bo->mem.mem_type!=TTM_PL_TT||drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5
-1@@ -903,14 +905,21 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo) if (unlikely(r)) return r; - r = ttm_bo_move_ttm(bo, true, false, &tmp); - if (unlikely(r)) + flags = amdgpu_ttm_tt_pte_flags(adev, bo->ttm, &tmp); + gtt->offset = (u64)tmp.start << PAGE_SHIFT; + r = amdgpu_gart_bind(adev, gtt->offset, bo->ttm->num_pages, + bo->ttm->pages, gtt->ttm.dma_address, flags); + if (unlikely(r)) { ttm_bo_mem_put(bo, &tmp);
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo) · line 917
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3
-3- else - bo->offset = (bo->mem.start << PAGE_SHIFT) + - bo->bdev->man[bo->mem.mem_type].gpu_offset; + return r; + } - return r; + ttm_bo_mem_put(bo, &bo->mem);The old node doesn't need to wait before put it? if another user allocate in same place immediately, doesn't it result in problem?
Good point, but no that isn't a problem.
When we go into this branch we know that the old node didn't had any GART space allocated to it, so we don't need to wait for anything using this GART space.
Regards,
Christian.
Quoted 11 lines
Regards,
David Zhoudrivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo) · line 925
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5
-0+ bo->mem = tmp; + bo->offset = (bo->mem.start << PAGE_SHIFT) + + bo->bdev->man[bo->mem.mem_type].gpu_offset; + + return 0; } int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/5 drm/amdgpu: allow framebuffer in GART memory as well
In reply to a message not in the archiveFrom: Christian König <[email protected]>
On CZ and newer APUs we can pin the fb into GART as well as VRAM.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 13 ++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_display.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 10 ++++++---- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 16 +++++++++++----- 4 files changed, 30 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +12 -1
@@ -29,6 +29,7 @@#include "amdgpu_i2c.h" #include "atom.h" #include "amdgpu_connectors.h" +#include "amdgpu_display.h" #include <asm/div64.h> #include <linux/pm_runtime.h>
@@ -188,7 +189,7 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc, goto cleanup; } - r =amdgpu_bo_pin (new_abo,AMDGPU_GEM_DOMAIN_VRAM , &base); + r =amdgpu_bo_pin (new_abo,amdgpu_framebuffer_domains (adev), &base);if (unlikely (r !=0 )) {DRM_ERROR ("failed to pin new abo buffer before flip\n" ); goto unreserve;
@@ -501,6 +502,16 @@ static const struct drm_framebuffer_funcs amdgpu_fb_funcs = { .create_handle = amdgpu_user_framebuffer_create_handle, }; +uint32_t amdgpu_framebuffer_domains (struct amdgpu_device *adev) +{ +uint32_t domain =AMDGPU_GEM_DOMAIN_VRAM ; + +if (adev->asic_type >=CHIP_CARRIZO && adev->flags &AMD_IS_APU ) + domain |=AMDGPU_GEM_DOMAIN_GTT ; + +return domain; +} + int amdgpu_framebuffer_init(struct drm_device *dev, struct amdgpu_framebuffer *rfb,
drivers/gpu/drm/amd/amdgpu/amdgpu_display.h +1 -0
@@ -23,6 +23,7 @@#ifndef __AMDGPU_DISPLAY_H__#define __AMDGPU_DISPLAY_H__ +uint32_t amdgpu_framebuffer_domains (struct amdgpu_device *adev);struct drm_framebuffer * amdgpu_user_framebuffer_create(struct drm_device *dev, struct drm_file *file_priv,
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +6 -4
@@ -38,6 +38,8 @@#include <linux/vga_switcheroo.h> +#include "amdgpu_display.h" +/* object hierarchy - this contains a helper + a amdgpu fb the helper contains a pointer to amdgpu framebuffer baseclass.
@@ -124,7 +126,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,struct drm_gem_object *gobj =NULL ;struct amdgpu_bo *abo =NULL ;bool fb_tiled = false;/* useful for testing */ -u32 tiling_flags =0 ; +u32 tiling_flags =0 , domain;int ret;int aligned_size, size;int height = mode_cmd->height;
@@ -135,12 +137,12 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,/* need to align pitch with crtc limits */ mode_cmd->pitches[0 ] =amdgpu_align_pitch (adev, mode_cmd->width, cpp, fb_tiled); + domain =amdgpu_framebuffer_domains (adev); height =ALIGN (mode_cmd->height,8 ); size = mode_cmd->pitches[0 ] * height; aligned_size =ALIGN (size,PAGE_SIZE ); - ret = amdgpu_gem_object_create(adev, aligned_size, 0, - AMDGPU_GEM_DOMAIN_VRAM, + ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain, AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | AMDGPU_GEM_CREATE_VRAM_CLEARED,
@@ -166,7 +168,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev, } - ret =amdgpu_bo_pin (abo,AMDGPU_GEM_DOMAIN_VRAM ,NULL ); + ret =amdgpu_bo_pin (abo, domain,NULL );if (ret) {amdgpu_bo_unreserve (abo); goto out_unref;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +11 -5
@@ -2934,13 +2934,15 @@ static const struct drm_plane_funcs dm_plane_funcs = {static int dm_plane_helper_prepare_fb (struct drm_plane *plane,struct drm_plane_state *new_state) { +struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old;struct amdgpu_framebuffer *afb;struct drm_gem_object *obj; +struct amdgpu_device *adev;struct amdgpu_bo *rbo;uint64_t chroma_addr =0 ; -int r; -struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old;unsigned int awidth; +uint32_t domain; +int r; dm_plane_state_old =to_dm_plane_state (plane->state); dm_plane_state_new =to_dm_plane_state (new_state);
@@ -2954,17 +2956,21 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane, obj = afb->obj; rbo =gem_to_amdgpu_bo (obj); + adev =amdgpu_ttm_adev (rbo->tbo.bdev); r =amdgpu_bo_reserve (rbo, false);if (unlikely (r !=0 ))return r; - r =amdgpu_bo_pin (rbo,AMDGPU_GEM_DOMAIN_VRAM , &afb->address); - +if (plane->type !=DRM_PLANE_TYPE_CURSOR ) + domain =amdgpu_framebuffer_domains (adev); +else + domain =AMDGPU_GEM_DOMAIN_VRAM ; + r =amdgpu_bo_pin (rbo, domain, &afb->address);amdgpu_bo_unreserve (rbo);if (unlikely (r !=0 )) { -DRM_ERROR ("Failed to pin framebuffer\n" ); +DRM_ERROR ("Failed to pin framebuffer (%d)\n" , r);return r; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Chunming Zhou
Reviewed-byQuoted 8 lines · Christian König
From: Christian König <[email protected]>
Rename
amdgpu_gtt_mgr_is_allocated()toamdgpu_gtt_mgr_has_gart_addr()and use that instead.v2: rename the function as well.
Signed-off-by Christian König <[email protected]>
Quoted 157 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 24 +++++++++--------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 +-- 5 files changed, 15 insertions(+), 22 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +3
-3@@ -85,13 +85,13 @@ static int amdgpu_gtt_mgr_fini(struct ttm_mem_type_manager *man) }/** -* amdgpu_gtt_mgr_is_allocated - Check if mem has address space +* amdgpu_gtt_mgr_has_gart_addr - Check if mem has address space * * @mem: the mem object to check * * Check if a mem object has already address space allocated. */ -bool amdgpu_gtt_mgr_is_allocated (struct ttm_mem_reg *mem) +bool amdgpu_gtt_mgr_has_gart_addr (struct ttm_mem_reg *mem) {struct drm_mm_node *node = mem->mm_node;@@ -120,7 +120,7 @@ static int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man,unsigned long fpfn, lpfn;int r; -if (amdgpu_gtt_mgr_is_allocated (mem)) +if (amdgpu_gtt_mgr_has_gart_addr (mem))return 0 ;if (place)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1
-1@@ -982,7 +982,7 @@ u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo) {WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_SYSTEM );WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_TT && - !amdgpu_ttm_is_bound (bo->tbo.ttm)); + !amdgpu_gtt_mgr_has_gart_addr (&bo->tbo.mem));WARN_ON_ONCE (!ww_mutex_is_locked (&bo->tbo.resv->lock) && !bo->pin_count);WARN_ON_ONCE (bo->tbo.mem.start ==AMDGPU_BO_INVALID_OFFSET );drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +1
-1@@ -187,7 +187,7 @@ static inline u64 amdgpu_bo_mmap_offset(struct amdgpu_bo *bo)static inline bool amdgpu_bo_gpu_accessible (struct amdgpu_bo *bo) {switch (bo->tbo.mem.mem_type) { -case TTM_PL_TT :return amdgpu_ttm_is_bound (bo->tbo.ttm); +case TTM_PL_TT :return amdgpu_gtt_mgr_has_gart_addr (&bo->tbo.mem);case TTM_PL_VRAM :return true;default :return false; }drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +9
-15@@ -282,8 +282,7 @@ static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo, {uint64_t addr =0 ; -if (mem->mem_type !=TTM_PL_TT || -amdgpu_gtt_mgr_is_allocated (mem)) { +if (mem->mem_type !=TTM_PL_TT ||amdgpu_gtt_mgr_has_gart_addr (mem)) { addr = mm_node->start <<PAGE_SHIFT ; addr += bo->bdev->man[mem->mem_type].gpu_offset; }@@ -369,7 +368,7 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,* dst to window 1 */ if (src->mem->mem_type ==TTM_PL_TT && - !amdgpu_gtt_mgr_is_allocated (src->mem)) { + !amdgpu_gtt_mgr_has_gart_addr (src->mem)) { r = amdgpu_map_buffer(src->bo, src->mem, PFN_UP(cur_size + src_page_offset), src_node_start, 0, ring,@@ -383,7 +382,7 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev, }if (dst->mem->mem_type ==TTM_PL_TT && - !amdgpu_gtt_mgr_is_allocated (dst->mem)) { + !amdgpu_gtt_mgr_has_gart_addr (dst->mem)) { r = amdgpu_map_buffer(dst->bo, dst->mem, PFN_UP(cur_size + dst_page_offset), dst_node_start, 1, ring,@@ -861,8 +860,10 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, bo_mem->mem_type == AMDGPU_PL_OA)return -EINVAL ; -if (!amdgpu_gtt_mgr_is_allocated (bo_mem)) +if (!amdgpu_gtt_mgr_has_gart_addr (bo_mem)) { + gtt->offset =AMDGPU_BO_INVALID_OFFSET ;return 0 ; + }spin_lock (>t->adev->gtt_list_lock); flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem);@@ -882,24 +883,17 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,return r; } -bool amdgpu_ttm_is_bound (struct ttm_tt *ttm) -{ -struct amdgpu_ttm_tt *gtt = (void *)ttm; - -return gtt && !list_empty (>t->list); -} -int amdgpu_ttm_bind (struct ttm_buffer_object *bo) {struct amdgpu_device *adev =amdgpu_ttm_adev (bo->bdev); -struct ttm_tt *ttm = bo->ttm;struct ttm_mem_reg tmp;struct ttm_placement placement;struct ttm_place placements;int r; -if (!ttm ||amdgpu_ttm_is_bound (ttm)) +if (bo->mem.mem_type !=TTM_PL_TT || +amdgpu_gtt_mgr_has_gart_addr (&bo->mem))return 0 ; tmp = bo->mem;@@ -960,7 +954,7 @@ static int amdgpu_ttm_backend_unbind(struct ttm_tt *ttm)if (gtt->userptr)amdgpu_ttm_tt_unpin_userptr (ttm); -if (!amdgpu_ttm_is_bound (ttm)) +if (gtt->offset ==AMDGPU_BO_INVALID_OFFSET )return 0 ;/* unbind shouldn't be done for GDS/GWS/OA in ttm_bo_clean_mm */ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1
-1@@ -67,7 +67,7 @@ struct amdgpu_copy_mem {extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func; -bool amdgpu_gtt_mgr_is_allocated (struct ttm_mem_reg *mem); +bool amdgpu_gtt_mgr_has_gart_addr (struct ttm_mem_reg *mem);uint64_t amdgpu_gtt_mgr_usage (struct ttm_mem_type_manager *man);uint64_t amdgpu_vram_mgr_usage (struct ttm_mem_type_manager *man);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h int amdgpu_fill_buffer(struct amdgpu_bo *bo, · line 95
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0
-1@@ -90,7 +90,6 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, struct dma_fence **fence);int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma); -bool amdgpu_ttm_is_bound (struct ttm_tt *ttm);int amdgpu_ttm_bind (struct ttm_buffer_object *bo);int amdgpu_ttm_recover_gart (struct amdgpu_device *adev);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx