From: Lars-Peter Clausen <lars@metafoo.de>
To: Shengjiu Wang <shengjiu.wang@freescale.com>
Cc: dmaengine <dmaengine@vger.kernel.org>, alsa-devel@alsa-project.org
Subject: Re: Issue in alsa when dma complete race with pcm release
Date: Mon, 06 Jul 2015 14:27:01 +0200 [thread overview]
Message-ID: <559A7415.8000006@metafoo.de> (raw)
In-Reply-To: <20150706090113.GA4995@shlinux2>
On 07/06/2015 11:01 AM, Shengjiu Wang wrote:
> On Fri, Jul 03, 2015 at 12:56:53PM +0200, Lars-Peter Clausen wrote:
>> On 07/03/2015 10:25 AM, Shengjiu Wang wrote:
>>> Hi alsa-devel
>>>
>>> There maybe a issue in ALSA when dma complete race with snd_pcm_release.
>>> The pcm release and dma complete are in different thread. There is occasion
>>> that dmaengine_pcm_dma_complete() is called too late, some memory has been
>>> freed, the prtd is null. Then there is kernel dump.
>>>
>>> Is there any solution for this issue? Thanks.
>>
>> We need to introduce a synchronization primitive that allows a
>> dmaengine client to synchronize to the execution of the complete
>> callbacks.
>>
>> terminate_all() unfortunately can't do this since terminate_all()
>> might be called from within one of the complete callbacks and so
>> would cause a deadlock if we'd wait for all complete callbacks to
>> finish before terminate_all() returns.
>>
>> So what is needed is a new function called dmaengine_sync() that
>> will wait until all scheduled complete callbacks have finished. A
>> call to this function needs to be put in snd_dmaengine_pcm_close()
>> before the prtd is closed.
>>
>> - Lars
>
> How to check " all scheduled complete callbacks have finished"?
That will be up to the dmaengine driver. But it basically comes down to two
things:
1) The driver needs to make sure that tasklet_schedule() is no longer called
after terminate_all() has finished.
2) In the sync() callback call tasklet_kill() to make sure that it has
finished running
>
> One concern is if add wait in snd_dmaengine_pcm_close(), which wil cause
> the snd_pcm_release is bound with dmaengine, when there is error in dma
> and no callback be called. Then the snd_pcm_release will not be released.
The sync() function will only wait if there is a callback scheduled, if
there is non scheduled it will return immediately.
next prev parent reply other threads:[~2015-07-06 12:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-03 8:25 Issue in alsa when dma complete race with pcm release Shengjiu Wang
2015-07-03 10:56 ` Lars-Peter Clausen
2015-07-06 9:01 ` Shengjiu Wang
2015-07-06 12:27 ` Lars-Peter Clausen [this message]
2015-07-07 10:13 ` Shengjiu Wang
2015-07-07 13:32 ` Lars-Peter Clausen
2015-07-15 1:37 ` Shengjiu Wang
2015-07-15 7:13 ` Lars-Peter Clausen
2015-07-15 7:00 ` Shengjiu Wang
2015-07-15 8:59 ` Lars-Peter Clausen
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=559A7415.8000006@metafoo.de \
--to=lars@metafoo.de \
--cc=alsa-devel@alsa-project.org \
--cc=dmaengine@vger.kernel.org \
--cc=shengjiu.wang@freescale.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