]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00181107 add dma_alloc_writethrough function
authorSandor Yu <R01008@freescale.com>
Fri, 27 Apr 2012 09:16:10 +0000 (17:16 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:34:32 +0000 (08:34 +0200)
add dma_alloc_writethrough function to dma_mapping.c

Signed-off-by: Sandor Yu <R01008@freescale.com>
arch/arm/include/asm/dma-mapping.h
arch/arm/include/asm/pgtable.h
arch/arm/mm/dma-mapping.c

index 4fff837363edd93249a0884d11f0fabc2ec6db30..d9b4badee6b26af51dfff23c4093204775bf0c3d 100644 (file)
@@ -185,6 +185,19 @@ static inline void dma_free_noncoherent(struct device *dev, size_t size,
  */
 extern void *dma_alloc_coherent(struct device *, size_t, dma_addr_t *, gfp_t);
 
+/**
+ * dma_alloc_writethrough - allocate consistent 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 writethrough cached,  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_writethrough(struct device *, size_t, dma_addr_t *, gfp_t);
+
 /**
  * dma_free_coherent - free memory allocated by dma_alloc_coherent
  * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
index 5750704e02718b9247704021a0832f161bcbaf3b..6682ab9314517b64700baa20655e987e8f868995 100644 (file)
@@ -232,6 +232,9 @@ extern pgprot_t             pgprot_kernel;
 #define pgprot_writecombine(prot) \
        __pgprot_modify(prot, L_PTE_MT_MASK, L_PTE_MT_BUFFERABLE)
 
+#define pgprot_writethrough(prot) \
+       __pgprot_modify(prot, L_PTE_MT_MASK, L_PTE_MT_WRITETHROUGH)
+
 #ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE
 #define pgprot_dmacoherent(prot) \
        __pgprot_modify(prot, L_PTE_MT_MASK, L_PTE_MT_BUFFERABLE | L_PTE_XN)
index f96d2c7300207ee8bd47b4ba4b19abe49f4bee06..79e05f69631c86912dd173db7002159264975fdd 100644 (file)
@@ -357,6 +357,18 @@ dma_alloc_writecombine(struct device *dev, size_t size, dma_addr_t *handle, gfp_
 }
 EXPORT_SYMBOL(dma_alloc_writecombine);
 
+/*
+ *  Allocate DMA-writethrough memory space and return both the kernel remapped
+ * virtual and bus address for that space.
+ */
+void *
+dma_alloc_writethrough(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp)
+{
+       return __dma_alloc(dev, size, handle, gfp,
+                         pgprot_writethrough(pgprot_kernel));
+}
+EXPORT_SYMBOL(dma_alloc_writethrough);
+
 static int dma_mmap(struct device *dev, struct vm_area_struct *vma,
                    void *cpu_addr, dma_addr_t dma_addr, size_t size)
 {