* [PATCH] powerpc: Fix DMA offset for non-coherent DMA
@ 2008-10-10 3:06 Benjamin Herrenschmidt
0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2008-10-10 3:06 UTC (permalink / raw)
To: linuxppc-dev
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>
---
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(-)
--- linux-work.orig/arch/powerpc/kernel/dma.c 2008-10-10 14:04:08.000000000 +1100
+++ linux-work/arch/powerpc/kernel/dma.c 2008-10-10 14:04:30.000000000 +1100
@@ -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 */
Index: linux-work/arch/powerpc/lib/dma-noncoherent.c
===================================================================
--- linux-work.orig/arch/powerpc/lib/dma-noncoherent.c 2008-10-10 14:04:08.000000000 +1100
+++ linux-work/arch/powerpc/lib/dma-noncoherent.c 2008-10-10 14:04:12.000000000 +1100
@@ -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));
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] powerpc: Fix DMA offset for non-coherent DMA
@ 2008-10-10 2:52 Benjamin Herrenschmidt
0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2008-10-10 2:52 UTC (permalink / raw)
To: linuxppc-dev
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 | 7 ++++++-
arch/powerpc/lib/dma-noncoherent.c | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
--- linux-work.orig/arch/powerpc/kernel/dma.c 2008-10-10 10:51:22.000000000 +1100
+++ linux-work/arch/powerpc/kernel/dma.c 2008-10-10 10:51:57.000000000 +1100
@@ -30,8 +30,13 @@ 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;
Index: linux-work/arch/powerpc/lib/dma-noncoherent.c
===================================================================
--- linux-work.orig/arch/powerpc/lib/dma-noncoherent.c 2008-10-10 10:52:17.000000000 +1100
+++ linux-work/arch/powerpc/lib/dma-noncoherent.c 2008-10-10 10:52:21.000000000 +1100
@@ -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));
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-10-10 3:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-10 3:06 [PATCH] powerpc: Fix DMA offset for non-coherent DMA Benjamin Herrenschmidt
-- strict thread matches above, loose matches on Subject: below --
2008-10-10 2:52 Benjamin Herrenschmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).