From: Vinod Koul <vinod.koul@intel.com>
To: Qiao Zhou <zhouqiao@marvell.com>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
Lars-Peter Clausen <lars@metafoo.de>,
"tiwai@suse.de" <tiwai@suse.de>,
"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
"zhangfei.gao@gmail.com" <zhangfei.gao@gmail.com>,
"trinity.qiao.zhou@gmail.com" <trinity.qiao.zhou@gmail.com>,
Chao Xie <cxie4@marvell.com>
Subject: Re: async between dmaengine_pcm_dma_complete and snd_pcm_release
Date: Thu, 10 Oct 2013 21:17:40 +0530 [thread overview]
Message-ID: <20131010154740.GZ2954@intel.com> (raw)
In-Reply-To: <5256403E.6090803@marvell.com>
On Thu, Oct 10, 2013 at 01:50:54PM +0800, Qiao Zhou wrote:
> >1. In dma driver, once terminate_all in invoked, grab the lock, disable the
> >tasklet, pause/stop the dmaengine remove all the descriptors from the lists.
> >This ensures that dmaengine doesnt trigger anything new. And if it does we dont
> >call into client
> what lock do you refer to? is it "snd_pcm_stream_lock" or a new one
> in dma driver?
We are ref dma driver so it would be a dma driver lock.
> >2. If we get an interrupt or tasklet invoked after this, then it is the
> >resposiblity of dma driver to clear interrupt and return
> >
> >3. While you have invoked the terminate_all you might get a callback, in that
> >case the substream is still valid (you are still in TRIGGER_STOP). There should
> >be no harm in calling period_elapsed, but it would be good if we detect that and
> >return from here.
> >
> >4. My only worry is that during callback we drop the locks held, so callback can
> >be running on different CPU while you process the terminate all. This is very
> >racy and possibly the issue being seen in this thread. This gets complicated by
> >that fact that xrun would invoke the stop thus terminate_all.
> The timing is very racy. we have two platforms, of which the only
> difference is that one is 2 * a9 cpu, and the other is 4 * a7 cpu.
> all other components and peripherals are the same. The result is we
> can't reproduce the panic issue after more than 4 days stress test
> on 2-cpu platform, but can reproduce the issue in ~10 hours level on
> the 4-cpu platform.
The only reason I see if dma driver is NOT buggy is that you dma driver already
invoked callback and on different CPU you decided to terminate the audio and
call terminate_all
> >>>>On the other hand that last part could get tricky as the
> >>>>dmaengine_terminate_all() might be call from within the callback.
> >>>It's tricky indeed in case xrun happens. we should avoid possible deadlock.
> >>
> >>I think we'll eventually need to versions of dmaengine_terminate_all(). A
> >>sync version which makes sure that the tasklet has finished and a non-sync
> >>version that only makes sure that no new callbacks are started. I think the
> >>sync version should be the default with an optional async version which must
> >>be used, if it can run from within the callback. So we'd call the async
> >>version in the pcm_trigger callback and the sync version in the pcm_close
> >>callback.
> >Yes this can be done. We can name this disable_callback cmd. The cmd will tell
> >dma driver to disable all callback on the channel. This can be invoked from the
> >TRIGEGR_STOP and then terminate_all in the free
> >
> >Which dma driver are you guys using in this? I will send a patch for the core
> >and pcm layer. Someone need to test on actual hardware with driver fix :)
> >
> I'm using the mmp_tdma driver under /drivers/dma/, and I can test
> the patch on our 4-cpu platform. thanks.
Ok, let me check the driver and also see what needs to be done for this
--
~Vinod
next prev parent reply other threads:[~2013-10-10 16:40 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-09 7:29 async between dmaengine_pcm_dma_complete and snd_pcm_release Qiao Zhou
2013-10-09 8:19 ` Lars-Peter Clausen
2013-10-09 8:30 ` Lars-Peter Clausen
2013-10-09 10:23 ` Qiao Zhou
2013-10-09 11:00 ` Lars-Peter Clausen
2013-10-10 1:05 ` Qiao Zhou
2013-10-10 2:56 ` Vinod Koul
2013-10-10 5:54 ` Qiao Zhou
2013-10-10 2:54 ` Vinod Koul
2013-10-10 5:50 ` Qiao Zhou
2013-10-10 15:47 ` Vinod Koul [this message]
2013-11-05 8:55 ` Qiao Zhou
2013-10-10 7:46 ` Lars-Peter Clausen
2013-10-10 16:10 ` Vinod Koul
2013-10-10 17:53 ` Lars-Peter Clausen
2013-10-13 15:24 ` Vinod Koul
2013-10-13 16:57 ` Lars-Peter Clausen
2013-10-09 10:53 ` Takashi Iwai
2013-10-10 1:08 ` Qiao Zhou
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=20131010154740.GZ2954@intel.com \
--to=vinod.koul@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=cxie4@marvell.com \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=tiwai@suse.de \
--cc=trinity.qiao.zhou@gmail.com \
--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 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).