diff options
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_bo_util.c')
| -rw-r--r-- | drivers/gpu/drm/ttm/ttm_bo_util.c | 24 | 
1 files changed, 17 insertions, 7 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 1cbfb00c1d65..fa04e62202c1 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -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); @@ -236,16 +239,19 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,  	if (bo->type != ttm_bo_type_sg)  		fbo->base.base.resv = &fbo->base.base._resv; -	if (fbo->base.resource) { -		ttm_resource_set_bo(fbo->base.resource, &fbo->base); -		bo->resource = NULL; -	} -  	dma_resv_init(&fbo->base.base._resv);  	fbo->base.base.dev = NULL;  	ret = dma_resv_trylock(&fbo->base.base._resv);  	WARN_ON(!ret); +	if (fbo->base.resource) { +		ttm_resource_set_bo(fbo->base.resource, &fbo->base); +		bo->resource = NULL; +		ttm_bo_set_bulk_move(&fbo->base, NULL); +	} else { +		fbo->base.bulk_move = NULL; +	} +  	ret = dma_resv_reserve_fences(&fbo->base.base._resv, 1);  	if (ret) {  		kfree(fbo); @@ -399,6 +405,8 @@ int ttm_bo_vmap(struct ttm_buffer_object *bo, struct iosys_map *map)  	struct ttm_resource *mem = bo->resource;  	int ret; +	dma_resv_assert_held(bo->base.resv); +  	ret = ttm_mem_io_reserve(bo->bdev, mem);  	if (ret)  		return ret; @@ -457,6 +465,8 @@ void ttm_bo_vunmap(struct ttm_buffer_object *bo, struct iosys_map *map)  {  	struct ttm_resource *mem = bo->resource; +	dma_resv_assert_held(bo->base.resv); +  	if (iosys_map_is_null(map))  		return;  |