arch/frv: add option to skip sync on DMA map
authorAlexander Duyck <alexander.h.duyck@intel.com>
Wed, 14 Dec 2016 23:04:43 +0000 (15:04 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 15 Dec 2016 00:04:07 +0000 (16:04 -0800)
The use of DMA_ATTR_SKIP_CPU_SYNC was not consistent across all of the
DMA APIs in the arch/arm folder.  This change is meant to correct that
so that we get consistent behavior.

Link: http://lkml.kernel.org/r/20161110113447.76501.93160.stgit@ahduyck-blue-test.jf.intel.com
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/frv/mb93090-mb00/pci-dma-nommu.c
arch/frv/mb93090-mb00/pci-dma.c

index 90f2e4c..1876881 100644 (file)
@@ -109,16 +109,19 @@ static int frv_dma_map_sg(struct device *dev, struct scatterlist *sglist,
                int nents, enum dma_data_direction direction,
                unsigned long attrs)
 {
-       int i;
        struct scatterlist *sg;
+       int i;
+
+       BUG_ON(direction == DMA_NONE);
+
+       if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+               return nents;
 
        for_each_sg(sglist, sg, nents, i) {
                frv_cache_wback_inv(sg_dma_address(sg),
                                    sg_dma_address(sg) + sg_dma_len(sg));
        }
 
-       BUG_ON(direction == DMA_NONE);
-
        return nents;
 }
 
@@ -127,7 +130,10 @@ static dma_addr_t frv_dma_map_page(struct device *dev, struct page *page,
                enum dma_data_direction direction, unsigned long attrs)
 {
        BUG_ON(direction == DMA_NONE);
-       flush_dcache_page(page);
+
+       if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+               flush_dcache_page(page);
+
        return (dma_addr_t) page_to_phys(page) + offset;
 }
 
index f585745..dba7df9 100644 (file)
@@ -40,13 +40,16 @@ static int frv_dma_map_sg(struct device *dev, struct scatterlist *sglist,
                int nents, enum dma_data_direction direction,
                unsigned long attrs)
 {
+       struct scatterlist *sg;
        unsigned long dampr2;
        void *vaddr;
        int i;
-       struct scatterlist *sg;
 
        BUG_ON(direction == DMA_NONE);
 
+       if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
+               return nents;
+
        dampr2 = __get_DAMPR(2);
 
        for_each_sg(sglist, sg, nents, i) {
@@ -70,7 +73,9 @@ static dma_addr_t frv_dma_map_page(struct device *dev, struct page *page,
                unsigned long offset, size_t size,
                enum dma_data_direction direction, unsigned long attrs)
 {
-       flush_dcache_page(page);
+       if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+               flush_dcache_page(page);
+
        return (dma_addr_t) page_to_phys(page) + offset;
 }