From: Takashi Iwai <tiwai@suse.de>
To: Giuliano Pochini <pochini@shiny.it>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: [PATCH] Kernel crash
Date: Wed, 15 Sep 2004 20:01:51 +0200 [thread overview]
Message-ID: <s5hhdpzs968.wl@alsa2.suse.de> (raw)
In-Reply-To: <20040915195008.33713acb.pochini@shiny.it>
At Wed, 15 Sep 2004 19:50:08 +0200,
Giuliano Pochini wrote:
>
> On Wed, 15 Sep 2004 12:24:03 +0200
> Takashi Iwai <tiwai@suse.de> wrote:
>
> > I believe the second part is not needed. DRAINING in capture implies
> > that the DMA is already stopped (like XRUN).
>
> snd_pcm_capture_drain() says:
>
> case SNDRV_PCM_STATE_RUNNING:
> if (snd_pcm_update_hw_ptr(substream) >= 0) {
> snd_pcm_stop(substream,
> snd_pcm_capture_avail(runtime) > 0 ?
> SNDRV_PCM_STATE_DRAINING : SNDRV_PCM_STATE_SETUP);
> break;
> }
> /* Fall through */
> case SNDRV_PCM_STATE_XRUN:
> _xrun_recovery:
> snd_pcm_change_state(substream,
> snd_pcm_capture_avail(runtime) > 0 ?
> SNDRV_PCM_STATE_DRAINING : SNDRV_PCM_STATE_SETUP);
> break;
>
> It may not be stopped when snd_pcm_update_hw_ptr()<0, if I'm not missing
> something.
snd_pcm_update_hw_ptr() returns a negative value only when xrun
happens or the drain is finished. In both cases, snd_pcm_stop() is
called internally before returning from this function.
> > If the second part really fixes the problem, the bug is in somewhere
> > else.
>
> It fixes it and yes, there is another problem: snd_pcm_change_state()
> overrides the state machine.
>
> snd_pcm_playback_drain() (when state=RUNNING) calls
> snd_pcm_change_state(DRAINING). When substreams are linked, it changes the
> state of all linked substreams *without* passing through
> snd_pcm_capture_drain(DRAINING).
>
> I checked all calls to snd_pcm_change_state() and the only problematic one
> is at line 1288 inside snd_pcm_capture_drain(). The problem exists only if
> capture and playback substreams are linked because a capture substream in
> DRAINING state implies it's stopped, while a playback substream doesn't. My
> patch is not the proper fix, but it workarounds the bug by fixing that
> asymmetry. I make snd_pcm_capture_drop() and snd_pcm_playback_drop() behave
> the same wrt DRAINING substreams.
I think it'd be better to add a new field to substream to indicate the
DMA running status so that snd_pcm_stop() can be called safely
regardless of the current status.
The situation right now is a mess, the DMA running state depending on
the stream direction and the state.
Takashi
-------------------------------------------------------
This SF.Net email is sponsored by: thawte's Crypto Challenge Vl
Crack the code and win a Sony DCRHC40 MiniDV Digital Handycam
Camcorder. More prizes in the weekly Lunch Hour Challenge.
Sign up NOW http://ad.doubleclick.net/clk;10740251;10262165;m
next prev parent reply other threads:[~2004-09-15 18:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-05 18:51 Kernel crash Giuliano Pochini
2004-09-06 15:16 ` Takashi Iwai
2004-09-07 7:55 ` Giuliano Pochini
2004-09-11 19:02 ` [PATCH] " Giuliano Pochini
2004-09-13 15:00 ` Takashi Iwai
2004-09-13 20:07 ` Giuliano Pochini
2004-09-15 10:24 ` Takashi Iwai
2004-09-15 17:50 ` Giuliano Pochini
2004-09-15 18:01 ` Takashi Iwai [this message]
2004-09-16 11:16 ` Takashi Iwai
2004-09-16 19:56 ` Giuliano Pochini
2004-09-17 6:54 ` Jaroslav Kysela
2004-09-17 10:22 ` Takashi Iwai
2004-09-17 10:32 ` Takashi Iwai
2004-09-22 8:08 ` Jaroslav Kysela
2004-09-22 10:08 ` Takashi Iwai
2004-09-22 14:12 ` Giuliano Pochini
2004-09-23 7:43 ` Jaroslav Kysela
2004-09-24 13:30 ` Takashi Iwai
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=s5hhdpzs968.wl@alsa2.suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@lists.sourceforge.net \
--cc=pochini@shiny.it \
/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