All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Nicolin Chen <b42378@freescale.com>
Cc: tiwai@suse.de, alsa-devel@alsa-project.org, broonie@kernel.org,
	lgirdwood@gmail.com
Subject: Re: [PATCH 1/2] ALSA: Add SoC on-chip internal memory support for DMA buffer allocation
Date: Wed, 16 Oct 2013 10:55:03 +0200	[thread overview]
Message-ID: <525E5467.5090301@metafoo.de> (raw)
In-Reply-To: <03ed477b729fd972b896d52312666e5773d8dfec.1381911378.git.b42378@freescale.com>

On 10/16/2013 10:18 AM, Nicolin Chen wrote:
> Now it's quite common that an SoC contains its on-chip internal memory.
> By using this memory space for DMA buffer during audio playback/record,
> we can shutdown the voltage for external memory to save power.
> 
> Thus add new DEV type with iram malloc()/free() and accordingly modify
> current default mmap() for the iram circumstance.
> 
> Signed-off-by: Nicolin Chen <b42378@freescale.com>

I think this is much better then having each machine add custom callbacks
for it.

[...]
> +
> +#ifdef CONFIG_OF
> +/**
> + * snd_malloc_dev_iram - allocate memory from on-chip internal memory
> + * @dev: DMA device pointer
> + * @size: number of bytes to allocate from the iram
> + * @dma: dma-view physical address
> + *
> + * Return cpu-view address or NULL indicating allocating failure
> + *
> + * This function requires iram phandle provided via of_node
> + */
> +void *snd_malloc_dev_iram(struct device *dev, size_t size, dma_addr_t *dma)
> +{
> +	struct gen_pool *pool = of_get_named_gen_pool(dev->of_node, "iram", 0);

dev will be the dma controller device not the audio controller device. This
means the iram property needs to be specified on dma controller node and
will be shared by all users of that controller. Is this the intention?

Also I think you need to check whether of_node is NULL before passing it to
of_get_named_gen_pool.

> +	unsigned long vaddr;
> +
> +	if (!pool)
> +		return NULL;
> +
> +	vaddr = gen_pool_alloc(pool, size);
> +	if (!vaddr)
> +		return NULL;
> +
> +	if (dma)

This check will always be true.

> +		*dma = gen_pool_virt_to_phys(pool, vaddr);
> +
> +	return (void *)vaddr;
> +}
> +
> +/**
> + * 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
> + * @dma: dma-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, dma_addr_t dma)
> +{
> +	struct gen_pool *pool = of_get_named_gen_pool(dev->of_node, "iram", 0);
> +	if (!pool)
> +		return;
> +
> +	gen_pool_free(pool, (unsigned long)ptr, size);
> +
> +	ptr = NULL;

This ...

> +
> +	if (dma)
> +		dma = 0;

... and this assignment are noops

> +}
> +#endif /* CONFIG_OF */
>  #endif /* CONFIG_HAS_DMA */

  parent reply	other threads:[~2013-10-16  8:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-16  8:18 [PATCH 1/2] ALSA: Add SoC on-chip internal memory support for DMA buffer allocation Nicolin Chen
2013-10-16  8:18 ` [PATCH 2/2] ASoC: generic-dmaengine-pcm: Support on-chip internal memory for DMA buffer Nicolin Chen
2013-10-16  8:56   ` Lars-Peter Clausen
2013-10-16  8:51     ` Nicolin Chen
2013-10-16  8:55 ` Lars-Peter Clausen [this message]
2013-10-16  8:48   ` [PATCH 1/2] ALSA: Add SoC on-chip internal memory support for DMA buffer allocation Nicolin Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=525E5467.5090301@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=b42378@freescale.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.