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>
This commit is contained in:
parent
9a4ab94afc
commit
8553f6e652
|
@ -935,15 +935,12 @@ static void iommu_dma_unmap_resource(struct device *dev, dma_addr_t handle,
|
||||||
__iommu_dma_unmap(dev, handle, size);
|
__iommu_dma_unmap(dev, handle, 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)
|
||||||
dma_addr_t handle, unsigned long attrs)
|
|
||||||
{
|
{
|
||||||
size_t alloc_size = PAGE_ALIGN(size);
|
size_t alloc_size = PAGE_ALIGN(size);
|
||||||
int count = alloc_size >> PAGE_SHIFT;
|
int count = alloc_size >> PAGE_SHIFT;
|
||||||
struct page *page = NULL, **pages = NULL;
|
struct page *page = NULL, **pages = NULL;
|
||||||
|
|
||||||
__iommu_dma_unmap(dev, handle, size);
|
|
||||||
|
|
||||||
/* Non-coherent atomic allocation? Easy */
|
/* Non-coherent atomic allocation? Easy */
|
||||||
if (dma_free_from_pool(cpu_addr, alloc_size))
|
if (dma_free_from_pool(cpu_addr, alloc_size))
|
||||||
return;
|
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));
|
__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,
|
static void *iommu_dma_alloc(struct device *dev, size_t size,
|
||||||
dma_addr_t *handle, gfp_t gfp, unsigned long attrs)
|
dma_addr_t *handle, gfp_t gfp, unsigned long attrs)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue