From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964986AbWFNOm7 (ORCPT ); Wed, 14 Jun 2006 10:42:59 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S964988AbWFNOm7 (ORCPT ); Wed, 14 Jun 2006 10:42:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:52878 "EHLO mx2.suse.de") by vger.kernel.org with ESMTP id S964986AbWFNOm6 (ORCPT ); Wed, 14 Jun 2006 10:42:58 -0400 Date: Wed, 14 Jun 2006 16:42:48 +0200 Message-ID: From: Takashi Iwai 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 Subject: Re: [Alsa-devel] RFC: dma_mmap_coherent() for powerpc/ppc architecture and ALSA? In-Reply-To: <20060612144254.305930@gmx.net> References: <20060610082223.321730@gmx.net> <20060612144254.305930@gmx.net> User-Agent: Wanderlust/2.12.0 (Your Wildest Dreams) SEMI/1.14.6 (Maruoka) FLIM/1.14.7 (=?ISO-8859-4?Q?Sanj=F2?=) APEL/10.6 MULE XEmacs/21.5 (beta25) (eggplant) (+CVS-20060326) (i386-suse-linux) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.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; }