Re: [PATCH] drm/i915/gem: Promote 'remain' to unsigned long

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> writes:

> Tidy the code by casting remain to unsigned long once for the duration
> of eb_relocate_vma()
>
> Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>

Reviewed-by: Mika Kuoppala <mika.kuoppala@xxxxxxxxxxxxxxx>

> ---
>  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@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux