]> git.hungrycats.org Git - linux/commitdiff
[ARM] Extend DMA API on ARM for DMA-able writecombining memory.
authorRussell King <rmk@flint.arm.linux.org.uk>
Mon, 29 Mar 2004 12:16:20 +0000 (13:16 +0100)
committerRussell King <rmk@flint.arm.linux.org.uk>
Mon, 29 Mar 2004 12:16:20 +0000 (13:16 +0100)
This is mainly for ARM framebuffer drivers, some of which are
presently either open-coding this functionality, or using some
internal ARM architecture function to get what they want.

arch/arm/mm/consistent.c
include/asm-arm/dma-mapping.h

index 9e666ec1814edab1ef4678b15803df7af2b2f30e..3b98c4806f02c57f83d30f8df56f223a34f122d3 100644 (file)
@@ -226,6 +226,20 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, int gfp)
 }
 EXPORT_SYMBOL(dma_alloc_coherent);
 
+/*
+ * Allocate a writecombining region, in much the same way as
+ * dma_alloc_coherent above.
+ */
+void *
+dma_alloc_writecombine(struct device *dev, size_t size, dma_addr_t *handle, int gfp)
+{
+       if (dev == NULL || *dev->dma_mask != 0xffffffff)
+               gfp |= GFP_DMA;
+
+       return consistent_alloc(gfp, size, handle, PTE_BUFFERABLE);
+}
+EXPORT_SYMBOL(dma_alloc_writecombine);
+
 /*
  * free a page as defined by the above mapping.
  */
index 84f16fadef30cbfe09ac801b2142a3e23416097b..653b01bce2856477212c4761b2813f46fe5882be 100644 (file)
@@ -106,6 +106,23 @@ dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
        consistent_free(cpu_addr, size, handle);
 }
 
+/**
+ * dma_alloc_writecombine - allocate writecombining memory for DMA
+ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
+ * @size: required memory size
+ * @handle: bus-specific DMA address
+ *
+ * Allocate some uncached, buffered memory for a device for
+ * performing DMA.  This function allocates pages, and will
+ * return the CPU-viewed address, and sets @handle to be the
+ * device-viewed address.
+ */
+extern void *
+dma_alloc_writecombine(struct device *dev, size_t size, dma_addr_t *handle, int gfp);
+
+#define dma_free_writecombine(dev,size,cpu_addr,handle) \
+       dma_free_coherent(dev,size,cpu_addr,handle)
+
 /**
  * dma_map_single - map a single buffer for streaming DMA
  * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices