alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Javier Martin <javier.martin@vista-silicon.com>
Cc: alsa-devel@alsa-project.org, broonie@opensource.wolfsonmicro.com,
	arnaud.patard@rtp-net.org
Subject: Re: [PATCH] ASoC: Fix DMA channel leak in imx-pcm-dma-mx2 driver.
Date: Tue, 17 Jan 2012 09:19:51 +0100	[thread overview]
Message-ID: <20120117081951.GT5446@pengutronix.de> (raw)
In-Reply-To: <1326367838-12947-1-git-send-email-javier.martin@vista-silicon.com>

On Thu, Jan 12, 2012 at 12:30:38PM +0100, Javier Martin wrote:
> "snd_imx_pcm_hw_params" callback can be called
> several times by the user (i.e. OSS emulation)
> leading to a DMA channel leak.

Then maybe this means that imx_ssi_dma_alloc is called from the wrong
place. I think it should be called from the
snd_soc_platform_driver.pcm_new callback.

Sascha

> 
> Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
> ---
>  sound/soc/imx/imx-pcm-dma-mx2.c |   12 +++++++-----
>  1 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/sound/soc/imx/imx-pcm-dma-mx2.c b/sound/soc/imx/imx-pcm-dma-mx2.c
> index 43fdc24..d2bb1cb 100644
> --- a/sound/soc/imx/imx-pcm-dma-mx2.c
> +++ b/sound/soc/imx/imx-pcm-dma-mx2.c
> @@ -88,11 +88,13 @@ static int imx_ssi_dma_alloc(struct snd_pcm_substream *substream,
>  	iprtd->dma_data.dma_request = dma_params->dma;
>  
>  	/* Try to grab a DMA channel */
> -	dma_cap_zero(mask);
> -	dma_cap_set(DMA_SLAVE, mask);
> -	iprtd->dma_chan = dma_request_channel(mask, filter, iprtd);
> -	if (!iprtd->dma_chan)
> -		return -EINVAL;
> +	if (!iprtd->dma_chan) {
> +		dma_cap_zero(mask);
> +		dma_cap_set(DMA_SLAVE, mask);
> +		iprtd->dma_chan = dma_request_channel(mask, filter, iprtd);
> +		if (!iprtd->dma_chan)
> +			return -EINVAL;
> +	}
>  
>  	switch (params_format(params)) {
>  	case SNDRV_PCM_FORMAT_S16_LE:
> -- 
> 1.7.0.4
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

      reply	other threads:[~2012-01-17  8:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-12 11:30 [PATCH] ASoC: Fix DMA channel leak in imx-pcm-dma-mx2 driver Javier Martin
2012-01-17  8:19 ` Sascha Hauer [this message]

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=20120117081951.GT5446@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=arnaud.patard@rtp-net.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=javier.martin@vista-silicon.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).