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:54:45 +0000
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-11-24 17:41:34 +0000
commit04da56943b416dd9fe7058abf8d5b9153164b3e9 (patch)
tree24541a1e46b9f660d3b33845d1e31b0d0c4918d0 /arch/arm/mm/dma-mapping.c
parent3e82d012e9281a0b6388ff2356e8396b9d781e1c (diff)
downloadkernel_samsung_espresso10-04da56943b416dd9fe7058abf8d5b9153164b3e9.zip
kernel_samsung_espresso10-04da56943b416dd9fe7058abf8d5b9153164b3e9.tar.gz
kernel_samsung_espresso10-04da56943b416dd9fe7058abf8d5b9153164b3e9.tar.bz2
ARM: dma-mapping: fix nommu dma_alloc_coherent()
The nommu version of dma_alloc_coherent was using kmalloc/kfree to manage the memory. dma_alloc_coherent() is expected to work with a granularity of a page, so this is wrong. Fix it by using the helper functions now provided. 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.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index a671308..62b4240 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -212,24 +212,17 @@ static void *
__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
pgprot_t prot)
{
- void *virt;
- u64 mask = get_coherent_dma_mask(dev);
-
- if (!mask)
- goto error;
+ struct page *page;
- if (mask < 0xffffffffULL)
- gfp |= GFP_DMA;
- virt = kmalloc(size, gfp);
- if (!virt)
- goto error;
+ *handle = ~0;
+ size = PAGE_ALIGN(size);
- *handle = virt_to_dma(dev, virt);
- return virt;
+ page = __dma_alloc_buffer(dev, size, gfp);
+ if (!page)
+ return NULL;
-error:
- *handle = ~0;
- return NULL;
+ *handle = page_to_dma(dev, page);
+ return page_address(page);
}
#endif /* CONFIG_MMU */
@@ -406,7 +399,7 @@ void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, dma_addr
{
if (dma_release_from_coherent(dev, get_order(size), cpu_addr))
return;
- kfree(cpu_addr);
+ __dma_free_buffer(dma_to_page(dev, handle), PAGE_ALIGN(size));
}
#endif /* CONFIG_MMU */
EXPORT_SYMBOL(dma_free_coherent);