From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH] Kernel crash Date: Wed, 15 Sep 2004 12:24:03 +0200 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: References: <20040911210212.317d930b.pochini@shiny.it> <20040913220729.466531ce.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: <20040913220729.466531ce.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 Mon, 13 Sep 2004 22:07:29 +0200, Giuliano Pochini wrote: > > On Mon, 13 Sep 2004 17:00:21 +0200 > Takashi Iwai wrote: > > > > I added some code in the hw_free callback to avoid the crash and some debug > > > lines in pcm_native.c and I got this trace: > > > > > > pcm_trigger start > > > [...] > > > pcm_native.c:1241: snd_pcm_playback_drain (state=RUNNING) > > > pcm_native.c:1294: snd_pcm_playback_drain not empty > > > pcm_native.c:1204: snd_pcm_change_state(DRAINING) > > > pcm_native.c:1457: snd_pcm_capture_drop (state=DRAINING) > > > pcm_native.c:1204: snd_pcm_change_state(SETUP) > > > > > > This changes the state of both substreams to SETUP, so > > > snd_pcm_playback/capture_drain/drop() functions will not call _stop() > > > anymore. > > > > > > pcm_native.c:1359: snd_pcm_playback_drop (state=SETUP) > > > pcm_hw_free(play) <--- BUG! > > > pcm_close > > > pcm_native.c:snd_pcm_capture_drop (state=SETUP) > > > pcm_hw_free(capt) > > > pcm_close > > > > I see. > > > > > I developed this patch, but I'm not sure it's ok. The first part probably is > > > not required but it seems more correct IMHO. > > > > The first one should be ok. > > I'm also not 100% sure about the second one after the short glance. > > > > The problem is that we have no DMA running state in runtime struct. > > DMA is supposed to be running in DRAINING state for playback, while > > it's to be stopped in DRAINING capture. > > I guessed the DMA is going on in RUNNING and DRAINING states only. Actually > I just noticed that my patch is wrong: in PREPARED state DMA is off and > snd_pcm_stop() should not be called if state is SNDRV_PCM_STATE_XRUN because > snd_pcm_xrun() already stopped it. > > (compiled and tested ok) I believe the second part is not needed. DRAINING in capture implies that the DMA is already stopped (like XRUN). If the second part really fixes the problem, the bug is in somewhere else. Takashi > > > --- pcm_native.c_orig Sat Sep 11 15:29:51 2004 > +++ pcm_native.c Mon Sep 13 21:51:05 2004 > @@ -1280,7 +1280,8 @@ > break; > } > > - if (runtime->status->state == SNDRV_PCM_STATE_RUNNING) { > + if (runtime->status->state == SNDRV_PCM_STATE_RUNNING || > + runtime->status->state == SNDRV_PCM_STATE_DRAINING) { > if (snd_pcm_playback_empty(substream)) { > snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); > goto _end; > @@ -1464,9 +1465,14 @@ > if (res < 0) > goto _end; > /* Fall through */ > - case SNDRV_PCM_STATE_PREPARED: > case SNDRV_PCM_STATE_DRAINING: > + if (snd_pcm_update_hw_ptr(substream) >= 0) { > + snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); > + break; > + } > + /* Fall through */ > case SNDRV_PCM_STATE_XRUN: > + case SNDRV_PCM_STATE_PREPARED: > snd_pcm_change_state(substream, SNDRV_PCM_STATE_SETUP); > break; > default: > > > > -- > Giuliano. > > > ------------------------------------------------------- > This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 > Project Admins to receive an Apple iPod Mini FREE for your judgement on > who ports your project to Linux PPC the best. Sponsored by IBM. > Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php > _______________________________________________ > Alsa-devel mailing list > Alsa-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/alsa-devel > ------------------------------------------------------- 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