summaryrefslogtreecommitdiffstats
path: root/arch/arm/mm/dma-mapping.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2009-11-19 21:58:31 +0100
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-11-24 18:41:35 +0100
commitebd7a845fa4332da3ebcbe8cf1b09bb43413420e (patch)
tree07bb3b78fd2bbe3705fb040f6ad1f5da6b5a625c /arch/arm/mm/dma-mapping.c
parentARM: dma-mapping: move consistent_init into CONFIG_MMU section (diff)
downloadlinux-ebd7a845fa4332da3ebcbe8cf1b09bb43413420e.tar.xz
linux-ebd7a845fa4332da3ebcbe8cf1b09bb43413420e.zip
ARM: dma-mapping: clean up coherent arch dma allocation
IXP23xx added support for dma_alloc_coherent() for DMA arches with an exception in dma_alloc_coherent(). This is a subset of what goes on in __dma_alloc(), and there is no reason why dma_alloc_writecombine() should not be given the same treatment (except, maybe, that IXP23xx doesn't use it.) We can better deal with this by moving the arch_is_coherent() test inside __dma_alloc() and killing the code duplication. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Acked-by: Greg Ungerer <gerg@uclinux.org>
Diffstat (limited to 'arch/arm/mm/dma-mapping.c')
-rw-r--r--arch/arm/mm/dma-mapping.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 19357f76ce89..3a8e527c774c 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -189,18 +189,24 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
struct page *page;
struct arm_vmregion *c;
- if (!consistent_pte[0]) {
- printk(KERN_ERR "%s: not initialised\n", __func__);
- dump_stack();
- return NULL;
- }
-
size = PAGE_ALIGN(size);
page = __dma_alloc_buffer(dev, size, gfp);
if (!page)
goto no_page;
+ if (arch_is_coherent()) {
+ *handle = page_to_dma(dev, page);
+ return page_address(page);
+ }
+
+ if (!consistent_pte[0]) {
+ printk(KERN_ERR "%s: not initialised\n", __func__);
+ dump_stack();
+ __dma_free_buffer(page, size);
+ return NULL;
+ }
+
/*
* Allocate a virtual address in the consistent mapping region.
*/
@@ -342,19 +348,6 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gf
if (dma_alloc_from_coherent(dev, size, handle, &memory))
return memory;
- if (arch_is_coherent()) {
- struct page *page;
-
- page = __dma_alloc_buffer(dev, PAGE_ALIGN(size), gfp);
- if (!page) {
- *handle = ~0;
- return NULL;
- }
-
- *handle = page_to_dma(dev, page);
- return page_address(page);
- }
-
return __dma_alloc(dev, size, handle, gfp,
pgprot_noncached(pgprot_kernel));
}