From: Takashi Iwai Subject: Re: USB audio devices & kernel panics Date: Mon, 21 Feb 2011 11:18:06 +0100 Message-ID: References: <4D5E839E.6030500@canonical.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 69A6A243E4 for ; Mon, 21 Feb 2011 11:18:07 +0100 (CET) In-Reply-To: <4D5E839E.6030500@canonical.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Moustafa Chamli Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Fri, 18 Feb 2011 09:35:10 -0500, Moustafa Chamli wrote: > > Hello, > > I was told to ask at the alsa-dev list as to if there's a known bug and > fix with USB audio devices causing kernel panics. A bug was reported on > Launchpad stating that it is fully reproducible: > > https://bugs.launchpad.net/ubuntu/+source/linux/+bug/715318 Could you try the patch below? thanks, Takashi --- diff --git a/sound/usb/card.c b/sound/usb/card.c index 800f7cb..b452aa4 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -323,6 +323,7 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, return -ENOMEM; } + init_mutex(&chip->shutdown_mutex); chip->index = idx; chip->dev = dev; chip->card = card; @@ -531,6 +532,7 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, void *ptr) chip = ptr; card = chip->card; mutex_lock(®ister_mutex); + mutex_lock(&chip->shutdown_mutex); chip->shutdown = 1; chip->num_interfaces--; if (chip->num_interfaces <= 0) { @@ -548,9 +550,11 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, void *ptr) snd_usb_mixer_disconnect(p); } usb_chip[chip->index] = NULL; + mutex_unlock(&chip->shutdown_mutex); mutex_unlock(®ister_mutex); snd_card_free_when_closed(card); } else { + mutex_unlock(&chip->shutdown_mutex); mutex_unlock(®ister_mutex); } } diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 4132522..ca4de49 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -385,8 +385,10 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream) subs->cur_audiofmt = NULL; subs->cur_rate = 0; subs->period_bytes = 0; + mutex_lock(&subs->stream->chip->shutdown_mutex); if (!subs->stream->chip->shutdown) snd_usb_release_substream_urbs(subs, 0); + mutex_unlock(&subs->stream->chip->shutdown_mutex); return snd_pcm_lib_free_vmalloc_buffer(substream); } diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index db3eb21..6e66fff 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h @@ -36,6 +36,7 @@ struct snd_usb_audio { struct snd_card *card; u32 usb_id; int shutdown; + struct mutex shutdown_mutex; unsigned int txfr_quirk:1; /* Subframe boundaries on transfers */ int num_interfaces; int num_suspended_intf;