[PATCH 5/8] etnaviv: iommuv1: fold pgtable_write into callers

Wladimir J. van der Laan laanwj at gmail.com
Wed Sep 27 11:30:52 UTC 2017


On Fri, Sep 15, 2017 at 07:04:36PM +0200, Lucas Stach wrote:
> A function doing a single assignment is not really helping the
> code flow.
> 
> Signed-off-by: Lucas Stach <l.stach at pengutronix.de>

agreed.

Reviewed-by: Wladimir J. van der Laan <laanwj at gmail.com>

> ---
>  drivers/gpu/drm/etnaviv/etnaviv_iommu.c | 16 ++++------------
>  1 file changed, 4 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_iommu.c b/drivers/gpu/drm/etnaviv/etnaviv_iommu.c
> index 78a7c0f3064a..43a0508bdbd7 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_iommu.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_iommu.c
> @@ -49,15 +49,6 @@ static struct etnaviv_iommu_domain *to_etnaviv_domain(struct iommu_domain *domai
>  	return container_of(domain, struct etnaviv_iommu_domain, domain);
>  }
>  
> -static void pgtable_write(struct etnaviv_iommu_domain_pgtable *pgtable,
> -			  unsigned long iova, phys_addr_t paddr)
> -{
> -	/* calcuate index into page table */
> -	unsigned int index = (iova - GPU_MEM_START) / SZ_4K;
> -
> -	pgtable->pgtable[index] = paddr;
> -}
> -
>  static int __etnaviv_iommu_init(struct etnaviv_iommu_domain *etnaviv_domain)
>  {
>  	u32 *p;
> @@ -111,11 +102,12 @@ static int etnaviv_iommuv1_map(struct iommu_domain *domain, unsigned long iova,
>  	   phys_addr_t paddr, size_t size, int prot)
>  {
>  	struct etnaviv_iommu_domain *etnaviv_domain = to_etnaviv_domain(domain);
> +	unsigned int index = (iova - GPU_MEM_START) / SZ_4K;
>  
>  	if (size != SZ_4K)
>  		return -EINVAL;
>  
> -	pgtable_write(&etnaviv_domain->pgtable, iova, paddr);
> +	etnaviv_domain->pgtable.pgtable[index] = paddr;
>  
>  	return 0;
>  }
> @@ -124,12 +116,12 @@ static size_t etnaviv_iommuv1_unmap(struct iommu_domain *domain,
>  	unsigned long iova, size_t size)
>  {
>  	struct etnaviv_iommu_domain *etnaviv_domain = to_etnaviv_domain(domain);
> +	unsigned int index = (iova - GPU_MEM_START) / SZ_4K;
>  
>  	if (size != SZ_4K)
>  		return -EINVAL;
>  
> -	pgtable_write(&etnaviv_domain->pgtable, iova,
> -		      etnaviv_domain->bad_page_dma);
> +	etnaviv_domain->pgtable.pgtable[index] = etnaviv_domain->bad_page_dma;
>  
>  	return SZ_4K;
>  }
> -- 
> 2.11.0
> 
> _______________________________________________
> etnaviv mailing list
> etnaviv at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv


More information about the etnaviv mailing list