diff options
author | Robin Murphy <robin.murphy@arm.com> | 2019-05-20 09:29:40 +0200 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2019-05-27 17:31:11 +0200 |
commit | 8553f6e65240ea0c2ae970eeba18e4d3a47230aa (patch) | |
tree | a0d0e8ca7deebd9c086c3f14cb9db27cb5548aab /drivers/iommu | |
parent | iommu/dma: Merge the CMA and alloc_pages allocation paths (diff) | |
download | linux-8553f6e65240ea0c2ae970eeba18e4d3a47230aa.tar.xz linux-8553f6e65240ea0c2ae970eeba18e4d3a47230aa.zip |
iommu/dma: Split iommu_dma_free
Most of it can double up to serve the failure cleanup path for
iommu_dma_alloc().
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/dma-iommu.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index ee7dcf03c304..f0cd35fd11dd 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -935,15 +935,12 @@ static void iommu_dma_unmap_resource(struct device *dev, dma_addr_t handle, __iommu_dma_unmap(dev, handle, size); } -static void iommu_dma_free(struct device *dev, size_t size, void *cpu_addr, - dma_addr_t handle, unsigned long attrs) +static void __iommu_dma_free(struct device *dev, size_t size, void *cpu_addr) { size_t alloc_size = PAGE_ALIGN(size); int count = alloc_size >> PAGE_SHIFT; struct page *page = NULL, **pages = NULL; - __iommu_dma_unmap(dev, handle, size); - /* Non-coherent atomic allocation? Easy */ if (dma_free_from_pool(cpu_addr, alloc_size)) return; @@ -968,6 +965,13 @@ static void iommu_dma_free(struct device *dev, size_t size, void *cpu_addr, __free_pages(page, get_order(alloc_size)); } +static void iommu_dma_free(struct device *dev, size_t size, void *cpu_addr, + dma_addr_t handle, unsigned long attrs) +{ + __iommu_dma_unmap(dev, handle, size); + __iommu_dma_free(dev, size, cpu_addr); +} + static void *iommu_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp, unsigned long attrs) { |