Commit 25893a14 authored by Christian König's avatar Christian König Committed by Alex Deucher

drm/ttm: add ttm_tt_populate wrapper

Stop calling the driver callback directly.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarRoger He <Hongbo.He@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent cc32ad8f
...@@ -375,8 +375,8 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, ...@@ -375,8 +375,8 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
/* /*
* TTM might be null for moves within the same region. * TTM might be null for moves within the same region.
*/ */
if (ttm && ttm->state == tt_unpopulated) { if (ttm) {
ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx); ret = ttm_tt_populate(ttm, ctx);
if (ret) if (ret)
goto out1; goto out1;
} }
...@@ -557,11 +557,9 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo, ...@@ -557,11 +557,9 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo,
BUG_ON(!ttm); BUG_ON(!ttm);
if (ttm->state == tt_unpopulated) { ret = ttm_tt_populate(ttm, &ctx);
ret = ttm->bdev->driver->ttm_tt_populate(ttm, &ctx);
if (ret) if (ret)
return ret; return ret;
}
if (num_pages == 1 && (mem->placement & TTM_PL_FLAG_CACHED)) { if (num_pages == 1 && (mem->placement & TTM_PL_FLAG_CACHED)) {
/* /*
......
...@@ -234,7 +234,7 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf) ...@@ -234,7 +234,7 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
cvma.vm_page_prot); cvma.vm_page_prot);
/* Allocate all page at once, most common usage */ /* Allocate all page at once, most common usage */
if (ttm->bdev->driver->ttm_tt_populate(ttm, &ctx)) { if (ttm_tt_populate(ttm, &ctx)) {
ret = VM_FAULT_OOM; ret = VM_FAULT_OOM;
goto out_io_unlock; goto out_io_unlock;
} }
......
...@@ -276,7 +276,7 @@ int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem, ...@@ -276,7 +276,7 @@ int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem,
if (ttm->state == tt_bound) if (ttm->state == tt_bound)
return 0; return 0;
ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx); ret = ttm_tt_populate(ttm, ctx);
if (ret) if (ret)
return ret; return ret;
...@@ -392,6 +392,14 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage) ...@@ -392,6 +392,14 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage)
return ret; return ret;
} }
int ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
{
if (ttm->state != tt_unpopulated)
return 0;
return ttm->bdev->driver->ttm_tt_populate(ttm, ctx);
}
static void ttm_tt_clear_mapping(struct ttm_tt *ttm) static void ttm_tt_clear_mapping(struct ttm_tt *ttm)
{ {
pgoff_t i; pgoff_t i;
......
...@@ -700,6 +700,15 @@ int ttm_tt_swapin(struct ttm_tt *ttm); ...@@ -700,6 +700,15 @@ int ttm_tt_swapin(struct ttm_tt *ttm);
int ttm_tt_set_placement_caching(struct ttm_tt *ttm, uint32_t placement); int ttm_tt_set_placement_caching(struct ttm_tt *ttm, uint32_t placement);
int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage); int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage);
/**
* ttm_tt_populate - allocate pages for a ttm
*
* @ttm: Pointer to the ttm_tt structure
*
* Calls the driver method to allocate pages for a ttm
*/
int ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx);
/** /**
* ttm_tt_unpopulate - free pages from a ttm * ttm_tt_unpopulate - free pages from a ttm
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment