aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mm/dma-mapping.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2009-11-19 15:58:31 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-11-24 12:41:35 -0500
commitebd7a845fa4332da3ebcbe8cf1b09bb43413420e (patch)
tree07bb3b78fd2bbe3705fb040f6ad1f5da6b5a625c /arch/arm/mm/dma-mapping.c
parent88c58f3b92bc7c26439802c300d39b6377739d81 (diff)
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,
189 struct page *page; 189 struct page *page;
190 struct arm_vmregion *c; 190 struct arm_vmregion *c;
191 191
192 if (!consistent_pte[0]) {
193 printk(KERN_ERR "%s: not initialised\n", __func__);
194 dump_stack();
195 return NULL;
196 }
197
198 size = PAGE_ALIGN(size); 192 size = PAGE_ALIGN(size);
199 193
200 page = __dma_alloc_buffer(dev, size, gfp); 194 page = __dma_alloc_buffer(dev, size, gfp);
201 if (!page) 195 if (!page)
202 goto no_page; 196 goto no_page;
203 197
198 if (arch_is_coherent()) {
199 *handle = page_to_dma(dev, page);
200 return page_address(page);
201 }
202
203 if (!consistent_pte[0]) {
204 printk(KERN_ERR "%s: not initialised\n", __func__);
205 dump_stack();
206 __dma_free_buffer(page, size);
207 return NULL;
208 }
209
204 /* 210 /*
205 * Allocate a virtual address in the consistent mapping region. 211 * Allocate a virtual address in the consistent mapping region.
206 */ 212 */
@@ -342,19 +348,6 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gf
342 if (dma_alloc_from_coherent(dev, size, handle, &memory)) 348 if (dma_alloc_from_coherent(dev, size, handle, &memory))
343 return memory; 349 return memory;
344 350
345 if (arch_is_coherent()) {
346 struct page *page;
347
348 page = __dma_alloc_buffer(dev, PAGE_ALIGN(size), gfp);
349 if (!page) {
350 *handle = ~0;
351 return NULL;
352 }
353
354 *handle = page_to_dma(dev, page);
355 return page_address(page);
356 }
357
358 return __dma_alloc(dev, size, handle, gfp, 351 return __dma_alloc(dev, size, handle, gfp,
359 pgprot_noncached(pgprot_kernel)); 352 pgprot_noncached(pgprot_kernel));
360} 353}