* ASoC: atmel-pcm-dma: Leaking memory in atmel_pcm_hw_params
@ 2013-03-17 14:39 Lars-Peter Clausen
2013-03-18 3:59 ` Bo Shen
0 siblings, 1 reply; 4+ messages in thread
From: Lars-Peter Clausen @ 2013-03-17 14:39 UTC (permalink / raw)
To: Bo Shen, Nicolas Ferre; +Cc: Linux-ALSA
Hi,
The dmaengine based pcm driver for atmel calls snd_dmaengine_pcm_open from
it's hw_params callback. There is nothing preventing an application calling
hw_params more than once. snd_dmaengine_pcm_open allocates a new prtd struct
each time it gets called. So in case hw_params is called multiple times we
leak memory here.
Is there any specific reason why snd_dmaengine_pcm_open() needs to be called
from the hw_params callback and why it can't be called from the open
callback? The filter function depends on the data returned by
snd_soc_dai_get_dma_data(), but as far as I can see the DAI driver calls
snd_soc_dai_set_dma_data() from its startup() callback, so the data is
available in the PCM drivers open callback.
- Lars
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ASoC: atmel-pcm-dma: Leaking memory in atmel_pcm_hw_params
2013-03-17 14:39 ASoC: atmel-pcm-dma: Leaking memory in atmel_pcm_hw_params Lars-Peter Clausen
@ 2013-03-18 3:59 ` Bo Shen
2013-03-18 15:36 ` Lars-Peter Clausen
0 siblings, 1 reply; 4+ messages in thread
From: Bo Shen @ 2013-03-18 3:59 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Linux-ALSA, Nicolas Ferre
Hi Lars,
On 3/17/2013 22:39, Lars-Peter Clausen wrote:
> Hi,
>
> The dmaengine based pcm driver for atmel calls snd_dmaengine_pcm_open from
> it's hw_params callback. There is nothing preventing an application calling
> hw_params more than once. snd_dmaengine_pcm_open allocates a new prtd struct
> each time it gets called. So in case hw_params is called multiple times we
> leak memory here.
I use alsa utils and don't meet this issue. Please point out which
software you use meet this issue.
> Is there any specific reason why snd_dmaengine_pcm_open() needs to be called
> from the hw_params callback and why it can't be called from the open
> callback?
This is because dma data setting and usage.
The filter function depends on the data returned by
> snd_soc_dai_get_dma_data(), but as far as I can see the DAI driver calls
> snd_soc_dai_set_dma_data() from its startup() callback, so the data is
> available in the PCM drivers open callback.
Have you test this yet?
>
> - Lars
>
Best Regards,
Bo Shen
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ASoC: atmel-pcm-dma: Leaking memory in atmel_pcm_hw_params
2013-03-18 3:59 ` Bo Shen
@ 2013-03-18 15:36 ` Lars-Peter Clausen
2013-03-19 1:18 ` Bo Shen
0 siblings, 1 reply; 4+ messages in thread
From: Lars-Peter Clausen @ 2013-03-18 15:36 UTC (permalink / raw)
To: Bo Shen; +Cc: Linux-ALSA, Nicolas Ferre
On 03/18/2013 04:59 AM, Bo Shen wrote:
> Hi Lars,
>
> On 3/17/2013 22:39, Lars-Peter Clausen wrote:
>> Hi,
>>
>> The dmaengine based pcm driver for atmel calls snd_dmaengine_pcm_open from
>> it's hw_params callback. There is nothing preventing an application calling
>> hw_params more than once. snd_dmaengine_pcm_open allocates a new prtd struct
>> each time it gets called. So in case hw_params is called multiple times we
>> leak memory here.
>
> I use alsa utils and don't meet this issue. Please point out which software
> you use meet this issue.
I found the issue by looking at the code, but I think any application using
the oss compatibility layer of ALSA will trigger this.
>
>> Is there any specific reason why snd_dmaengine_pcm_open() needs to be called
>> from the hw_params callback and why it can't be called from the open
>> callback?
>
> This is because dma data setting and usage.
>
> The filter function depends on the data returned by
>> snd_soc_dai_get_dma_data(), but as far as I can see the DAI driver calls
>> snd_soc_dai_set_dma_data() from its startup() callback, so the data is
>> available in the PCM drivers open callback.
>
> Have you test this yet?
I don't have the hardware. I just looked at the code again, and it looks
like I must have misread it the first time. snd_soc_dai_set_dma_data() is
called from the DAI drivers hwparams callback. But the data that gets passed
to snd_soc_dai_set_dma_data() doesn't really depend on anything that's only
available in the hwparams callback. So the snd_soc_dai_set_dma_data() could
easily be move to the DAI driver startup() callback.
- Lars
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ASoC: atmel-pcm-dma: Leaking memory in atmel_pcm_hw_params
2013-03-18 15:36 ` Lars-Peter Clausen
@ 2013-03-19 1:18 ` Bo Shen
0 siblings, 0 replies; 4+ messages in thread
From: Bo Shen @ 2013-03-19 1:18 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Linux-ALSA, Nicolas Ferre
Hi Lars,
On 3/18/2013 23:36, Lars-Peter Clausen wrote:
> On 03/18/2013 04:59 AM, Bo Shen wrote:
>> Hi Lars,
>>
>> On 3/17/2013 22:39, Lars-Peter Clausen wrote:
>>> Hi,
>>>
>>> The dmaengine based pcm driver for atmel calls snd_dmaengine_pcm_open from
>>> it's hw_params callback. There is nothing preventing an application calling
>>> hw_params more than once. snd_dmaengine_pcm_open allocates a new prtd struct
>>> each time it gets called. So in case hw_params is called multiple times we
>>> leak memory here.
>>
>> I use alsa utils and don't meet this issue. Please point out which software
>> you use meet this issue.
>
> I found the issue by looking at the code, but I think any application using
> the oss compatibility layer of ALSA will trigger this.
Thanks for this information.
>
>>
>>> Is there any specific reason why snd_dmaengine_pcm_open() needs to be called
>>> from the hw_params callback and why it can't be called from the open
>>> callback?
>>
>> This is because dma data setting and usage.
>>
>> The filter function depends on the data returned by
>>> snd_soc_dai_get_dma_data(), but as far as I can see the DAI driver calls
>>> snd_soc_dai_set_dma_data() from its startup() callback, so the data is
>>> available in the PCM drivers open callback.
>>
>> Have you test this yet?
>
> I don't have the hardware. I just looked at the code again, and it looks
> like I must have misread it the first time. snd_soc_dai_set_dma_data() is
> called from the DAI drivers hwparams callback. But the data that gets passed
> to snd_soc_dai_set_dma_data() doesn't really depend on anything that's only
> available in the hwparams callback. So the snd_soc_dai_set_dma_data() could
> easily be move to the DAI driver startup() callback.
I will implement this, and send patch for this.
Thanks again.
> - Lars
>
Best Regards,
Bo Shen
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-03-19 1:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-17 14:39 ASoC: atmel-pcm-dma: Leaking memory in atmel_pcm_hw_params Lars-Peter Clausen
2013-03-18 3:59 ` Bo Shen
2013-03-18 15:36 ` Lars-Peter Clausen
2013-03-19 1:18 ` Bo Shen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox