Re: [PATCH v2 07/10] drm/msm/gem: Rework vma lookup and pin

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

 



On 3/30/22 23:47, Rob Clark wrote:
> From: Rob Clark <robdclark@xxxxxxxxxxxx>
> 
> Combines duplicate vma lookup in the get_and_pin path.
> 
> Signed-off-by: Rob Clark <robdclark@xxxxxxxxxxxx>
> ---
>  drivers/gpu/drm/msm/msm_gem.c | 50 ++++++++++++++++++-----------------
>  1 file changed, 26 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
> index deafae6feaa8..218744a490a4 100644
> --- a/drivers/gpu/drm/msm/msm_gem.c
> +++ b/drivers/gpu/drm/msm/msm_gem.c
> @@ -376,39 +376,40 @@ put_iova_vmas(struct drm_gem_object *obj)
>  	}
>  }
>  
> -static int get_iova_locked(struct drm_gem_object *obj,
> -		struct msm_gem_address_space *aspace, uint64_t *iova,
> +static struct msm_gem_vma *get_vma_locked(struct drm_gem_object *obj,
> +		struct msm_gem_address_space *aspace,
>  		u64 range_start, u64 range_end)
>  {
>  	struct msm_gem_vma *vma;
> -	int ret = 0;
>  
>  	GEM_WARN_ON(!msm_gem_is_locked(obj));
>  
>  	vma = lookup_vma(obj, aspace);
>  
>  	if (!vma) {
> +		int ret;
> +
>  		vma = add_vma(obj, aspace);
>  		if (IS_ERR(vma))
> -			return PTR_ERR(vma);
> +			return vma;
>  
>  		ret = msm_gem_init_vma(aspace, vma, obj->size,
>  			range_start, range_end);
>  		if (ret) {
You're allocation range_start -> range_end


>  			del_vma(vma);
> -			return ret;
> +			return ERR_PTR(ret);
>  		}
> +	} else {
> +		GEM_WARN_ON(vma->iova < range_start);
> +		GEM_WARN_ON((vma->iova + obj->size) > range_end);

and then comparing range_start -> range_start + obj->size, hence you're
assuming that range_end always equals to obj->size during the allocation.

I'm not sure what is the idea here.. this looks inconsistent. I think
you wanted to write:

		GEM_WARN_ON(vma->iova < range_start);
		GEM_WARN_ON(vma->iova + (vma->node.size << PAGE_SHIFT) > range_end);

But is it really useful to check whether the new range is inside of the
old range? Shouldn't it be always a error to change the IOVA range
without reallocating vma?

I'd expect to see:

		GEM_WARN_ON(vma->iova != range_start);
		GEM_WARN_ON(vma->iova + (vma->node.size << PAGE_SHIFT) != range_end);

and then error out if range mismatches.



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux