Re: [PATCH 3/8] etnaviv: iommuv1: fold pagetable alloc and free into caller

2017-09-27 Thread Wladimir J. van der Laan
On Fri, Sep 15, 2017 at 07:04:34PM +0200, Lucas Stach wrote:
> Those functions are simple enough to fold them into the calling
> function. This also fixes a correctness issue, as the alloc/free
> functions didn't specifiy the device the memory was allocated for.
> 
> Signed-off-by: Lucas Stach 

Reviewed-by: Wladimir J. van der Laan 

> ---
>  drivers/gpu/drm/etnaviv/etnaviv_iommu.c | 27 ---
>  1 file changed, 8 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_iommu.c 
> b/drivers/gpu/drm/etnaviv/etnaviv_iommu.c
> index f804c0aaa7a2..aaa8c4136f53 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_iommu.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_iommu.c
> @@ -50,22 +50,6 @@ static struct etnaviv_iommu_domain 
> *to_etnaviv_domain(struct iommu_domain *domai
>   return container_of(domain, struct etnaviv_iommu_domain, domain);
>  }
>  
> -static int pgtable_alloc(struct etnaviv_iommu_domain_pgtable *pgtable,
> -  size_t size)
> -{
> - pgtable->pgtable = dma_alloc_coherent(NULL, size, >paddr, 
> GFP_KERNEL);
> - if (!pgtable->pgtable)
> - return -ENOMEM;
> -
> - return 0;
> -}
> -
> -static void pgtable_free(struct etnaviv_iommu_domain_pgtable *pgtable,
> -  size_t size)
> -{
> - dma_free_coherent(NULL, size, pgtable->pgtable, pgtable->paddr);
> -}
> -
>  static void pgtable_write(struct etnaviv_iommu_domain_pgtable *pgtable,
> unsigned long iova, phys_addr_t paddr)
>  {
> @@ -91,8 +75,11 @@ static int __etnaviv_iommu_init(struct 
> etnaviv_iommu_domain *etnaviv_domain)
>   for (i = 0; i < SZ_4K / 4; i++)
>   *p++ = 0xdead55aa;
>  
> - ret = pgtable_alloc(_domain->pgtable, PT_SIZE);
> - if (ret < 0) {
> + etnaviv_domain->pgtable.pgtable =
> + dma_alloc_coherent(etnaviv_domain->dev, PT_SIZE,
> +_domain->pgtable.paddr,
> +GFP_KERNEL);
> + if (!etnaviv_domain->pgtable.pgtable) {
>   dma_free_coherent(etnaviv_domain->dev, SZ_4K,
> etnaviv_domain->bad_page_cpu,
> etnaviv_domain->bad_page_dma);
> @@ -112,7 +99,9 @@ static void etnaviv_domain_free(struct iommu_domain 
> *domain)
>  {
>   struct etnaviv_iommu_domain *etnaviv_domain = to_etnaviv_domain(domain);
>  
> - pgtable_free(_domain->pgtable, PT_SIZE);
> + dma_free_coherent(etnaviv_domain->dev, PT_SIZE,
> +   etnaviv_domain->pgtable.pgtable,
> +   etnaviv_domain->pgtable.paddr);
>  
>   dma_free_coherent(etnaviv_domain->dev, SZ_4K,
> etnaviv_domain->bad_page_cpu,
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 3/8] etnaviv: iommuv1: fold pagetable alloc and free into caller

2017-09-18 Thread Philipp Zabel
On Fri, 2017-09-15 at 19:04 +0200, Lucas Stach wrote:
> Those functions are simple enough to fold them into the calling
> function. This also fixes a correctness issue, as the alloc/free
> functions didn't specifiy the device the memory was allocated for.
> 
> Signed-off-by: Lucas Stach 

Reviewed-by: Philipp Zabel 

regards
Philipp
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/8] etnaviv: iommuv1: fold pagetable alloc and free into caller

2017-09-15 Thread Lucas Stach
Those functions are simple enough to fold them into the calling
function. This also fixes a correctness issue, as the alloc/free
functions didn't specifiy the device the memory was allocated for.

Signed-off-by: Lucas Stach 
---
 drivers/gpu/drm/etnaviv/etnaviv_iommu.c | 27 ---
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_iommu.c 
b/drivers/gpu/drm/etnaviv/etnaviv_iommu.c
index f804c0aaa7a2..aaa8c4136f53 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_iommu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_iommu.c
@@ -50,22 +50,6 @@ static struct etnaviv_iommu_domain *to_etnaviv_domain(struct 
iommu_domain *domai
return container_of(domain, struct etnaviv_iommu_domain, domain);
 }
 
-static int pgtable_alloc(struct etnaviv_iommu_domain_pgtable *pgtable,
-size_t size)
-{
-   pgtable->pgtable = dma_alloc_coherent(NULL, size, >paddr, 
GFP_KERNEL);
-   if (!pgtable->pgtable)
-   return -ENOMEM;
-
-   return 0;
-}
-
-static void pgtable_free(struct etnaviv_iommu_domain_pgtable *pgtable,
-size_t size)
-{
-   dma_free_coherent(NULL, size, pgtable->pgtable, pgtable->paddr);
-}
-
 static void pgtable_write(struct etnaviv_iommu_domain_pgtable *pgtable,
  unsigned long iova, phys_addr_t paddr)
 {
@@ -91,8 +75,11 @@ static int __etnaviv_iommu_init(struct etnaviv_iommu_domain 
*etnaviv_domain)
for (i = 0; i < SZ_4K / 4; i++)
*p++ = 0xdead55aa;
 
-   ret = pgtable_alloc(_domain->pgtable, PT_SIZE);
-   if (ret < 0) {
+   etnaviv_domain->pgtable.pgtable =
+   dma_alloc_coherent(etnaviv_domain->dev, PT_SIZE,
+  _domain->pgtable.paddr,
+  GFP_KERNEL);
+   if (!etnaviv_domain->pgtable.pgtable) {
dma_free_coherent(etnaviv_domain->dev, SZ_4K,
  etnaviv_domain->bad_page_cpu,
  etnaviv_domain->bad_page_dma);
@@ -112,7 +99,9 @@ static void etnaviv_domain_free(struct iommu_domain *domain)
 {
struct etnaviv_iommu_domain *etnaviv_domain = to_etnaviv_domain(domain);
 
-   pgtable_free(_domain->pgtable, PT_SIZE);
+   dma_free_coherent(etnaviv_domain->dev, PT_SIZE,
+ etnaviv_domain->pgtable.pgtable,
+ etnaviv_domain->pgtable.paddr);
 
dma_free_coherent(etnaviv_domain->dev, SZ_4K,
  etnaviv_domain->bad_page_cpu,
-- 
2.11.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel