All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Giuliano Pochini <pochini@shiny.it>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: [PATCH] Kernel crash
Date: Mon, 13 Sep 2004 17:00:21 +0200	[thread overview]
Message-ID: <s5hekl6tdru.wl@alsa2.suse.de> (raw)
In-Reply-To: <20040911210212.317d930b.pochini@shiny.it>

At Sat, 11 Sep 2004 21:02:12 +0200,
Giuliano Pochini wrote:
> 
> On Tue, 07 Sep 2004 09:55:02 +0200 (CEST)
> Giuliano Pochini <pochini@shiny.it> wrote:
> 
> > On 06-Sep-2004 Takashi Iwai wrote:
> > 
> > >> It successfully crashes my system after a few attempts:
> > >>
> > >> Linux Jay 2.6.8.1 #2 SMP Wed Aug 18 15:14:51 CEST 2004 ppc unknown
> > >> booted with maxcpus=1 and without preempt.
> > >> alsa-driver-1.0.6a and CVS-2004-09-05
> > >> alsa-lib-1.0.4
> > >> gcc 3.4.1
> > >>
> > >> with both the powermac (Snapper) driver and my Echoaudio driver.
> > >
> > > It doesn't crash on my system with SB live with the latest CVS
> > > version but segfaults at line 263 because c is bogus.
> > > The crash looks likely driver-specific, then.
> > 
> > No, I don't think so. I already found (one of?) the cause, but
> > I forgot to mention it again, sorry. It happens because ALSA
> > calls the .free() pcm callback without calling .trigger(STOP)
> > and .close() first. Jaroslav posted a patch which didn't work,
> > then the discussion stopped. The problem occurs only when the
> > substreams are linked and the userpace app is badly broken
> > like mine.
> 
> 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.


Takashi


> 
> 
> --- alsa-kernel/core/pcm_native.c_orig	Sat Sep 11 15:29:51 2004
> +++ alsa-kernel/core/pcm_native.c	Sat Sep 11 20:54:32 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;
> @@ -1467,7 +1468,10 @@
>  	case SNDRV_PCM_STATE_PREPARED:
>  	case SNDRV_PCM_STATE_DRAINING:
>  	case SNDRV_PCM_STATE_XRUN:
> -		snd_pcm_change_state(substream, SNDRV_PCM_STATE_SETUP);
> +		if (snd_pcm_update_hw_ptr(substream) >= 0)
> +			snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP);
> +		else
> +			snd_pcm_change_state(substream, SNDRV_PCM_STATE_SETUP);
>  		break;
>  	default: 
>  		break; 
> 
> 
> 
> --
> 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

  reply	other threads:[~2004-09-13 15:00 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 [this message]
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
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=s5hekl6tdru.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 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.