Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754773Ab2KMKQo (ORCPT ); Tue, 13 Nov 2012 05:16:44 -0500 Received: from cantor2.suse.de ([195.135.220.15]:46333 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754416Ab2KMKQl (ORCPT ); Tue, 13 Nov 2012 05:16:41 -0500 Date: Tue, 13 Nov 2012 11:16:36 +0100 Message-ID: From: Takashi Iwai To: Jiri Slaby Cc: Jaroslav Kysela , alsa-devel@alsa-project.org, LKML , USB list , Jiri Slaby Subject: Re: Sound+USB: deadlock problem In-Reply-To: <50A21542.2090102@suse.cz> References: <50A20429.3020109@suse.cz> <50A20512.10805@suse.cz> <50A21542.2090102@suse.cz> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.2 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2288 Lines: 77 At Tue, 13 Nov 2012 10:39:14 +0100, Jiri Slaby wrote: > > On 11/13/2012 09:45 AM, Takashi Iwai wrote: > > At Tue, 13 Nov 2012 09:30:10 +0100, > > Jiri Slaby wrote: > >> > >> On 11/13/2012 09:28 AM, Takashi Iwai wrote: > >>> At Tue, 13 Nov 2012 09:26:17 +0100, > >>> Jiri Slaby wrote: > >>>> > >>>> Hello, > >>>> > >>>> I've just plugged+unplugged+plugged my USB audio card and the audio > >>>> subsystem got stuck: > >>> > >>> Which kernel? If it's older than 3.7-rc5, could you try 3.7-rc5? > >> > >> Oh, forgot to mention: > >> 3.7.0-rc5-next-20121112_64+ > > > > Through a quick glance, one of mutex locks seems stuck. > > Just a blind short -- does the patch below cure the problem? > > Yes, this helps. > > Adding a LOCKDEP splash _before_ applying the patch: Thanks, this helps much for understanding the cause. It's a new rwsem in the usb-audio driver that deadlocks. Although the previous patch fixes the deadlock it opens the race again. Could you try the patch below instead? The rwsem above doesn't have to be taken for the whole operation, but just needs to protect for turning on the flag. The patch below should suffice for protecting races but avoids the deadlock. Takashi --- diff --git a/sound/usb/card.c b/sound/usb/card.c index 282f0fc..dbf7999 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -559,9 +559,11 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, return; card = chip->card; - mutex_lock(®ister_mutex); down_write(&chip->shutdown_rwsem); chip->shutdown = 1; + up_write(&chip->shutdown_rwsem); + + mutex_lock(®ister_mutex); chip->num_interfaces--; if (chip->num_interfaces <= 0) { snd_card_disconnect(card); @@ -582,11 +584,9 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, snd_usb_mixer_disconnect(p); } usb_chip[chip->index] = NULL; - up_write(&chip->shutdown_rwsem); mutex_unlock(®ister_mutex); snd_card_free_when_closed(card); } else { - up_write(&chip->shutdown_rwsem); mutex_unlock(®ister_mutex); } } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/