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 08:31:17 +0200
Cc: Ralf Baechle <ralf@linux-mips.org>, linux-mips <linux-mips@linux-mips.org>
In-reply-to: <1271218889.25872.27.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>
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 12:21:29 +0800,
Wu Zhangjin wrote:
> 
> Hi,
> 
> > > $ mplayer -ao alsa file.mp3
> > > 
> > > but without it, the ALSA output is broken.
> > 
> > Hm, which driver/device are you using?  Also, how is it broken?
> 
> I'm using the cs5535 audio in my Yeeloong laptop with the config
> "CONFIG_SND_CS5535AUDIO=m"
> 
> the above 'broken' means there is audio output with ALSA, but the output
> is not normal for it has lots of noises: sha sha sha... 
> 
> > 
> > There is already a low-level hack in sound/core/pcm_native.c for MIPS,
> > so I thought the kernel oops should have been avoided, at least.
> > Maybe still pgprot_noncached() is missing, though.
> 
> You mean this part for MIPS:
> 
> static inline struct page *
> snd_pcm_default_page_ops(struct snd_pcm_substream *substream, unsigned
> long ofs) 
> {
>         void *vaddr = substream->runtime->dma_area + ofs; 
> #if defined(CONFIG_MIPS) && defined(CONFIG_DMA_NONCOHERENT)
>         if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV)
>                 return virt_to_page(CAC_ADDR(vaddr));
> #endif
> 
> ...
> }
> 
> Yes, it was already there from one of your patches to linux-2.6.33, but
> the pgprot_noncached() was missing as you mentioned above.
> 
> And I have found you have added the ARM specific dma_mmap_coherent() to
> snd_pcm_default_mmap() to mmap the DMA buffer on RAM:
> 
> /*
>  * mmap the DMA buffer on RAM
>  */
> static int snd_pcm_default_mmap(struct snd_pcm_substream *substream,
>                                 struct vm_area_struct *area)
> {
>         area->vm_flags |= VM_RESERVED;
> #ifdef ARCH_HAS_DMA_MMAP_COHERENT
>         if (!substream->ops->page &&
>             substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV)
>                 return dma_mmap_coherent(substream->dma_buffer.dev.dev,
>                                          area,
>                                          substream->runtime->dma_area,
>                                          substream->runtime->dma_addr,
>                                          area->vm_end - area->vm_start);
> #endif /* ARCH_HAS_DMA_MMAP_COHERENT */
>         /* mmap with fault handler */
>         area->vm_ops = &snd_pcm_vm_ops_data_fault;
>         return 0;
> }
> 
> 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.


thanks,

Takashi

---
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index c22ebb0..fd6703e 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3188,6 +3188,8 @@ 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)
+       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>