From f8ac04255dc8baa1c018e8028222d842efa56e6b Mon Sep 17 00:00:00 2001 From: Yoichi Yuasa Date: Thu, 4 Jun 2009 00:16:04 +0900 Subject: MIPS: Add DMA declare coherent memory support The ohci-sm501 driver requires dma_declare_coherent_memory(). It is used by the driver's local memory allocation with dma_alloc_coherent(). Tested on TANBAC TB0287(VR4131 + SM501). [Ralf: Fixed reject in dma-default.c and removed the entire #if 0'ed block in dma-mapping.h instead of just the #if 0.] Signed-off-by: Yoichi Yuasa Signed-off-by: Ralf Baechle --- arch/mips/mm/dma-default.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'arch/mips/mm/dma-default.c') diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c index 7e48e76148aa..9367e33fbd18 100644 --- a/arch/mips/mm/dma-default.c +++ b/arch/mips/mm/dma-default.c @@ -90,6 +90,9 @@ void *dma_alloc_coherent(struct device *dev, size_t size, { void *ret; + if (dma_alloc_from_coherent(dev, size, dma_handle, &ret)) + return ret; + gfp = massage_gfp_flags(dev, gfp); ret = (void *) __get_free_pages(gfp, get_order(size)); @@ -122,6 +125,10 @@ void dma_free_coherent(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle) { unsigned long addr = (unsigned long) vaddr; + int order = get_order(size); + + if (dma_release_from_coherent(dev, order, vaddr)) + return; plat_unmap_dma_mem(dev, dma_handle, size, DMA_BIDIRECTIONAL); -- cgit v1.2.3-59-g8ed1b