Commit 591fcf3b authored by Nicolin Chen's avatar Nicolin Chen Committed by Christoph Hellwig

iommu/dma: Apply dma_{alloc,free}_contiguous functions

This patch replaces dma_{alloc,release}_from_contiguous() with
dma_{alloc,free}_contiguous() to simplify those function calls.
Signed-off-by: default avatarNicolin Chen <nicoleotsuka@gmail.com>
Acked-by: default avatarRobin Murphy <robin.murphy@arm.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 4b4b077c
...@@ -951,8 +951,8 @@ static void __iommu_dma_free(struct device *dev, size_t size, void *cpu_addr) ...@@ -951,8 +951,8 @@ static void __iommu_dma_free(struct device *dev, size_t size, void *cpu_addr)
if (pages) if (pages)
__iommu_dma_free_pages(pages, count); __iommu_dma_free_pages(pages, count);
if (page && !dma_release_from_contiguous(dev, page, count)) if (page)
__free_pages(page, get_order(alloc_size)); dma_free_contiguous(dev, page, alloc_size);
} }
static void iommu_dma_free(struct device *dev, size_t size, void *cpu_addr, 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, ...@@ -970,12 +970,7 @@ static void *iommu_dma_alloc_pages(struct device *dev, size_t size,
struct page *page = NULL; struct page *page = NULL;
void *cpu_addr; void *cpu_addr;
if (gfpflags_allow_blocking(gfp)) page = dma_alloc_contiguous(dev, alloc_size, 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));
if (!page) if (!page)
return NULL; return NULL;
...@@ -997,8 +992,7 @@ static void *iommu_dma_alloc_pages(struct device *dev, size_t size, ...@@ -997,8 +992,7 @@ static void *iommu_dma_alloc_pages(struct device *dev, size_t size,
memset(cpu_addr, 0, alloc_size); memset(cpu_addr, 0, alloc_size);
return cpu_addr; return cpu_addr;
out_free_pages: out_free_pages:
if (!dma_release_from_contiguous(dev, page, alloc_size >> PAGE_SHIFT)) dma_free_contiguous(dev, page, alloc_size);
__free_pages(page, get_order(alloc_size));
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment