[Intel-gfx] [PATCH] drm/i915/gem: Promote 'remain' to unsigned long

Mika Kuoppala mika.kuoppala at linux.intel.com
Tue Apr 7 09:21:16 UTC 2020


Chris Wilson <chris at chris-wilson.co.uk> writes:

> Tidy the code by casting remain to unsigned long once for the duration
> of eb_relocate_vma()
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

Reviewed-by: Mika Kuoppala <mika.kuoppala at linux.intel.com>

> ---
>  drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> index d9ab517bbce9..c95dc09c4c93 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> @@ -1508,11 +1508,11 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
>  	struct drm_i915_gem_relocation_entry stack[N_RELOC(512)];
>  	struct drm_i915_gem_relocation_entry __user *urelocs;
>  	const struct drm_i915_gem_exec_object2 *entry = ev->exec;
> -	unsigned int remain;
> +	unsigned long remain;
>  
>  	urelocs = u64_to_user_ptr(entry->relocs_ptr);
>  	remain = entry->relocation_count;
> -	if (unlikely((unsigned long)remain > N_RELOC(ULONG_MAX)))
> +	if (unlikely(remain > N_RELOC(ULONG_MAX)))
>  		return -EINVAL;
>  
>  	/*
> @@ -1520,13 +1520,12 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
>  	 * to read. However, if the array is not writable the user loses
>  	 * the updated relocation values.
>  	 */
> -	if (unlikely(!access_ok(urelocs, remain*sizeof(*urelocs))))
> +	if (unlikely(!access_ok(urelocs, remain * sizeof(*urelocs))))
>  		return -EFAULT;
>  
>  	do {
>  		struct drm_i915_gem_relocation_entry *r = stack;
> -		unsigned int count =
> -			min_t(unsigned int, remain, ARRAY_SIZE(stack));
> +		unsigned int count = min(remain, ARRAY_SIZE(stack));
>  		unsigned int copied;
>  
>  		/*
> -- 
> 2.20.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx


More information about the Intel-gfx mailing list