linux-mips
[Top] [All Lists]

Re: About MIPS specific dma_mmap_coherent()

To: wuzhangjin@gmail.com
Subject: Re: About MIPS specific dma_mmap_coherent()
From: Takashi Iwai <tiwai@suse.de>
Date: Wed, 14 Apr 2010 17:46:13 +0200
Cc: Ralf Baechle <ralf@linux-mips.org>, linux-mips <linux-mips@linux-mips.org>
In-reply-to: <1271235619.25872.148.camel@falcon>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1271134735.25797.35.camel@falcon> <s5hmxx7z4a7.wl%tiwai@suse.de> <1271218889.25872.27.camel@falcon> <s5hzl164kay.wl%tiwai@suse.de> <1271235619.25872.148.camel@falcon>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Wanderlust/2.15.6 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.7 Emacs/23.1 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO)
At Wed, 14 Apr 2010 17:00:19 +0800,
Wu Zhangjin wrote:
> 
> On Wed, 2010-04-14 at 08:31 +0200, Takashi Iwai wrote:
> [...]
> > > 
> > > Before, we have added the low-level handling with pgprot_noncached() in
> > > snd_pcm_mmap() to fix it, but now, can we add MIPS specific
> > > dma_mmap_coherent() as ARM did?
> > 
> > That would be a certainly fix, yes.  I have no objection, of course ;)
> > A quicky, less-intrusive one would be the patch below.
> 
> The below patch works well, just tested it.

Thanks.

But, I remember vaguely that calling pgprot_noncached()
unconditionally is dangerous.  It should be checked somehow, e.g. via
platform_device_is_coherent().  And, this found only in
dma-coherence.h, and adding it to pcm_native.c would become messy like
below...

So, it'd be really better to add dma_mmap_coherent(), indeed.


Takashi

---
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index c22ebb0..4c3edc1 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -36,6 +36,9 @@
 #include <sound/timer.h>
 #include <sound/minors.h>
 #include <asm/io.h>
+#if defined(CONFIG_MIPS) && defined(CONFIG_DMA_NONCOHERENT)
+#include <dma-coherence.h>
+#endif
 
 /*
  *  Compatibility
@@ -3188,6 +3191,10 @@ static int snd_pcm_default_mmap(struct snd_pcm_substream 
*substream,
                                         substream->runtime->dma_area,
                                         substream->runtime->dma_addr,
                                         area->vm_end - area->vm_start);
+#elif defined(CONFIG_MIPS) && defined(CONFIG_DMA_NONCOHERENT)
+       if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV &&
+           !plat_device_is_coherent(substream->dma_buffer.dev.dev))
+               area->vm_page_prot = pgprot_noncached(area->vm_page_prot);
 #endif /* ARCH_HAS_DMA_MMAP_COHERENT */
        /* mmap with fault handler */
        area->vm_ops = &snd_pcm_vm_ops_data_fault;

<Prev in Thread] Current Thread [Next in Thread>