drm/amdgpu: Modify alloc_sgt apis to consider size of request
Subsystems (2)
PATCH 1/1 drm/amdgpu: Modify alloc_sgt apis to consider size of request
The current method that builds SG table does not allow its users to request a sub-block of the buffer object. The change modifies api signature to allow users to specify both the offset and size of the request.
Signed-off-by Ramesh Errabolu <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 11 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 8 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 9 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 245 +++++++++++++++---- 4 files changed, 210 insertions(+), 63 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +3 -8
@@ -326,8 +326,8 @@ static struct sg_table *amdgpu_dma_buf_map(struct dma_buf_attachment *attach,break ;case TTM_PL_VRAM : - r =amdgpu_vram_mgr_alloc_sgt (adev, &bo->tbo.mem, attach->dev, - dir, &sgt); + r =amdgpu_vram_mgr_alloc_sgt (adev, &bo->tbo.mem,0 ,0 , + attach->dev, dir, &sgt);if (r)return ERR_PTR (r);break ;
@@ -356,17 +356,12 @@ static void amdgpu_dma_buf_unmap(struct dma_buf_attachment *attach, struct sg_table *sgt, enum dma_data_direction dir) { -struct dma_buf *dma_buf = attach->dmabuf; -struct drm_gem_object *obj = dma_buf->priv; -struct amdgpu_bo *bo =gem_to_amdgpu_bo (obj); -struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev); -if (sgt->sgl->page_link) {dma_unmap_sgtable (attach->dev, sgt, dir,0 );sg_free_table (sgt);kfree (sgt); }else { -amdgpu_vram_mgr_free_sgt (adev, attach->dev, dir, sgt); +amdgpu_vram_mgr_free_sgt (attach->dev, dir, sgt); } }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -4
@@ -222,8 +222,8 @@ static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo,* @offset: The offset that drm_mm_node is used for finding. * */ -static struct drm_mm_node *amdgpu_find_mm_node (struct ttm_resource *mem, -uint64_t *offset) +struct drm_mm_node *amdgpu_find_mm_node (struct ttm_resource *mem, +uint64_t *offset) {struct drm_mm_node *mm_node = mem->mm_node;
@@ -782,8 +782,8 @@ static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resoreturn 0 ; } -static unsigned long amdgpu_ttm_io_mem_pfn (struct ttm_buffer_object *bo, -unsigned long page_offset) +unsigned long amdgpu_ttm_io_mem_pfn (struct ttm_buffer_object *bo, +unsigned long page_offset) {uint64_t offset = (page_offset <<PAGE_SHIFT );struct drm_mm_node *mm;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +7 -2
@@ -116,11 +116,12 @@ int amdgpu_gtt_mgr_recover(struct ttm_resource_manager *man);u64 amdgpu_vram_mgr_bo_visible_size (struct amdgpu_bo *bo);int amdgpu_vram_mgr_alloc_sgt (struct amdgpu_device *adev,struct ttm_resource *mem, +uint64_t req_offset, +uint64_t req_size,struct device *dev,enum dma_data_direction dir,struct sg_table **sgt); -void amdgpu_vram_mgr_free_sgt (struct amdgpu_device *adev, -struct device *dev, +void amdgpu_vram_mgr_free_sgt (struct device *dev,enum dma_data_direction dir,struct sg_table *sgt);uint64_t amdgpu_vram_mgr_usage (struct ttm_resource_manager *man);
@@ -155,6 +156,10 @@ int amdgpu_mmap(struct file *filp, struct vm_area_struct *vma);int amdgpu_ttm_alloc_gart (struct ttm_buffer_object *bo);int amdgpu_ttm_recover_gart (struct ttm_buffer_object *tbo);uint64_t amdgpu_ttm_domain_start (struct amdgpu_device *adev,uint32_t type); +struct drm_mm_node *amdgpu_find_mm_node (struct ttm_resource *mem, +uint64_t *offset); +unsigned long amdgpu_ttm_io_mem_pfn (struct ttm_buffer_object *bo, +unsigned long page_offset);#if IS_ENABLED (CONFIG_DRM_AMDGPU_USERPTR )int amdgpu_ttm_tt_get_user_pages (struct amdgpu_bo *bo,struct page **pages);
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +196 -49
287 lines not on this page · raw message
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx