Skip to contentSkip to conversation

powerpc: Fix DMA offset for non-coherent DMA

PATCH New Benjamin Herrenschmidt 1 participant 1 message Oct 10, 2008 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---

v2. This one fixes a typo that I introduced when rebasing/cleaning
up a larger patch to produce this one that causes void *ret to be defined twice for coherent platforms

 arch/powerpc/kernel/dma.c          |    8 ++++++--
 arch/powerpc/lib/dma-noncoherent.c |    2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)
arch/powerpc/kernel/dma.c +6 -2
@@ -30,11 +30,15 @@ static unsigned long get_dma_direct_offs
 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 */
arch/powerpc/lib/dma-noncoherent.c +1 -1
Index: linux-work/arch/powerpc/lib/dma-noncoherent.c
===================================================================
@@ -203,7 +203,7 @@ __dma_alloc_coherent(size_t size, dma_ad
 		/*
 		 * Set the "dma handle"
 		 */
-		*handle = page_to_bus(page);
+		*handle = page_to_phys(page);
 
 		do {
 			BUG_ON(!pte_none(*pte));