Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=2a3eeba88f935b200245d1536b99cd4b7eec1d4a
Commit:     2a3eeba88f935b200245d1536b99cd4b7eec1d4a
Parent:     e760e716d47b48caf98da348368fd41b4a9b9e7e
Author:     Magnus Damm <[EMAIL PROTECTED]>
AuthorDate: Fri Jan 25 12:42:48 2008 +0900
Committer:  Paul Mundt <[EMAIL PROTECTED]>
CommitDate: Thu Feb 14 14:22:07 2008 +0900

    sh: declared coherent memory support V2 fix
    
    This patch fixes the recently introduced declared coherent memory support.
    Without this fix a cached memory area is returned by dma_alloc_coherent() -
    unless dma_declare_coherent_memory() has setup a separate area.
    
    This patch makes sure an uncached memory area is returned. With this patch
    it is now possible to ping through an rtl8139 interface on r2d-plus.
    
    Signed-off-by: Magnus Damm <[EMAIL PROTECTED]>
    Signed-off-by: Paul Mundt <[EMAIL PROTECTED]>
---
 arch/sh/mm/consistent.c |   30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
index 7b2131c..d3c33fc 100644
--- a/arch/sh/mm/consistent.c
+++ b/arch/sh/mm/consistent.c
@@ -26,7 +26,7 @@ struct dma_coherent_mem {
 void *dma_alloc_coherent(struct device *dev, size_t size,
                           dma_addr_t *dma_handle, gfp_t gfp)
 {
-       void *ret;
+       void *ret, *ret_nocache;
        struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
        int order = get_order(size);
 
@@ -44,17 +44,24 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
        }
 
        ret = (void *)__get_free_pages(gfp, order);
-
-       if (ret != NULL) {
-               memset(ret, 0, size);
-               /*
-                * Pages from the page allocator may have data present in
-                * cache. So flush the cache before using uncached memory.
-                */
-               dma_cache_sync(NULL, ret, size, DMA_BIDIRECTIONAL);
-               *dma_handle = virt_to_phys(ret);
+       if (!ret)
+               return NULL;
+
+       memset(ret, 0, size);
+       /*
+        * Pages from the page allocator may have data present in
+        * cache. So flush the cache before using uncached memory.
+        */
+       dma_cache_sync(dev, ret, size, DMA_BIDIRECTIONAL);
+
+       ret_nocache = ioremap_nocache(virt_to_phys(ret), size);
+       if (!ret_nocache) {
+               free_pages((unsigned long)ret, order);
+               return NULL;
        }
-       return ret;
+
+       *dma_handle = virt_to_phys(ret);
+       return ret_nocache;
 }
 EXPORT_SYMBOL(dma_alloc_coherent);
 
@@ -71,7 +78,8 @@ void dma_free_coherent(struct device *dev, size_t size,
        } else {
                WARN_ON(irqs_disabled());       /* for portability */
                BUG_ON(mem && mem->flags & DMA_MEMORY_EXCLUSIVE);
-               free_pages((unsigned long)vaddr, order);
+               free_pages((unsigned long)phys_to_virt(dma_handle), order);
+               iounmap(vaddr);
        }
 }
 EXPORT_SYMBOL(dma_free_coherent);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to