diff options
author | Dave Airlie <airlied@redhat.com> | 2020-09-17 07:13:06 +0300 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2020-09-17 23:21:29 +0300 |
commit | 92afce9095300cb652ea74a617c6679c4c4d4429 (patch) | |
tree | 09a9fa27a7038e9d2a67adc14e718d938b688042 /drivers | |
parent | 13a8f46d8030e519939bfb674f7aa541109f6ce2 (diff) | |
download | linux-92afce9095300cb652ea74a617c6679c4c4d4429.tar.xz |
drm/ttm: make common function for wait/free node path.
The pipeline and accel cleansups has similiar paths here.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200917043040.146575-8-airlied@gmail.com
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_bo_util.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 8a6841454ce7..ee4484ccbd1e 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -526,6 +526,20 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map) } EXPORT_SYMBOL(ttm_bo_kunmap); +static int ttm_bo_wait_free_node(struct ttm_buffer_object *bo, + bool dst_use_tt) +{ + int ret; + ret = ttm_bo_wait(bo, false, false); + if (ret) + return ret; + + if (!dst_use_tt) + ttm_bo_tt_destroy(bo); + ttm_bo_free_old_node(bo); + return 0; +} + static int ttm_bo_move_to_ghost(struct ttm_buffer_object *bo, struct dma_fence *fence, bool dst_use_tt) @@ -576,19 +590,12 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo, int ret; dma_resv_add_excl_fence(bo->base.resv, fence); - if (evict) { - ret = ttm_bo_wait(bo, false, false); - if (ret) - return ret; - - if (!man->use_tt) - ttm_bo_tt_destroy(bo); - ttm_bo_free_old_node(bo); - } else { + if (evict) + ret = ttm_bo_wait_free_node(bo, man->use_tt); + else ret = ttm_bo_move_to_ghost(bo, fence, man->use_tt); - if (ret) - return ret; - } + if (ret) + return ret; ttm_bo_assign_mem(bo, new_mem); @@ -638,14 +645,9 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo, * * Should never happen in pratice. */ - - ret = ttm_bo_wait(bo, false, false); + ret = ttm_bo_wait_free_node(bo, to->use_tt); if (ret) return ret; - - if (!to->use_tt) - ttm_bo_tt_destroy(bo); - ttm_bo_free_old_node(bo); } ttm_bo_assign_mem(bo, new_mem); |