iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/dma: Apply dma_{alloc,free}_contiguous functions
@ 2019-06-03 22:52 Nicolin Chen
  2019-06-06  6:28 ` Christoph Hellwig
  2019-06-14 12:30 ` Christoph Hellwig
  0 siblings, 2 replies; 5+ messages in thread
From: Nicolin Chen @ 2019-06-03 22:52 UTC (permalink / raw)
  To: joro; +Cc: iommu, hch, linux-kernel

This patch replaces dma_{alloc,release}_from_contiguous() with
dma_{alloc,free}_contiguous() to simplify those function calls.

Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
---
 drivers/iommu/dma-iommu.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 0cd49c2d3770..cc3d39dbbe1a 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -951,8 +951,8 @@ static void __iommu_dma_free(struct device *dev, size_t size, void *cpu_addr)
 
 	if (pages)
 		__iommu_dma_free_pages(pages, count);
-	if (page && !dma_release_from_contiguous(dev, page, count))
-		__free_pages(page, get_order(alloc_size));
+	if (page)
+		dma_free_contiguous(dev, page, alloc_size);
 }
 
 static void iommu_dma_free(struct device *dev, size_t size, void *cpu_addr,
@@ -970,12 +970,7 @@ static void *iommu_dma_alloc_pages(struct device *dev, size_t size,
 	struct page *page = NULL;
 	void *cpu_addr;
 
-	if (gfpflags_allow_blocking(gfp))
-		page = dma_alloc_from_contiguous(dev, alloc_size >> PAGE_SHIFT,
-						 get_order(alloc_size),
-						 gfp & __GFP_NOWARN);
-	if (!page)
-		page = alloc_pages(gfp, get_order(alloc_size));
+	page = dma_alloc_contiguous(dev, alloc_size, gfp);
 	if (!page)
 		return NULL;
 
@@ -997,8 +992,7 @@ static void *iommu_dma_alloc_pages(struct device *dev, size_t size,
 	memset(cpu_addr, 0, alloc_size);
 	return cpu_addr;
 out_free_pages:
-	if (!dma_release_from_contiguous(dev, page, alloc_size >> PAGE_SHIFT))
-		__free_pages(page, get_order(alloc_size));
+	dma_free_contiguous(dev, page, alloc_size);
 	return NULL;
 }
 
-- 
2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] iommu/dma: Apply dma_{alloc,free}_contiguous functions
  2019-06-03 22:52 [PATCH] iommu/dma: Apply dma_{alloc,free}_contiguous functions Nicolin Chen
@ 2019-06-06  6:28 ` Christoph Hellwig
  2019-06-14 10:42   ` Robin Murphy
  2019-06-14 12:30 ` Christoph Hellwig
  1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2019-06-06  6:28 UTC (permalink / raw)
  To: Nicolin Chen, Robin Murphy; +Cc: hch, iommu, linux-kernel

Looks fine to me.  Robin, any comments?

On Mon, Jun 03, 2019 at 03:52:59PM -0700, Nicolin Chen wrote:
> This patch replaces dma_{alloc,release}_from_contiguous() with
> dma_{alloc,free}_contiguous() to simplify those function calls.
> 
> Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
> ---
>  drivers/iommu/dma-iommu.c | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> index 0cd49c2d3770..cc3d39dbbe1a 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -951,8 +951,8 @@ static void __iommu_dma_free(struct device *dev, size_t size, void *cpu_addr)
>  
>  	if (pages)
>  		__iommu_dma_free_pages(pages, count);
> -	if (page && !dma_release_from_contiguous(dev, page, count))
> -		__free_pages(page, get_order(alloc_size));
> +	if (page)
> +		dma_free_contiguous(dev, page, alloc_size);
>  }
>  
>  static void iommu_dma_free(struct device *dev, size_t size, void *cpu_addr,
> @@ -970,12 +970,7 @@ static void *iommu_dma_alloc_pages(struct device *dev, size_t size,
>  	struct page *page = NULL;
>  	void *cpu_addr;
>  
> -	if (gfpflags_allow_blocking(gfp))
> -		page = dma_alloc_from_contiguous(dev, alloc_size >> PAGE_SHIFT,
> -						 get_order(alloc_size),
> -						 gfp & __GFP_NOWARN);
> -	if (!page)
> -		page = alloc_pages(gfp, get_order(alloc_size));
> +	page = dma_alloc_contiguous(dev, alloc_size, gfp);
>  	if (!page)
>  		return NULL;
>  
> @@ -997,8 +992,7 @@ static void *iommu_dma_alloc_pages(struct device *dev, size_t size,
>  	memset(cpu_addr, 0, alloc_size);
>  	return cpu_addr;
>  out_free_pages:
> -	if (!dma_release_from_contiguous(dev, page, alloc_size >> PAGE_SHIFT))
> -		__free_pages(page, get_order(alloc_size));
> +	dma_free_contiguous(dev, page, alloc_size);
>  	return NULL;
>  }
>  
> -- 
> 2.17.1
---end quoted text---
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iommu/dma: Apply dma_{alloc,free}_contiguous functions
  2019-06-06  6:28 ` Christoph Hellwig
@ 2019-06-14 10:42   ` Robin Murphy
  2019-06-14 12:31     ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Robin Murphy @ 2019-06-14 10:42 UTC (permalink / raw)
  To: Christoph Hellwig, Nicolin Chen; +Cc: iommu, linux-kernel

On 06/06/2019 07:28, Christoph Hellwig wrote:
> Looks fine to me.  Robin, any comments?

AFAICS this looks like the obvious conversion, so... no? :)

> On Mon, Jun 03, 2019 at 03:52:59PM -0700, Nicolin Chen wrote:
>> This patch replaces dma_{alloc,release}_from_contiguous() with
>> dma_{alloc,free}_contiguous() to simplify those function calls.

Acked-by: Robin Murphy <robin.murphy@arm.com>

>> Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
>> ---
>>   drivers/iommu/dma-iommu.c | 14 ++++----------
>>   1 file changed, 4 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
>> index 0cd49c2d3770..cc3d39dbbe1a 100644
>> --- a/drivers/iommu/dma-iommu.c
>> +++ b/drivers/iommu/dma-iommu.c
>> @@ -951,8 +951,8 @@ static void __iommu_dma_free(struct device *dev, size_t size, void *cpu_addr)
>>   
>>   	if (pages)
>>   		__iommu_dma_free_pages(pages, count);
>> -	if (page && !dma_release_from_contiguous(dev, page, count))
>> -		__free_pages(page, get_order(alloc_size));
>> +	if (page)
>> +		dma_free_contiguous(dev, page, alloc_size);
>>   }
>>   
>>   static void iommu_dma_free(struct device *dev, size_t size, void *cpu_addr,
>> @@ -970,12 +970,7 @@ static void *iommu_dma_alloc_pages(struct device *dev, size_t size,
>>   	struct page *page = NULL;
>>   	void *cpu_addr;
>>   
>> -	if (gfpflags_allow_blocking(gfp))
>> -		page = dma_alloc_from_contiguous(dev, alloc_size >> PAGE_SHIFT,
>> -						 get_order(alloc_size),
>> -						 gfp & __GFP_NOWARN);
>> -	if (!page)
>> -		page = alloc_pages(gfp, get_order(alloc_size));
>> +	page = dma_alloc_contiguous(dev, alloc_size, gfp);
>>   	if (!page)
>>   		return NULL;
>>   
>> @@ -997,8 +992,7 @@ static void *iommu_dma_alloc_pages(struct device *dev, size_t size,
>>   	memset(cpu_addr, 0, alloc_size);
>>   	return cpu_addr;
>>   out_free_pages:
>> -	if (!dma_release_from_contiguous(dev, page, alloc_size >> PAGE_SHIFT))
>> -		__free_pages(page, get_order(alloc_size));
>> +	dma_free_contiguous(dev, page, alloc_size);
>>   	return NULL;
>>   }
>>   
>> -- 
>> 2.17.1
> ---end quoted text---
> 
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iommu/dma: Apply dma_{alloc,free}_contiguous functions
  2019-06-03 22:52 [PATCH] iommu/dma: Apply dma_{alloc,free}_contiguous functions Nicolin Chen
  2019-06-06  6:28 ` Christoph Hellwig
@ 2019-06-14 12:30 ` Christoph Hellwig
  1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2019-06-14 12:30 UTC (permalink / raw)
  To: Nicolin Chen; +Cc: hch, iommu, linux-kernel

Thanks,

applied to the dma-mapping for-next branch.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iommu/dma: Apply dma_{alloc,free}_contiguous functions
  2019-06-14 10:42   ` Robin Murphy
@ 2019-06-14 12:31     ` Christoph Hellwig
  0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2019-06-14 12:31 UTC (permalink / raw)
  To: Robin Murphy; +Cc: Nicolin Chen, Christoph Hellwig, iommu, linux-kernel

On Fri, Jun 14, 2019 at 11:42:54AM +0100, Robin Murphy wrote:
> On 06/06/2019 07:28, Christoph Hellwig wrote:
>> Looks fine to me.  Robin, any comments?
>
> AFAICS this looks like the obvious conversion, so... no? :)

Yep.  Just want to make sure I don't apply dma-iommu patches without
your review.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-06-14 12:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-03 22:52 [PATCH] iommu/dma: Apply dma_{alloc,free}_contiguous functions Nicolin Chen
2019-06-06  6:28 ` Christoph Hellwig
2019-06-14 10:42   ` Robin Murphy
2019-06-14 12:31     ` Christoph Hellwig
2019-06-14 12:30 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).