[Intel-gfx] [PATCH v2 6/7] drm/i915: Use error code as -E2BIG when the size of gem ttm object is too large

Mauro Carvalho Chehab mauro.chehab at linux.intel.com
Tue Jul 5 14:50:48 UTC 2022


On Tue,  5 Jul 2022 15:24:54 +0300
Gwan-gyeong Mun <gwan-gyeong.mun at intel.com> wrote:

> The ttm_bo_init_reserved() functions returns -ENOSPC if the size is too big
> to add vma. The direct function that returns -ENOSPC is drm_mm_insert_node_in_range().
> To handle the same error as other code returning -E2BIG when the size is
> too large, it converts return value to -E2BIG.
> 
> Signed-off-by: Gwan-gyeong Mun <gwan-gyeong.mun at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Matthew Auld <matthew.auld at intel.com>
> Cc: Thomas Hellström <thomas.hellstrom at linux.intel.com>
> Reviewed-by: Nirmoy Das <nirmoy.das at intel.com>

Reviewed-by: Mauro Carvalho Chehab <mchehab at kernel.org>

> ---
>  drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
> index d579524663b3..271f64b7e4f1 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
> @@ -1249,6 +1249,17 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem,
>  				   bo_type, &i915_sys_placement,
>  				   page_size >> PAGE_SHIFT,
>  				   &ctx, NULL, NULL, i915_ttm_bo_destroy);
> +
> +	/*
> +	 * XXX: The ttm_bo_init_reserved() functions returns -ENOSPC if the size
> +	 * is too big to add vma. The direct function that returns -ENOSPC is
> +	 * drm_mm_insert_node_in_range(). To handle the same error as other code
> +	 * that returns -E2BIG when the size is too large, it converts -ENOSPC to
> +	 * -E2BIG.
> +	 */
> +	if (size >> PAGE_SHIFT > INT_MAX && ret == -ENOSPC)
> +		ret = -E2BIG;
> +
>  	if (ret)
>  		return i915_ttm_err_to_gem(ret);
>  


More information about the Intel-gfx mailing list