From: Christoph Hellwig <hch@lst.de>
To: Nicolin Chen <nicoleotsuka@gmail.com>,
Robin Murphy <robin.murphy@arm.com>
Cc: hch@lst.de, iommu@lists.linux-foundation.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iommu/dma: Apply dma_{alloc,free}_contiguous functions
Date: Thu, 6 Jun 2019 08:28:40 +0200 [thread overview]
Message-ID: <20190606062840.GD26745@lst.de> (raw)
In-Reply-To: <20190603225259.21994-1-nicoleotsuka@gmail.com>
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
WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Nicolin Chen <nicoleotsuka@gmail.com>,
Robin Murphy <robin.murphy@arm.com>
Cc: joro@8bytes.org, hch@lst.de, iommu@lists.linux-foundation.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iommu/dma: Apply dma_{alloc,free}_contiguous functions
Date: Thu, 6 Jun 2019 08:28:40 +0200 [thread overview]
Message-ID: <20190606062840.GD26745@lst.de> (raw)
In-Reply-To: <20190603225259.21994-1-nicoleotsuka@gmail.com>
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---
next prev parent reply other threads:[~2019-06-06 6:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-03 22:52 [PATCH] iommu/dma: Apply dma_{alloc,free}_contiguous functions Nicolin Chen
2019-06-03 22:52 ` Nicolin Chen
2019-06-06 6:28 ` Christoph Hellwig [this message]
2019-06-06 6:28 ` Christoph Hellwig
2019-06-14 10:42 ` Robin Murphy
2019-06-14 10:42 ` Robin Murphy
2019-06-14 12:31 ` Christoph Hellwig
2019-06-14 12:31 ` Christoph Hellwig
2019-06-14 12:30 ` Christoph Hellwig
2019-06-14 12:30 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190606062840.GD26745@lst.de \
--to=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicoleotsuka@gmail.com \
--cc=robin.murphy@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.