public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [MMC] wbsd: use dma_alloc insted of kmalloc
@ 2005-09-25 19:16 Pierre Ossman
  2005-09-25 19:29 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Pierre Ossman @ 2005-09-25 19:16 UTC (permalink / raw)
  To: rmk+lkml; +Cc: Pierre Ossman, linux-kernel

x86_64 doesn't seem to like being passed pointers allocated using
kmalloc to the DMA mapping API. Change allocation to use
dma_alloc_coherent() instead.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
---

 drivers/mmc/wbsd.c |   26 +++++++++++---------------
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c
--- a/drivers/mmc/wbsd.c
+++ b/drivers/mmc/wbsd.c
@@ -1543,18 +1543,17 @@ static void __devinit wbsd_request_dma(s
 	 * We need to allocate a special buffer in
 	 * order for ISA to be able to DMA to it.
 	 */
-	host->dma_buffer = kmalloc(WBSD_DMA_SIZE,
+
+	mmc_dev(host->mmc)->coherent_dma_mask = 0xffffff;
+	mmc_dev(host->mmc)->dma_mask = &mmc_dev(host->mmc)->coherent_dma_mask;
+
+	host->dma_buffer = dma_alloc_coherent(mmc_dev(host->mmc),
+		WBSD_DMA_SIZE, &host->dma_addr,
 		GFP_NOIO | GFP_DMA | __GFP_REPEAT | __GFP_NOWARN);
 	if (!host->dma_buffer)
 		goto free;
 
 	/*
-	 * Translate the address to a physical address.
-	 */
-	host->dma_addr = dma_map_single(host->mmc->dev, host->dma_buffer,
-		WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
-
-	/*
 	 * ISA DMA must be aligned on a 64k basis.
 	 */
 	if ((host->dma_addr & 0xffff) != 0)
@@ -1575,12 +1574,11 @@ kfree:
 	 */
 	BUG_ON(1);
 
-	dma_unmap_single(host->mmc->dev, host->dma_addr, WBSD_DMA_SIZE,
-		DMA_BIDIRECTIONAL);
-	host->dma_addr = (dma_addr_t)NULL;
+	dma_free_coherent(mmc_dev(host->mmc), WBSD_DMA_SIZE,
+		host->dma_buffer, host->dma_addr);
 
-	kfree(host->dma_buffer);
 	host->dma_buffer = NULL;
+	host->dma_addr = (dma_addr_t)NULL;
 
 free:
 	free_dma(dma);
@@ -1592,11 +1590,9 @@ err:
 
 static void __devexit wbsd_release_dma(struct wbsd_host* host)
 {
-	if (host->dma_addr)
-		dma_unmap_single(host->mmc->dev, host->dma_addr, WBSD_DMA_SIZE,
-			DMA_BIDIRECTIONAL);
 	if (host->dma_buffer)
-		kfree(host->dma_buffer);
+		dma_free_coherent(mmc_dev(host->mmc), WBSD_DMA_SIZE,
+			host->dma_buffer, host->dma_addr);
 	if (host->dma >= 0)
 		free_dma(host->dma);
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [MMC] wbsd: use dma_alloc insted of kmalloc
  2005-09-25 19:16 [PATCH] [MMC] wbsd: use dma_alloc insted of kmalloc Pierre Ossman
@ 2005-09-25 19:29 ` Christoph Hellwig
  2005-09-25 19:37   ` Pierre Ossman
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2005-09-25 19:29 UTC (permalink / raw)
  To: Pierre Ossman; +Cc: rmk+lkml, Pierre Ossman, linux-kernel

On Sun, Sep 25, 2005 at 09:16:23PM +0200, Pierre Ossman wrote:
> x86_64 doesn't seem to like being passed pointers allocated using
> kmalloc to the DMA mapping API.

How so?  There's not much else that could be passed to dma_map_single.

Please try to fix x86_64 instead.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [MMC] wbsd: use dma_alloc insted of kmalloc
  2005-09-25 19:29 ` Christoph Hellwig
@ 2005-09-25 19:37   ` Pierre Ossman
  0 siblings, 0 replies; 3+ messages in thread
From: Pierre Ossman @ 2005-09-25 19:37 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: rmk+lkml, linux-kernel, Andi Kleen

Christoph Hellwig wrote:
> On Sun, Sep 25, 2005 at 09:16:23PM +0200, Pierre Ossman wrote:
> 
>>x86_64 doesn't seem to like being passed pointers allocated using
>>kmalloc to the DMA mapping API.
> 
> 
> How so?  There's not much else that could be passed to dma_map_single.

It kept oopsing on dma_map_single(). I'm guessing it expects som
structures to be present for its IOMMU.

http://list.drzeus.cx/pipermail/wbsd-devel/2005-September/000335.html

> 
> Please try to fix x86_64 instead.

I'm not familiar with the x86_64 IOMMU, I don't even have access to the
hardware. So I figured I'd side-step the problem since there was an API
avaiable that works more reliably.

Andi might be more up to the task?

Rgds
Pierre

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-09-25 19:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-25 19:16 [PATCH] [MMC] wbsd: use dma_alloc insted of kmalloc Pierre Ossman
2005-09-25 19:29 ` Christoph Hellwig
2005-09-25 19:37   ` Pierre Ossman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox