From: Lars-Peter Clausen <lars@metafoo.de>
To: Mark Brown <broonie@kernel.org>
Cc: tiwai@suse.de, Qiao Zhou <zhouqiao@marvell.com>,
alsa-devel@alsa-project.org, zhangfei.gao@gmail.com
Subject: Re: [PATCH] ASoC: dmaengine: add runtime status checking in dmaengine_pcm_dma_complete
Date: Sun, 09 Jun 2013 15:37:16 +0200 [thread overview]
Message-ID: <51B4850C.5090508@metafoo.de> (raw)
In-Reply-To: <20130607143428.GR31367@sirena.org.uk>
On 06/07/2013 04:34 PM, Mark Brown wrote:
> On Fri, Jun 07, 2013 at 07:57:29PM +0800, Qiao Zhou wrote:
>> the dmaengine_pcm_dma_complete callback is usually executed after
>> the dma interrupt, which uses tasklet_schedule, workqueue, or other
>> method for quick int handler return.
>>
>> in some corner case, where pcm stream is released unexpected, like
>> media server is killed, the runtime parameter will be freed. if it
>> happens between the t1 and t2 in below chart, then the callback
>> will try to access members of paramters which is already freed,
>> and kernel panics.
>>
>> to avoid this issue, add runtime checking before other handling in
>> dmaengine_pcm_dma_complete. if pcm stream is already released,
>> just ignore the current handling and return.
>
> This doesn't seem like a good or robust way of fixing this, if we're
> tearing down the resources the DMA is using while the DMA is in progress
> then in the worst case that might include the memory being DMAed and of
> course there's races if you just check the pointer - the pointer can be
> checked at the same time as it's being freed (or between the free and
> the clear).
>
> I think we should be either halting the DMA or waiting for it to finish
> here.
I haven't see the original patch, but the proper solution to this problem
should be to add a check to snd_dmaengine_pcm_close() to see if the DMA is
still running, and if it is call dmaengine_terminate_all() for the DMA channel
associated with the PCM. Everything else will probably still be racy.
- Lars
next prev parent reply other threads:[~2013-06-09 13:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1370606249-19955-1-git-send-email-zhouqiao@marvell.com>
2013-06-07 14:34 ` [PATCH] ASoC: dmaengine: add runtime status checking in dmaengine_pcm_dma_complete Mark Brown
2013-06-09 13:37 ` Lars-Peter Clausen [this message]
2013-06-09 13:51 ` Lars-Peter Clausen
2013-06-10 9:31 ` Mark Brown
2013-06-10 10:46 ` Lars-Peter Clausen
2013-06-12 7:43 ` Vinod Koul
2013-06-12 12:15 ` Lars-Peter Clausen
2013-06-12 14:39 ` Mark Brown
2013-06-14 9:10 ` Qiao Zhou
[not found] ` <51B2EC7A.8090309@marvell.com>
2013-06-10 9:30 ` Mark Brown
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=51B4850C.5090508@metafoo.de \
--to=lars@metafoo.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=tiwai@suse.de \
--cc=zhangfei.gao@gmail.com \
--cc=zhouqiao@marvell.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 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.