powerpc: Fix DMA offset for non-coherent DMA

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Wednesday, October 15, 2008 - 12:09 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=8aa265...
Commit:     8aa2659009714cf5f9ffe7f3e16ccfa8ff0e0d61
Parent:     1263965f298af611d4992165242202eb194db1c1
Author:     Benjamin Herrenschmidt <benh@kernel.crashing.org>
AuthorDate: Thu Oct 9 17:06:24 2008 +0000
Committer:  Benjamin Herrenschmidt <benh@kernel.crashing.org>
CommitDate: Tue Oct 14 10:35:26 2008 +1100

    powerpc: Fix DMA offset for non-coherent DMA
    
    After Becky's work we can almost have different DMA offsets
    between on-chip devices and PCI. Almost because there's a
    problem with the non-coherent DMA code that basically ignores
    the programmed offset to use the global one for everything.
    This fixes it.
    
    Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/powerpc/kernel/dma.c          |    8 ++++++--
 arch/powerpc/lib/dma-noncoherent.c |    2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index 41fdd48..1562daf 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -30,11 +30,15 @@ static unsigned long get_dma_direct_offset(struct device *dev)
 void *dma_direct_alloc_coherent(struct device *dev, size_t size,
 				dma_addr_t *dma_handle, gfp_t flag)
 {
+	void *ret;
 #ifdef CONFIG_NOT_COHERENT_CACHE
-	return __dma_alloc_coherent(size, dma_handle, flag);
+	ret = __dma_alloc_coherent(size, dma_handle, flag);
+	if (ret == NULL)
+		return NULL;
+	*dma_handle += get_dma_direct_offset(dev);
+	return ret;
 #else
 	struct page *page;
-	void *ret;
 	int node = dev_to_node(dev);
 
 	/* ignore region specifiers */
diff --git a/arch/powerpc/lib/dma-noncoherent.c b/arch/powerpc/lib/dma-noncoherent.c
index 5d83907..31734c0 100644
--- a/arch/powerpc/lib/dma-noncoherent.c
+++ b/arch/powerpc/lib/dma-noncoherent.c
@@ -203,7 +203,7 @@ __dma_alloc_coherent(size_t size, dma_addr_t *handle, gfp_t gfp)
 		/*
 		 * Set the "dma handle"
 		 */
-		*handle = page_to_bus(page);
+		*handle = page_to_phys(page);
 
 		do {
 			BUG_ON(!pte_none(*pte));
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
powerpc: Fix DMA offset for non-coherent DMA, Linux Kernel Mailing ..., (Wed Oct 15, 12:09 pm)