From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH] Kernel crash Date: Wed, 15 Sep 2004 20:01:51 +0200 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: References: <20040911210212.317d930b.pochini@shiny.it> <20040913220729.466531ce.pochini@shiny.it> <20040915195008.33713acb.pochini@shiny.it> Mime-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <20040915195008.33713acb.pochini@shiny.it> Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Giuliano Pochini Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org At Wed, 15 Sep 2004 19:50:08 +0200, Giuliano Pochini wrote: > > On Wed, 15 Sep 2004 12:24:03 +0200 > Takashi Iwai 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