[Intel-gfx] [PATCH v2 3/3] drm/i915: Limit the scattergather coalescing to 32bits

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Tue Oct 18 09:33:11 UTC 2016


On 17/10/2016 09:00, Chris Wilson wrote:
> The scattergather list uses a 32bit size counter, we should avoid
> exceeding it.
>
> v2: Also we should use unsigned int to match sg->length.
>
> Fixes: 871dfbd67d4e ("drm/i915: Allow compaction upto SWIOTLB max segment size")
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com> # v1
> ---
>   drivers/gpu/drm/i915/i915_gem.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 181bda2db587..a74ec10a5370 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -2205,7 +2205,7 @@ i915_gem_object_put_pages(struct drm_i915_gem_object *obj)
>   	return 0;
>   }
>   
> -static unsigned long swiotlb_max_size(void)
> +static unsigned int swiotlb_max_size(void)
>   {
>   #if IS_ENABLED(CONFIG_SWIOTLB)
>   	return rounddown(swiotlb_nr_tbl() << IO_TLB_SHIFT, PAGE_SIZE);
> @@ -2225,7 +2225,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
>   	struct sgt_iter sgt_iter;
>   	struct page *page;
>   	unsigned long last_pfn = 0;	/* suppress gcc warning */
> -	unsigned long max_segment;
> +	unsigned int max_segment;
>   	int ret;
>   	gfp_t gfp;
>   
> @@ -2238,7 +2238,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
>   
>   	max_segment = swiotlb_max_size();
>   	if (!max_segment)
> -		max_segment = obj->base.size;
> +		max_segment = rounddown(UINT_MAX, PAGE_SIZE);

rounddown looks like an overkill vs just UINT_MAX, no?

>   
>   	st = kmalloc(sizeof(*st), GFP_KERNEL);
>   	if (st == NULL)

Anyway,

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Regards,

Tvrtko



More information about the Intel-gfx mailing list