aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2009-11-19 10:54:45 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-11-24 12:41:34 -0500
commit04da56943b416dd9fe7058abf8d5b9153164b3e9 (patch)
tree24541a1e46b9f660d3b33845d1e31b0d0c4918d0 /arch/arm
parent3e82d012e9281a0b6388ff2356e8396b9d781e1c (diff)
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')
-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 a67130873431..62b4240b34b3 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -212,24 +212,17 @@ static void *
212__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp, 212__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
213 pgprot_t prot) 213 pgprot_t prot)
214{ 214{
215 void *virt; 215 struct page *page;
216 u64 mask = get_coherent_dma_mask(dev);
217
218 if (!mask)
219 goto error;
220 216
221 if (mask < 0xffffffffULL) 217 *handle = ~0;
222 gfp |= GFP_DMA; 218 size = PAGE_ALIGN(size);
223 virt = kmalloc(size, gfp);
224 if (!virt)
225 goto error;
226 219
227 *handle = virt_to_dma(dev, virt); 220 page = __dma_alloc_buffer(dev, size, gfp);
228 return virt; 221 if (!page)
222 return NULL;
229 223
230error: 224 *handle = page_to_dma(dev, page);
231 *handle = ~0; 225 return page_address(page);
232 return NULL;
233} 226}
234#endif /* CONFIG_MMU */ 227#endif /* CONFIG_MMU */
235 228
@@ -406,7 +399,7 @@ void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, dma_addr
406{ 399{
407 if (dma_release_from_coherent(dev, get_order(size), cpu_addr)) 400 if (dma_release_from_coherent(dev, get_order(size), cpu_addr))
408 return; 401 return;
409 kfree(cpu_addr); 402 __dma_free_buffer(dma_to_page(dev, handle), PAGE_ALIGN(size));
410} 403}
411#endif /* CONFIG_MMU */ 404#endif /* CONFIG_MMU */
412EXPORT_SYMBOL(dma_free_coherent); 405EXPORT_SYMBOL(dma_free_coherent);