From: Takashi Iwai Subject: Re: [PATCH v6] ALSA: Add SoC on-chip internal memory support for DMA buffer allocation Date: Tue, 22 Oct 2013 15:24:41 +0200 Message-ID: References: <1382410849-11906-1-git-send-email-b42378@freescale.com> <52666A30.7030102@metafoo.de> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id F1C0A26533E for ; Tue, 22 Oct 2013 15:21:45 +0200 (CEST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Nicole Otsuka Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen , broonie@kernel.org, Nicolin Chen , lgirdwood@gmail.com List-Id: alsa-devel@alsa-project.org At Tue, 22 Oct 2013 20:49:49 +0800, Nicole Otsuka wrote: > > On Tue, Oct 22, 2013 at 8:06 PM, Lars-Peter Clausen wrote: > > > On 10/22/2013 05:00 AM, Nicolin Chen wrote: > > [...] > > > +/** > > > + * snd_free_dev_iram - free allocated specific memory from on-chip > > internal memory > > > + * @dev: DMA device pointer > > > + * @size: size in bytes of memory to free > > > + * @ptr: cpu-view address returned from snd_malloc_dev_iram > > > + * > > > + * This function requires iram phandle provided via of_node > > > + */ > > > +void snd_free_dev_iram(struct device *dev, size_t size, void *ptr) > > > +{ > > > + struct gen_pool *pool = NULL; > > > + > > > + if (!dev->of_node) > > > + return; > > > + > > > + pool = of_get_named_gen_pool(dev->of_node, "iram", 0); > > > + if (!pool) > > > + return; > > > > I've had a closer look at the other SNDRV_DMA_TYPE implementations and I > > think a better way to handle this is to assign the pool to the > > snd_dma_buffer's private_data field and then use it here instead of looking > > the pool up again. This will also make it easier to use a non-OF lookup > > scheme. > > > > > By saving the pool to pdata during the allocating? Hmm..that should be > nicer. > > Just need to change the parameter "struct device *" to "struct gen_pool > *" directly > > I'll see what I can do to refine it. Thank you for the suggestion. I guess Lars meant to use simply snd_dma_buffer.private_data field for storing the pool pointer in snd_malloc_dev_iram(), and use this pointer instead of calling of_get_named_gen_pool() again in snd_free_dev_iram(). Takashi