linux-mips
[Top] [All Lists]

[PATCH 1/2] Set of fixes for DMA when dma_addr_t != physical addr

To: linux-mips@linux-mips.org
Subject: [PATCH 1/2] Set of fixes for DMA when dma_addr_t != physical address
From: David VomLehn <dvomlehn@cisco.com>
Date: Wed, 25 Nov 2009 15:00:24 -0500
Authentication-results: sj-iport-5.cisco.com; dkim=neutral (message not signed) header.i=none
Cc: ralf@linux-mips.org
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.5.18 (2008-05-17)
From: Jon Fraser <jfraser@broadcom.com>
DMA changes from Jon Fraser, slightly tweaked for 2.6.30.

Signed-off-by: Jon Fraser <jfraser@broadcom.com>
Signed-off-by: David VomLehn <dvomlehn@cisco.com>
---
 arch/mips/mm/dma-default.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 4fdb7f5..70cff1f 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -135,6 +135,9 @@ EXPORT_SYMBOL(dma_free_coherent);
 static inline void __dma_sync(unsigned long addr, size_t size,
        enum dma_data_direction direction)
 {
+
+       BUG_ON(addr < KSEG0);
+
        switch (direction) {
        case DMA_TO_DEVICE:
                dma_cache_wback(addr, size);
@@ -188,11 +191,13 @@ int dma_map_sg(struct device *dev, struct scatterlist 
*sg, int nents,
        for (i = 0; i < nents; i++, sg++) {
                unsigned long addr;
 
+               BUG_ON(!sg_page(sg));
+
                addr = (unsigned long) sg_virt(sg);
-               if (!plat_device_is_coherent(dev) && addr)
+               if (!plat_device_is_coherent(dev) && (addr >= KSEG0))
                        __dma_sync(addr, sg->length, direction);
-               sg->dma_address = plat_map_dma_mem(dev,
-                                                  (void *)addr, sg->length);
+
+               sg->dma_address = sg_phys(sg);
        }
 
        return nents;
@@ -229,7 +234,7 @@ void dma_unmap_sg(struct device *dev, struct scatterlist 
*sg, int nhwentries,
                if (!plat_device_is_coherent(dev) &&
                    direction != DMA_TO_DEVICE) {
                        addr = (unsigned long) sg_virt(sg);
-                       if (addr)
+                       if (addr >= KSEG0)
                                __dma_sync(addr, sg->length, direction);
                }
                plat_unmap_dma_mem(dev, sg->dma_address);
@@ -359,6 +364,7 @@ void dma_cache_sync(struct device *dev, void *vaddr, size_t 
size,
               enum dma_data_direction direction)
 {
        BUG_ON(direction == DMA_NONE);
+       BUG_ON(vaddr < (void *)KSEG0);
 
        plat_extra_sync_for_device(dev);
        if (!plat_device_is_coherent(dev))

<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH 1/2] Set of fixes for DMA when dma_addr_t != physical address, David VomLehn <=