From linux-kernel-owner+willy=40w.ods.org-S261187AbVDMV2S@vger.kernel.org Wed Apr 13 23:30:30 2005 Return-Path: Received: from vger.kernel.org (vger.kernel.org [12.107.209.244]) by mail.w.ods.org (8.12.9/8.12.1) with ESMTP id j3DLURac012986 for ; Wed, 13 Apr 2005 23:30:28 +0200 (CEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261187AbVDMV2S (ORCPT ); Wed, 13 Apr 2005 17:28:18 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261193AbVDMV2S (ORCPT ); Wed, 13 Apr 2005 17:28:18 -0400 Received: from coyote.holtmann.net ([217.160.111.169]:44698 "EHLO mail.holtmann.net") by vger.kernel.org with ESMTP id S261187AbVDMV2J (ORCPT ); Wed, 13 Apr 2005 17:28:09 -0400 Received: from pegasus (p3EE2CA2B.dip.t-dialin.net [62.226.202.43]) by mail.holtmann.net (8.12.3/8.12.3/Debian-7.1) with ESMTP id j3DLSibo004019 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Wed, 13 Apr 2005 23:28:45 +0200 Subject: Re: [2.4] "Fix" introduced in 2.4.27pre2 for bluetooth hci_usb race causes kernel hang From: Marcel Holtmann To: Tomas =?ISO-8859-1?Q?=D6gren?= Cc: linux-kernel@vger.kernel.org In-Reply-To: <20050413103758.GA12780@shaka.acc.umu.se> References: <20050408195632.GA17621@shaka.acc.umu.se> <1113053955.9783.57.camel@pegasus> <20050413103758.GA12780@shaka.acc.umu.se> Content-Type: multipart/mixed; boundary="=-LBJEnVSApInmZXSGMW4F" Date: Wed, 13 Apr 2005 23:28:09 +0200 Message-Id: <1113427689.16014.2.camel@pegasus> Mime-Version: 1.0 X-Mailer: Evolution 2.2.2 X-Virus-Scanned: ClamAV 0.83/826/Wed Apr 13 13:03:12 2005 on coyote.holtmann.net X-Virus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org Status: RO Content-Length: 2566 Lines: 85 --=-LBJEnVSApInmZXSGMW4F Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi Tomas, > > > I have noticed a problem with a race condition fix introduced in > > > 2.4.27-pre2 that causes the kernel to hang when disconnecting a > > > Bluetooth USB dongle or doing 'hciconfig hci0 down'. No message is > > > printed, the kernel just doesn't respond anymore. > > > > > > Seen in Changelog: > > > Marcel Holtmann: > > > o [Bluetooth] Fix race in RX complete routine of the USB drivers > > > > > > Reversing the following patch to hci_usb_rx_complete() makes 2.4.27-pre2 > > > up until 2.4.30 happy and does not hang when removing the dongle > > > anymore. (bfusb.c has the same patch applied) > > > > > > 2.6.11.7 does not show the same problem, but has similar code to the > > > "fixed" (that hangs) code in 2.4, so the real problem is probably > > > somewhere else. > > > > does the attached patch makes any difference? > > It works just fine with pristine 2.4.30 and this patch. No deadlocks > anymore. if this works then we should do the same change in the bfusb driver. A patch that fixes both drivers is attached. Regards Marcel --=-LBJEnVSApInmZXSGMW4F Content-Disposition: attachment; filename=patch Content-Type: text/plain; name=patch; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit ===== drivers/bluetooth/bfusb.c 1.3 vs edited ===== --- 1.3/drivers/bluetooth/bfusb.c 2004-04-16 14:01:40 +02:00 +++ edited/drivers/bluetooth/bfusb.c 2005-04-13 12:49:55 +02:00 @@ -470,11 +470,10 @@ return 0; write_lock_irqsave(&bfusb->lock, flags); + write_unlock_irqrestore(&bfusb->lock, flags); bfusb_unlink_urbs(bfusb); bfusb_flush(hdev); - - write_unlock_irqrestore(&bfusb->lock, flags); MOD_DEC_USE_COUNT; ===== drivers/bluetooth/hci_usb.c 1.23 vs edited ===== --- 1.23/drivers/bluetooth/hci_usb.c 2004-07-31 13:02:43 +02:00 +++ edited/drivers/bluetooth/hci_usb.c 2005-04-09 15:37:12 +02:00 @@ -398,12 +398,12 @@ BT_DBG("%s", hdev->name); + /* Synchronize with completion handlers */ write_lock_irqsave(&husb->completion_lock, flags); - + write_unlock_irqrestore(&husb->completion_lock, flags); + hci_usb_unlink_urbs(husb); hci_usb_flush(hdev); - - write_unlock_irqrestore(&husb->completion_lock, flags); MOD_DEC_USE_COUNT; return 0; --=-LBJEnVSApInmZXSGMW4F-- - 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/