Lines Matching refs:bo

42 	struct ttm_buffer_object *bo;  member
142 int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, in ttm_bo_move_memcpy() argument
146 struct ttm_device *bdev = bo->bdev; in ttm_bo_move_memcpy()
148 ttm_manager_type(bo->bdev, dst_mem->mem_type); in ttm_bo_move_memcpy()
149 struct ttm_tt *ttm = bo->ttm; in ttm_bo_move_memcpy()
150 struct ttm_resource *src_mem = bo->resource; in ttm_bo_move_memcpy()
173 dst_iter = ttm_kmap_iter_tt_init(&_dst_iter.tt, bo->ttm); in ttm_bo_move_memcpy()
179 src_iter = ttm_kmap_iter_tt_init(&_src_iter.tt, bo->ttm); in ttm_bo_move_memcpy()
191 ttm_bo_move_sync_cleanup(bo, dst_mem); in ttm_bo_move_memcpy()
201 static void ttm_transfered_destroy(struct ttm_buffer_object *bo) in ttm_transfered_destroy() argument
205 fbo = container_of(bo, struct ttm_transfer_obj, base); in ttm_transfered_destroy()
207 ttm_bo_put(fbo->bo); in ttm_transfered_destroy()
226 static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo, in ttm_buffer_object_transfer() argument
236 fbo->base = *bo; in ttm_buffer_object_transfer()
249 if (bo->type != ttm_bo_type_sg) in ttm_buffer_object_transfer()
259 bo->resource = NULL; in ttm_buffer_object_transfer()
271 ttm_bo_get(bo); in ttm_buffer_object_transfer()
272 fbo->bo = bo; in ttm_buffer_object_transfer()
290 pgprot_t ttm_io_prot(struct ttm_buffer_object *bo, struct ttm_resource *res, in ttm_io_prot() argument
296 man = ttm_manager_type(bo->bdev, res->mem_type); in ttm_io_prot()
297 caching = man->use_tt ? bo->ttm->caching : res->bus.caching; in ttm_io_prot()
303 static int ttm_bo_ioremap(struct ttm_buffer_object *bo, in ttm_bo_ioremap() argument
308 struct ttm_resource *mem = bo->resource; in ttm_bo_ioremap()
310 if (bo->resource->bus.addr) { in ttm_bo_ioremap()
312 map->virtual = ((u8 *)bo->resource->bus.addr) + offset; in ttm_bo_ioremap()
314 resource_size_t res = bo->resource->bus.offset + offset; in ttm_bo_ioremap()
329 static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo, in ttm_bo_kmap_ttm() argument
334 struct ttm_resource *mem = bo->resource; in ttm_bo_kmap_ttm()
339 struct ttm_tt *ttm = bo->ttm; in ttm_bo_kmap_ttm()
345 ret = ttm_tt_populate(bo->bdev, ttm, &ctx); in ttm_bo_kmap_ttm()
363 prot = ttm_io_prot(bo, mem, PAGE_KERNEL); in ttm_bo_kmap_ttm()
387 int ttm_bo_kmap(struct ttm_buffer_object *bo, in ttm_bo_kmap() argument
395 map->bo = bo; in ttm_bo_kmap()
396 if (num_pages > PFN_UP(bo->resource->size)) in ttm_bo_kmap()
398 if ((start_page + num_pages) > PFN_UP(bo->resource->size)) in ttm_bo_kmap()
401 ret = ttm_mem_io_reserve(bo->bdev, bo->resource); in ttm_bo_kmap()
404 if (!bo->resource->bus.is_iomem) { in ttm_bo_kmap()
405 return ttm_bo_kmap_ttm(bo, start_page, num_pages, map); in ttm_bo_kmap()
409 return ttm_bo_ioremap(bo, offset, size, map); in ttm_bo_kmap()
440 ttm_mem_io_free(map->bo->bdev, map->bo->resource); in ttm_bo_kunmap()
460 int ttm_bo_vmap(struct ttm_buffer_object *bo, struct iosys_map *map) in ttm_bo_vmap() argument
462 struct ttm_resource *mem = bo->resource; in ttm_bo_vmap()
465 dma_resv_assert_held(bo->base.resv); in ttm_bo_vmap()
467 ret = ttm_mem_io_reserve(bo->bdev, mem); in ttm_bo_vmap()
478 bo->base.size); in ttm_bo_vmap()
482 bo->base.size); in ttm_bo_vmap()
485 vaddr_iomem = ioremap(mem->bus.offset, bo->base.size); in ttm_bo_vmap()
497 struct ttm_tt *ttm = bo->ttm; in ttm_bo_vmap()
501 ret = ttm_tt_populate(bo->bdev, ttm, &ctx); in ttm_bo_vmap()
509 prot = ttm_io_prot(bo, mem, PAGE_KERNEL); in ttm_bo_vmap()
529 void ttm_bo_vunmap(struct ttm_buffer_object *bo, struct iosys_map *map) in ttm_bo_vunmap() argument
531 struct ttm_resource *mem = bo->resource; in ttm_bo_vunmap()
533 dma_resv_assert_held(bo->base.resv); in ttm_bo_vunmap()
544 ttm_mem_io_free(bo->bdev, bo->resource); in ttm_bo_vunmap()
548 static int ttm_bo_wait_free_node(struct ttm_buffer_object *bo, in ttm_bo_wait_free_node() argument
553 ret = dma_resv_wait_timeout(bo->base.resv, DMA_RESV_USAGE_BOOKKEEP, in ttm_bo_wait_free_node()
561 ttm_bo_tt_destroy(bo); in ttm_bo_wait_free_node()
562 ttm_resource_free(bo, &bo->resource); in ttm_bo_wait_free_node()
566 static int ttm_bo_move_to_ghost(struct ttm_buffer_object *bo, in ttm_bo_move_to_ghost() argument
581 ret = ttm_buffer_object_transfer(bo, &ghost_obj); in ttm_bo_move_to_ghost()
597 bo->ttm = NULL; in ttm_bo_move_to_ghost()
604 static void ttm_bo_move_pipeline_evict(struct ttm_buffer_object *bo, in ttm_bo_move_pipeline_evict() argument
607 struct ttm_device *bdev = bo->bdev; in ttm_bo_move_pipeline_evict()
610 from = ttm_manager_type(bdev, bo->resource->mem_type); in ttm_bo_move_pipeline_evict()
623 ttm_resource_free(bo, &bo->resource); in ttm_bo_move_pipeline_evict()
642 int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo, in ttm_bo_move_accel_cleanup() argument
648 struct ttm_device *bdev = bo->bdev; in ttm_bo_move_accel_cleanup()
649 struct ttm_resource_manager *from = ttm_manager_type(bdev, bo->resource->mem_type); in ttm_bo_move_accel_cleanup()
653 dma_resv_add_fence(bo->base.resv, fence, DMA_RESV_USAGE_KERNEL); in ttm_bo_move_accel_cleanup()
655 ret = ttm_bo_move_to_ghost(bo, fence, man->use_tt); in ttm_bo_move_accel_cleanup()
657 ttm_bo_move_pipeline_evict(bo, fence); in ttm_bo_move_accel_cleanup()
659 ret = ttm_bo_wait_free_node(bo, man->use_tt); in ttm_bo_move_accel_cleanup()
664 ttm_bo_assign_mem(bo, new_mem); in ttm_bo_move_accel_cleanup()
679 void ttm_bo_move_sync_cleanup(struct ttm_buffer_object *bo, in ttm_bo_move_sync_cleanup() argument
682 struct ttm_device *bdev = bo->bdev; in ttm_bo_move_sync_cleanup()
686 ret = ttm_bo_wait_free_node(bo, man->use_tt); in ttm_bo_move_sync_cleanup()
690 ttm_bo_assign_mem(bo, new_mem); in ttm_bo_move_sync_cleanup()
705 int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo) in ttm_bo_pipeline_gutting() argument
713 ret = ttm_resource_alloc(bo, &sys_mem, &sys_res); in ttm_bo_pipeline_gutting()
718 if (dma_resv_test_signaled(bo->base.resv, DMA_RESV_USAGE_BOOKKEEP)) { in ttm_bo_pipeline_gutting()
719 if (!bo->ttm) { in ttm_bo_pipeline_gutting()
721 ret = ttm_tt_create(bo, true); in ttm_bo_pipeline_gutting()
725 ttm_tt_unpopulate(bo->bdev, bo->ttm); in ttm_bo_pipeline_gutting()
726 if (bo->type == ttm_bo_type_device) in ttm_bo_pipeline_gutting()
727 ttm_tt_mark_for_clear(bo->ttm); in ttm_bo_pipeline_gutting()
729 ttm_resource_free(bo, &bo->resource); in ttm_bo_pipeline_gutting()
730 ttm_bo_assign_mem(bo, sys_res); in ttm_bo_pipeline_gutting()
742 ttm = bo->ttm; in ttm_bo_pipeline_gutting()
743 bo->ttm = NULL; in ttm_bo_pipeline_gutting()
744 ret = ttm_tt_create(bo, true); in ttm_bo_pipeline_gutting()
745 swap(bo->ttm, ttm); in ttm_bo_pipeline_gutting()
749 ret = ttm_buffer_object_transfer(bo, &ghost); in ttm_bo_pipeline_gutting()
753 ret = dma_resv_copy_fences(&ghost->base._resv, bo->base.resv); in ttm_bo_pipeline_gutting()
756 dma_resv_wait_timeout(bo->base.resv, DMA_RESV_USAGE_BOOKKEEP, in ttm_bo_pipeline_gutting()
762 bo->ttm = ttm; in ttm_bo_pipeline_gutting()
763 ttm_bo_assign_mem(bo, sys_res); in ttm_bo_pipeline_gutting()
767 ttm_tt_destroy(bo->bdev, ttm); in ttm_bo_pipeline_gutting()
770 ttm_resource_free(bo, &sys_res); in ttm_bo_pipeline_gutting()