From owner-freebsd-hackers@FreeBSD.ORG Tue Apr 26 14:43:26 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5E41E106566B; Tue, 26 Apr 2011 14:43:26 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe06.c2i.net [212.247.154.162]) by mx1.freebsd.org (Postfix) with ESMTP id B5E9D8FC16; Tue, 26 Apr 2011 14:43:25 +0000 (UTC) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.1 cv=NvrFngl24Vvwb7eBef0tfsytOWEnP/WlkqxQrRnklhk= c=1 sm=1 a=SvYTsOw2Z4kA:10 a=NSgU13EpIVMA:10 a=WQU8e4WWZSUA:10 a=8nJEP1OIZ-IA:10 a=CL8lFSKtTFcA:10 a=i9M/sDlu2rpZ9XS819oYzg==:17 a=8bDjwUAGVKT74-45mFsA:9 a=wPNLvfGTeEIA:10 a=M8q0rZJ2Y_bfsept:21 a=pHEeH1OnV-vjp8f0:21 a=i9M/sDlu2rpZ9XS819oYzg==:117 Received: from [188.126.198.129] (account mc467741@c2i.net HELO laptop002.hselasky.homeunix.org) by mailfe06.swip.net (CommuniGate Pro SMTP 5.2.19) with ESMTPA id 118131955; Tue, 26 Apr 2011 16:43:14 +0200 From: Hans Petter Selasky To: freebsd-hackers@freebsd.org Date: Tue, 26 Apr 2011 16:42:17 +0200 User-Agent: KMail/1.13.5 (FreeBSD/8.2-STABLE; KDE/4.4.5; amd64; ; ) References: <4DB695DB.1080505@chillt.de> <5627117D-499B-4FD7-BF84-BE4BE6F583D7@bsdimp.com> <201104261037.17893.jhb@freebsd.org> In-Reply-To: <201104261037.17893.jhb@freebsd.org> X-Face: *nPdTl_}RuAI6^PVpA02T?$%Xa^>@hE0uyUIoiha$pC:9TVgl.Oq, NwSZ4V"|LR.+tj}g5 %V,x^qOs~mnU3]Gn; cQLv&.N>TrxmSFf+p6(30a/{)KUU!s}w\IhQBj}[g}bj0I3^glmC( :AuzV9:.hESm-x4h240C`9=w MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201104261642.17569.hselasky@c2i.net> Cc: Bartosz Fabianowski Subject: Re: Is there some implicit locking of device methods? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Apr 2011 14:43:26 -0000 On Tuesday 26 April 2011 16:37:17 John Baldwin wrote: > On Tuesday, April 26, 2011 10:27:14 am Warner Losh wrote: > > On Apr 26, 2011, at 7:42 AM, John Baldwin wrote: > > > - The Giant protection for new-bus should prevent attach/detach from > > > running > > > > > > concurrently I believe (either that or the USB bus itself should > > > ensure that the two instances of your device have seperate device_t > > > instances with separate softc's, so current attach/detach should not > > > matter except that they may both try to talk to the same hardware > > > perhaps? In that case that is something the USB bus driver should > > > fix by prevent a device from attaching at an existing address until > > > any existing device at that address is fully detached). > > > > I thought that if we held Giant when we're about to go to sleep that we > > drop it as a special case. So if any newbus-releated function sleeps, > > we can have a situation where attach is running and detach gets called. > > There is (or was) some code to cope with this in CardBus, iirc. I'm > > surprised there isn't any in USB, since Hans was the one that alerted me > > to this issue. > > Yes, Giant doesn't really provide too much help here. However, the real > fix should be in the USB bus, and USB peripheral drivers should not have > to worry about handling concurrent attach/detach (they can't really handle > it safely anyway). Hi, All detach/attach/suspend/resume functions on a device tree belonging to the same USB controller are executed from a single thread, which is called the root HUB thread. --HPS