linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: <linuxppc-dev@ozlabs.org>
Subject: [PATCH] powerpc: Fix DMA offset for non-coherent DMA
Date: Fri, 10 Oct 2008 13:52:29 +1100	[thread overview]
Message-ID: <20081010025257.9E08CDDEFB@ozlabs.org> (raw)

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));

             reply	other threads:[~2008-10-10  2:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-10  2:52 Benjamin Herrenschmidt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-10-10  3:06 [PATCH] powerpc: Fix DMA offset for non-coherent DMA Benjamin Herrenschmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081010025257.9E08CDDEFB@ozlabs.org \
    --to=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).