drm/ttm: audit bo->resource usage v2
Allow BOs to exist without backing store. v2: handle ttm_bo_move_memcpy as well. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220707102453.3633-5-christian.koenig@amd.com
This commit is contained in:
parent
64e257f187
commit
4d8f68548e
@ -117,12 +117,13 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
|
||||
struct ttm_operation_ctx *ctx,
|
||||
struct ttm_place *hop)
|
||||
{
|
||||
struct ttm_resource_manager *old_man, *new_man;
|
||||
struct ttm_device *bdev = bo->bdev;
|
||||
bool old_use_tt, new_use_tt;
|
||||
int ret;
|
||||
|
||||
old_man = ttm_manager_type(bdev, bo->resource->mem_type);
|
||||
new_man = ttm_manager_type(bdev, mem->mem_type);
|
||||
old_use_tt = bo->resource &&
|
||||
ttm_manager_type(bdev, bo->resource->mem_type)->use_tt;
|
||||
new_use_tt = ttm_manager_type(bdev, mem->mem_type)->use_tt;
|
||||
|
||||
ttm_bo_unmap_virtual(bo);
|
||||
|
||||
@ -130,11 +131,11 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
|
||||
* Create and bind a ttm if required.
|
||||
*/
|
||||
|
||||
if (new_man->use_tt) {
|
||||
if (new_use_tt) {
|
||||
/* Zero init the new TTM structure if the old location should
|
||||
* have used one as well.
|
||||
*/
|
||||
ret = ttm_tt_create(bo, old_man->use_tt);
|
||||
ret = ttm_tt_create(bo, old_use_tt);
|
||||
if (ret)
|
||||
goto out_err;
|
||||
|
||||
@ -160,8 +161,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
|
||||
return 0;
|
||||
|
||||
out_err:
|
||||
new_man = ttm_manager_type(bdev, bo->resource->mem_type);
|
||||
if (!new_man->use_tt)
|
||||
if (!old_use_tt)
|
||||
ttm_bo_tt_destroy(bo);
|
||||
|
||||
return ret;
|
||||
@ -898,7 +898,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
|
||||
/*
|
||||
* Check whether we need to move buffer.
|
||||
*/
|
||||
if (!ttm_resource_compat(bo->resource, placement)) {
|
||||
if (!bo->resource || !ttm_resource_compat(bo->resource, placement)) {
|
||||
ret = ttm_bo_move_buffer(bo, placement, ctx);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
@ -137,8 +137,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
|
||||
ttm_manager_type(bo->bdev, dst_mem->mem_type);
|
||||
struct ttm_tt *ttm = bo->ttm;
|
||||
struct ttm_resource *src_mem = bo->resource;
|
||||
struct ttm_resource_manager *src_man =
|
||||
ttm_manager_type(bdev, src_mem->mem_type);
|
||||
struct ttm_resource_manager *src_man;
|
||||
union {
|
||||
struct ttm_kmap_iter_tt tt;
|
||||
struct ttm_kmap_iter_linear_io io;
|
||||
@ -147,6 +146,10 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
|
||||
bool clear;
|
||||
int ret = 0;
|
||||
|
||||
if (!src_mem)
|
||||
return 0;
|
||||
|
||||
src_man = ttm_manager_type(bdev, src_mem->mem_type);
|
||||
if (ttm && ((ttm->page_flags & TTM_TT_FLAG_SWAPPED) ||
|
||||
dst_man->use_tt)) {
|
||||
ret = ttm_tt_populate(bdev, ttm, ctx);
|
||||
|
Loading…
x
Reference in New Issue
Block a user