2 * Dynamic DMA mapping support.
4 * On cris there is no hardware dynamic DMA address translation,
5 * so consistent alloc/free are merely page allocation/freeing.
6 * The rest of the dynamic DMA mapping interface is implemented
12 #include <linux/types.h>
14 #include <linux/string.h>
15 #include <linux/pci.h>
18 void *dma_alloc_coherent(struct device *dev, size_t size,
19 dma_addr_t *dma_handle, gfp_t gfp)
22 int order = get_order(size);
23 /* ignore region specifiers */
24 gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
26 if (dma_alloc_from_coherent(dev, size, dma_handle, &ret))
29 if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
32 ret = (void *)__get_free_pages(gfp, order);
36 *dma_handle = virt_to_phys(ret);
41 void dma_free_coherent(struct device *dev, size_t size,
42 void *vaddr, dma_addr_t dma_handle)
44 int order = get_order(size);
46 if (!dma_release_from_coherent(dev, order, vaddr))
47 free_pages((unsigned long)vaddr, order);