aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/mm/dma-default.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/mm/dma-default.c')
-rw-r--r--arch/mips/mm/dma-default.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 98b5e5bac02e..b1b40527658b 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -13,6 +13,7 @@
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/string.h> 15#include <linux/string.h>
16#include <linux/scatterlist.h>
16 17
17#include <asm/cache.h> 18#include <asm/cache.h>
18#include <asm/io.h> 19#include <asm/io.h>
@@ -165,12 +166,11 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
165 for (i = 0; i < nents; i++, sg++) { 166 for (i = 0; i < nents; i++, sg++) {
166 unsigned long addr; 167 unsigned long addr;
167 168
168 addr = (unsigned long) page_address(sg->page); 169 addr = (unsigned long) sg_virt(sg);
169 if (!plat_device_is_coherent(dev) && addr) 170 if (!plat_device_is_coherent(dev) && addr)
170 __dma_sync(addr + sg->offset, sg->length, direction); 171 __dma_sync(addr, sg->length, direction);
171 sg->dma_address = plat_map_dma_mem(dev, 172 sg->dma_address = plat_map_dma_mem(dev,
172 (void *)(addr + sg->offset), 173 (void *)addr, sg->length);
173 sg->length);
174 } 174 }
175 175
176 return nents; 176 return nents;
@@ -223,10 +223,9 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
223 for (i = 0; i < nhwentries; i++, sg++) { 223 for (i = 0; i < nhwentries; i++, sg++) {
224 if (!plat_device_is_coherent(dev) && 224 if (!plat_device_is_coherent(dev) &&
225 direction != DMA_TO_DEVICE) { 225 direction != DMA_TO_DEVICE) {
226 addr = (unsigned long) page_address(sg->page); 226 addr = (unsigned long) sg_virt(sg);
227 if (addr) 227 if (addr)
228 __dma_sync(addr + sg->offset, sg->length, 228 __dma_sync(addr, sg->length, direction);
229 direction);
230 } 229 }
231 plat_unmap_dma_mem(sg->dma_address); 230 plat_unmap_dma_mem(sg->dma_address);
232 } 231 }
@@ -304,7 +303,7 @@ void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
304 /* Make sure that gcc doesn't leave the empty loop body. */ 303 /* Make sure that gcc doesn't leave the empty loop body. */
305 for (i = 0; i < nelems; i++, sg++) { 304 for (i = 0; i < nelems; i++, sg++) {
306 if (cpu_is_noncoherent_r10000(dev)) 305 if (cpu_is_noncoherent_r10000(dev))
307 __dma_sync((unsigned long)page_address(sg->page), 306 __dma_sync((unsigned long)page_address(sg_page(sg)),
308 sg->length, direction); 307 sg->length, direction);
309 plat_unmap_dma_mem(sg->dma_address); 308 plat_unmap_dma_mem(sg->dma_address);
310 } 309 }
@@ -322,7 +321,7 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nele
322 /* Make sure that gcc doesn't leave the empty loop body. */ 321 /* Make sure that gcc doesn't leave the empty loop body. */
323 for (i = 0; i < nelems; i++, sg++) { 322 for (i = 0; i < nelems; i++, sg++) {
324 if (!plat_device_is_coherent(dev)) 323 if (!plat_device_is_coherent(dev))
325 __dma_sync((unsigned long)page_address(sg->page), 324 __dma_sync((unsigned long)page_address(sg_page(sg)),
326 sg->length, direction); 325 sg->length, direction);
327 plat_unmap_dma_mem(sg->dma_address); 326 plat_unmap_dma_mem(sg->dma_address);
328 } 327 }