Lines Matching refs:ttm
69 struct ttm_tt *ttm,
72 struct ttm_tt *ttm);
244 flags = amdgpu_ttm_tt_pte_flags(adev, bo->ttm, mem); in amdgpu_ttm_map_buffer()
253 dma_addr = &bo->ttm->dma_address[mm_cur->start >> PAGE_SHIFT]; in amdgpu_ttm_map_buffer()
497 r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem); in amdgpu_bo_move()
506 bo->ttm == NULL)) { in amdgpu_bo_move()
525 amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm); in amdgpu_bo_move()
673 struct ttm_tt ttm; member
683 #define ttm_to_amdgpu_ttm_tt(ptr) container_of(ptr, struct amdgpu_ttm_tt, ttm)
696 struct ttm_tt *ttm = bo->tbo.ttm; in amdgpu_ttm_tt_get_user_pages() local
697 struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(ttm); in amdgpu_ttm_tt_get_user_pages()
728 readonly = amdgpu_ttm_tt_is_readonly(ttm); in amdgpu_ttm_tt_get_user_pages()
729 r = amdgpu_hmm_range_get_pages(&bo->notifier, start, ttm->num_pages, in amdgpu_ttm_tt_get_user_pages()
743 void amdgpu_ttm_tt_discard_user_pages(struct ttm_tt *ttm, in amdgpu_ttm_tt_discard_user_pages() argument
746 struct amdgpu_ttm_tt *gtt = (void *)ttm; in amdgpu_ttm_tt_discard_user_pages()
758 bool amdgpu_ttm_tt_get_user_pages_done(struct ttm_tt *ttm, in amdgpu_ttm_tt_get_user_pages_done() argument
761 struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(ttm); in amdgpu_ttm_tt_get_user_pages_done()
767 gtt->userptr, ttm->num_pages); in amdgpu_ttm_tt_get_user_pages_done()
782 void amdgpu_ttm_tt_set_user_pages(struct ttm_tt *ttm, struct page **pages) in amdgpu_ttm_tt_set_user_pages() argument
786 for (i = 0; i < ttm->num_pages; ++i) in amdgpu_ttm_tt_set_user_pages()
787 ttm->pages[i] = pages ? pages[i] : NULL; in amdgpu_ttm_tt_set_user_pages()
796 struct ttm_tt *ttm) in amdgpu_ttm_tt_pin_userptr() argument
799 struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(ttm); in amdgpu_ttm_tt_pin_userptr()
806 r = sg_alloc_table_from_pages(ttm->sg, ttm->pages, ttm->num_pages, 0, in amdgpu_ttm_tt_pin_userptr()
807 (u64)ttm->num_pages << PAGE_SHIFT, in amdgpu_ttm_tt_pin_userptr()
813 r = dma_map_sgtable(adev->dev, ttm->sg, direction, 0); in amdgpu_ttm_tt_pin_userptr()
818 drm_prime_sg_to_dma_addr_array(ttm->sg, gtt->ttm.dma_address, in amdgpu_ttm_tt_pin_userptr()
819 ttm->num_pages); in amdgpu_ttm_tt_pin_userptr()
824 kfree(ttm->sg); in amdgpu_ttm_tt_pin_userptr()
825 ttm->sg = NULL; in amdgpu_ttm_tt_pin_userptr()
833 struct ttm_tt *ttm) in amdgpu_ttm_tt_unpin_userptr() argument
836 struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(ttm); in amdgpu_ttm_tt_unpin_userptr()
842 if (!ttm->sg || !ttm->sg->sgl) in amdgpu_ttm_tt_unpin_userptr()
846 dma_unmap_sgtable(adev->dev, ttm->sg, direction, 0); in amdgpu_ttm_tt_unpin_userptr()
847 sg_free_table(ttm->sg); in amdgpu_ttm_tt_unpin_userptr()
858 struct ttm_tt *ttm, uint64_t flags) in amdgpu_ttm_gart_bind_gfx9_mqd() argument
860 struct amdgpu_ttm_tt *gtt = (void *)ttm; in amdgpu_ttm_gart_bind_gfx9_mqd()
861 uint64_t total_pages = ttm->num_pages; in amdgpu_ttm_gart_bind_gfx9_mqd()
874 1, >t->ttm.dma_address[page_idx], flags); in amdgpu_ttm_gart_bind_gfx9_mqd()
882 >t->ttm.dma_address[page_idx + 1], in amdgpu_ttm_gart_bind_gfx9_mqd()
892 struct ttm_tt *ttm = tbo->ttm; in amdgpu_ttm_gart_bind() local
893 struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(ttm); in amdgpu_ttm_gart_bind()
899 amdgpu_ttm_gart_bind_gfx9_mqd(adev, ttm, flags); in amdgpu_ttm_gart_bind()
901 amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages, in amdgpu_ttm_gart_bind()
902 gtt->ttm.dma_address, flags); in amdgpu_ttm_gart_bind()
914 struct ttm_tt *ttm, in amdgpu_ttm_backend_bind() argument
918 struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(ttm); in amdgpu_ttm_backend_bind()
929 r = amdgpu_ttm_tt_pin_userptr(bdev, ttm); in amdgpu_ttm_backend_bind()
934 } else if (ttm->page_flags & TTM_TT_FLAG_EXTERNAL) { in amdgpu_ttm_backend_bind()
935 if (!ttm->sg) { in amdgpu_ttm_backend_bind()
944 ttm->sg = sgt; in amdgpu_ttm_backend_bind()
947 drm_prime_sg_to_dma_addr_array(ttm->sg, gtt->ttm.dma_address, in amdgpu_ttm_backend_bind()
948 ttm->num_pages); in amdgpu_ttm_backend_bind()
951 if (!ttm->num_pages) { in amdgpu_ttm_backend_bind()
953 ttm->num_pages, bo_mem, ttm); in amdgpu_ttm_backend_bind()
963 flags = amdgpu_ttm_tt_pte_flags(adev, ttm, bo_mem); in amdgpu_ttm_backend_bind()
967 amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages, in amdgpu_ttm_backend_bind()
968 gtt->ttm.dma_address, flags); in amdgpu_ttm_backend_bind()
985 struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(bo->ttm); in amdgpu_ttm_alloc_gart()
1012 flags = amdgpu_ttm_tt_pte_flags(adev, bo->ttm, tmp); in amdgpu_ttm_alloc_gart()
1035 if (!tbo->ttm) in amdgpu_ttm_recover_gart()
1038 flags = amdgpu_ttm_tt_pte_flags(adev, tbo->ttm, tbo->resource); in amdgpu_ttm_recover_gart()
1049 struct ttm_tt *ttm) in amdgpu_ttm_backend_unbind() argument
1052 struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(ttm); in amdgpu_ttm_backend_unbind()
1056 amdgpu_ttm_tt_unpin_userptr(bdev, ttm); in amdgpu_ttm_backend_unbind()
1057 } else if (ttm->sg && gtt->gobj->import_attach) { in amdgpu_ttm_backend_unbind()
1061 dma_buf_unmap_attachment(attach, ttm->sg, DMA_BIDIRECTIONAL); in amdgpu_ttm_backend_unbind()
1062 ttm->sg = NULL; in amdgpu_ttm_backend_unbind()
1072 amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages); in amdgpu_ttm_backend_unbind()
1077 struct ttm_tt *ttm) in amdgpu_ttm_backend_destroy() argument
1079 struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(ttm); in amdgpu_ttm_backend_destroy()
1084 ttm_tt_fini(>t->ttm); in amdgpu_ttm_backend_destroy()
1120 if (ttm_sg_tt_init(>t->ttm, bo, page_flags, caching)) { in amdgpu_ttm_tt_create()
1124 return >t->ttm; in amdgpu_ttm_tt_create()
1134 struct ttm_tt *ttm, in amdgpu_ttm_tt_populate() argument
1138 struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(ttm); in amdgpu_ttm_tt_populate()
1145 ttm->sg = kzalloc(sizeof(struct sg_table), GFP_KERNEL); in amdgpu_ttm_tt_populate()
1146 if (!ttm->sg) in amdgpu_ttm_tt_populate()
1151 if (ttm->page_flags & TTM_TT_FLAG_EXTERNAL) in amdgpu_ttm_tt_populate()
1158 ret = ttm_pool_alloc(pool, ttm, ctx); in amdgpu_ttm_tt_populate()
1162 for (i = 0; i < ttm->num_pages; ++i) in amdgpu_ttm_tt_populate()
1163 ttm->pages[i]->mapping = bdev->dev_mapping; in amdgpu_ttm_tt_populate()
1175 struct ttm_tt *ttm) in amdgpu_ttm_tt_unpopulate() argument
1177 struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(ttm); in amdgpu_ttm_tt_unpopulate()
1182 amdgpu_ttm_backend_unbind(bdev, ttm); in amdgpu_ttm_tt_unpopulate()
1185 amdgpu_ttm_tt_set_user_pages(ttm, NULL); in amdgpu_ttm_tt_unpopulate()
1186 kfree(ttm->sg); in amdgpu_ttm_tt_unpopulate()
1187 ttm->sg = NULL; in amdgpu_ttm_tt_unpopulate()
1191 if (ttm->page_flags & TTM_TT_FLAG_EXTERNAL) in amdgpu_ttm_tt_unpopulate()
1194 for (i = 0; i < ttm->num_pages; ++i) in amdgpu_ttm_tt_unpopulate()
1195 ttm->pages[i]->mapping = NULL; in amdgpu_ttm_tt_unpopulate()
1204 return ttm_pool_free(pool, ttm); in amdgpu_ttm_tt_unpopulate()
1219 if (!tbo->ttm) in amdgpu_ttm_tt_get_userptr()
1222 gtt = (void *)tbo->ttm; in amdgpu_ttm_tt_get_userptr()
1244 if (!bo->ttm) { in amdgpu_ttm_tt_set_userptr()
1246 bo->ttm = amdgpu_ttm_tt_create(bo, 0); in amdgpu_ttm_tt_set_userptr()
1247 if (bo->ttm == NULL) in amdgpu_ttm_tt_set_userptr()
1252 bo->ttm->page_flags |= TTM_TT_FLAG_EXTERNAL; in amdgpu_ttm_tt_set_userptr()
1254 gtt = ttm_to_amdgpu_ttm_tt(bo->ttm); in amdgpu_ttm_tt_set_userptr()
1269 struct mm_struct *amdgpu_ttm_tt_get_usermm(struct ttm_tt *ttm) in amdgpu_ttm_tt_get_usermm() argument
1271 struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(ttm); in amdgpu_ttm_tt_get_usermm()
1287 bool amdgpu_ttm_tt_affect_userptr(struct ttm_tt *ttm, unsigned long start, in amdgpu_ttm_tt_affect_userptr() argument
1290 struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(ttm); in amdgpu_ttm_tt_affect_userptr()
1299 size = (unsigned long)gtt->ttm.num_pages * PAGE_SIZE; in amdgpu_ttm_tt_affect_userptr()
1311 bool amdgpu_ttm_tt_is_userptr(struct ttm_tt *ttm) in amdgpu_ttm_tt_is_userptr() argument
1313 struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(ttm); in amdgpu_ttm_tt_is_userptr()
1324 bool amdgpu_ttm_tt_is_readonly(struct ttm_tt *ttm) in amdgpu_ttm_tt_is_readonly() argument
1326 struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(ttm); in amdgpu_ttm_tt_is_readonly()
1342 uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_resource *mem) in amdgpu_ttm_tt_pde_flags() argument
1354 if (ttm->caching == ttm_cached) in amdgpu_ttm_tt_pde_flags()
1374 uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm, in amdgpu_ttm_tt_pte_flags() argument
1377 uint64_t flags = amdgpu_ttm_tt_pde_flags(ttm, mem); in amdgpu_ttm_tt_pte_flags()
1382 if (!amdgpu_ttm_tt_is_readonly(ttm)) in amdgpu_ttm_tt_pte_flags()