diff options
| author | Dmitry Torokhov <[email protected]> | 2023-08-30 16:06:38 -0700 | 
|---|---|---|
| committer | Dmitry Torokhov <[email protected]> | 2023-08-30 16:06:38 -0700 | 
| commit | 1ac731c529cd4d6adbce134754b51ff7d822b145 (patch) | |
| tree | 143ab3f35ca5f3b69f583c84e6964b17139c2ec1 /drivers/gpu/drm/ttm/ttm_bo.c | |
| parent | 07b4c950f27bef0362dc6ad7ee713aab61d58149 (diff) | |
| parent | 54116d442e001e1b6bd482122043b1870998a1f3 (diff) | |
Merge branch 'next' into for-linus
Prepare input updates for 6.6 merge window.
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_bo.c')
| -rw-r--r-- | drivers/gpu/drm/ttm/ttm_bo.c | 38 | 
1 files changed, 17 insertions, 21 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 326a3d13a829..bd5dae4d1624 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -84,6 +84,7 @@ EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);   * ttm_bo_set_bulk_move - update BOs bulk move object   *   * @bo: The buffer object. + * @bulk: bulk move structure   *   * Update the BOs bulk move object, making sure that resources are added/removed   * as well. A bulk move allows to move many resource on the LRU at once, @@ -120,8 +121,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,  	bool old_use_tt, new_use_tt;  	int ret; -	old_use_tt = bo->resource && -		ttm_manager_type(bdev, bo->resource->mem_type)->use_tt; +	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); @@ -295,8 +295,6 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo,  	if (unlock_resv)  		dma_resv_unlock(bo->base.resv); -	ttm_bo_put(bo); -  	return 0;  } @@ -465,7 +463,8 @@ bounce:  	if (ret == -EMULTIHOP) {  		ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, ctx, &hop);  		if (ret) { -			pr_err("Buffer eviction failed\n"); +			if (ret != -ERESTARTSYS && ret != -EINTR) +				pr_err("Buffer eviction failed\n");  			ttm_resource_free(bo, &evict_mem);  			goto out;  		} @@ -748,7 +747,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,   *   * @bo: Pointer to a struct ttm_buffer_object. the data of which   * we want to allocate space for. - * @proposed_placement: Proposed new placement for the buffer object. + * @placement: Proposed new placement for the buffer object.   * @mem: A struct ttm_resource.   * @ctx: if and how to sleep, lock buffers and alloc memory   * @@ -894,14 +893,18 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,  	if (!placement->num_placement && !placement->num_busy_placement)  		return ttm_bo_pipeline_gutting(bo); -	/* -	 * Check whether we need to move buffer. -	 */ -	if (!bo->resource || !ttm_resource_compat(bo->resource, placement)) { -		ret = ttm_bo_move_buffer(bo, placement, ctx); -		if (ret) -			return ret; -	} +	/* Check whether we need to move buffer. */ +	if (bo->resource && ttm_resource_compat(bo->resource, placement)) +		return 0; + +	/* Moving of pinned BOs is forbidden */ +	if (bo->pin_count) +		return -EINVAL; + +	ret = ttm_bo_move_buffer(bo, placement, ctx); +	if (ret) +		return ret; +  	/*  	 * We might need to add a TTM.  	 */ @@ -953,7 +956,6 @@ int ttm_bo_init_reserved(struct ttm_device *bdev, struct ttm_buffer_object *bo,  			 struct sg_table *sg, struct dma_resv *resv,  			 void (*destroy) (struct ttm_buffer_object *))  { -	static const struct ttm_place sys_mem = { .mem_type = TTM_PL_SYSTEM };  	int ret;  	kref_init(&bo->kref); @@ -970,12 +972,6 @@ int ttm_bo_init_reserved(struct ttm_device *bdev, struct ttm_buffer_object *bo,  		bo->base.resv = &bo->base._resv;  	atomic_inc(&ttm_glob.bo_count); -	ret = ttm_resource_alloc(bo, &sys_mem, &bo->resource); -	if (unlikely(ret)) { -		ttm_bo_put(bo); -		return ret; -	} -  	/*  	 * For ttm_bo_type_device buffers, allocate  	 * address space from the device.  |