[PATCH v2] drm/ttm: Should to return the evict error

Christian König christian.koenig at amd.com
Mon Jun 2 10:05:48 UTC 2025


On 5/21/25 05:56, Emily Deng wrote:
> For the evict fail case, the evict error should be returned.
> 
> v2: Consider ENOENT case.
> 
> Signed-off-by: Emily Deng <Emily.Deng at amd.com>
> ---
>  drivers/gpu/drm/ttm/ttm_resource.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
> index 097716bd248a..abf104ae9d35 100644
> --- a/drivers/gpu/drm/ttm/ttm_resource.c
> +++ b/drivers/gpu/drm/ttm/ttm_resource.c
> @@ -511,12 +511,12 @@ int ttm_resource_manager_evict_all(struct ttm_device *bdev,
>  		.force_alloc = true
>  	};
>  	struct dma_fence *fence;
> -	int ret;
> +	int ret, evict_ret = 0;
>  
>  	do {
> -		ret = ttm_bo_evict_first(bdev, man, &ctx);
> +		evict_ret = ttm_bo_evict_first(bdev, man, &ctx);
>  		cond_resched();
> -	} while (!ret);
> +	} while (!evict_ret);


We should probably abort here directly when the eviction failed for some reason (except for -ENOENT) and not wait for the move to finish.

Regards,
Christian.

>  
>  	spin_lock(&man->move_lock);
>  	fence = dma_fence_get(man->move);
> @@ -529,7 +529,7 @@ int ttm_resource_manager_evict_all(struct ttm_device *bdev,
>  			return ret;
>  	}
>  
> -	return 0;
> +	return (evict_ret == -ENOENT) ? 0 : evict_ret;
>  }
>  EXPORT_SYMBOL(ttm_resource_manager_evict_all);
>  



More information about the amd-gfx mailing list