From: Takashi Iwai Subject: Re: RFC: dma_mmap_coherent() for powerpc/ppc architecture and ALSA? Date: Wed, 14 Jun 2006 16:42:48 +0200 Message-ID: References: <20060610082223.321730@gmx.net> <20060612144254.305930@gmx.net> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20060612144254.305930@gmx.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@lists.sourceforge.net Errors-To: alsa-devel-bounces@lists.sourceforge.net To: Gerhard Pircher Cc: linuxppc-dev@ozlabs.org, rlrevell@joe-job.com, alsa-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, benh@kernel.crashing.org List-Id: alsa-devel@alsa-project.org At Mon, 12 Jun 2006 16:42:54 +0200, Gerhard Pircher wrote: > > > > But as far as I understand this would require a rewrite of all the > > > ALSA drivers (or at least a rewrite of the ALSA's DMA helper > > > functions). > > > > Yes. The change of ALSA side has been also on my tree. But it was > > still pending since I'm not satisfied with the design yet. > > If you're interested in it, let me know. I'll post the patch. > > Yes, please! Then I can test, if the dma_mmap_coherent() patch works on > my non cache coherent powerpc machine. For using dma_mmap_coherent(), the patch below should suffice. (Also you need to enable HAVE_DMA_MMAP_COHERENT there not only for ARM.) > Do you think the DMA Layer/ALSA patches will go upstream in one of > the next ALSA/Linux kernel versions? Definitely no 2.6.18 material yet. Takashi diff -r 08577d0b45ef sound/core/pcm_native.c --- a/sound/core/pcm_native.c Tue Jun 13 12:01:14 2006 +0200 +++ b/sound/core/pcm_native.c Wed Jun 14 16:40:32 2006 +0200 @@ -3123,6 +3123,10 @@ static int snd_pcm_mmap_control(struct s } #endif /* coherent mmap */ +#if defined(CONFIG_ARM) +#define HAVE_DMA_MMAP_COHERENT +#endif + /* * nopage callback for mmapping a RAM page */ @@ -3166,6 +3170,14 @@ static struct vm_operations_struct snd_p .nopage = snd_pcm_mmap_data_nopage, }; +#ifdef HAVE_DMA_MMAP_COHERENT +static struct vm_operations_struct snd_pcm_vm_ops_data_one_map = +{ + .open = snd_pcm_mmap_data_open, + .close = snd_pcm_mmap_data_close, +}; +#endif + /* * mmap the DMA buffer on RAM */ @@ -3175,6 +3187,16 @@ static int snd_pcm_default_mmap(struct s area->vm_ops = &snd_pcm_vm_ops_data; area->vm_private_data = substream; area->vm_flags |= VM_RESERVED; +#ifdef HAVE_DMA_MMAP_COHERENT + if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) { + area->vm_ops = &snd_pcm_vm_ops_data_one_map; + if (dma_mmap_coherent(substream->dma_buffer.dev.dev, area, + substream->runtime->dma_area, + substream->runtime->dma_addr, + area->vm_end - area->vm_start)) + return -EAGAIN; + } +#endif atomic_inc(&substream->mmap_count); return 0; }