aboutsummaryrefslogtreecommitdiffstats
path: root/arch/nios2/mm/dma-mapping.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/nios2/mm/dma-mapping.c')
-rw-r--r--arch/nios2/mm/dma-mapping.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/arch/nios2/mm/dma-mapping.c b/arch/nios2/mm/dma-mapping.c
index d800fad87896..f6a5dcf9d682 100644
--- a/arch/nios2/mm/dma-mapping.c
+++ b/arch/nios2/mm/dma-mapping.c
@@ -98,13 +98,17 @@ static int nios2_dma_map_sg(struct device *dev, struct scatterlist *sg,
98 int i; 98 int i;
99 99
100 for_each_sg(sg, sg, nents, i) { 100 for_each_sg(sg, sg, nents, i) {
101 void *addr; 101 void *addr = sg_virt(sg);
102 102
103 addr = sg_virt(sg); 103 if (!addr)
104 if (addr) { 104 continue;
105 __dma_sync_for_device(addr, sg->length, direction); 105
106 sg->dma_address = sg_phys(sg); 106 sg->dma_address = sg_phys(sg);
107 } 107
108 if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
109 continue;
110
111 __dma_sync_for_device(addr, sg->length, direction);
108 } 112 }
109 113
110 return nents; 114 return nents;
@@ -117,7 +121,9 @@ static dma_addr_t nios2_dma_map_page(struct device *dev, struct page *page,
117{ 121{
118 void *addr = page_address(page) + offset; 122 void *addr = page_address(page) + offset;
119 123
120 __dma_sync_for_device(addr, size, direction); 124 if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
125 __dma_sync_for_device(addr, size, direction);
126
121 return page_to_phys(page) + offset; 127 return page_to_phys(page) + offset;
122} 128}
123 129
@@ -125,7 +131,8 @@ static void nios2_dma_unmap_page(struct device *dev, dma_addr_t dma_address,
125 size_t size, enum dma_data_direction direction, 131 size_t size, enum dma_data_direction direction,
126 unsigned long attrs) 132 unsigned long attrs)
127{ 133{
128 __dma_sync_for_cpu(phys_to_virt(dma_address), size, direction); 134 if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
135 __dma_sync_for_cpu(phys_to_virt(dma_address), size, direction);
129} 136}
130 137
131static void nios2_dma_unmap_sg(struct device *dev, struct scatterlist *sg, 138static void nios2_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
@@ -138,6 +145,9 @@ static void nios2_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
138 if (direction == DMA_TO_DEVICE) 145 if (direction == DMA_TO_DEVICE)
139 return; 146 return;
140 147
148 if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
149 return;
150
141 for_each_sg(sg, sg, nhwentries, i) { 151 for_each_sg(sg, sg, nhwentries, i) {
142 addr = sg_virt(sg); 152 addr = sg_virt(sg);
143 if (addr) 153 if (addr)