From owner-freebsd-usb@FreeBSD.ORG Thu Nov 11 16:05:59 2004 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AF26716A4CE for ; Thu, 11 Nov 2004 16:05:59 +0000 (GMT) Received: from mailfe09.swip.net (mailfe09.swipnet.se [212.247.155.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id E643C43D46 for ; Thu, 11 Nov 2004 16:05:58 +0000 (GMT) (envelope-from hselasky@c2i.net) X-T2-Posting-ID: REIQbJFbyiUDW4t0LS52jw== Received: from [193.217.201.208] (HELO curly.tele2.no) by mailfe09.swip.net (CommuniGate Pro SMTP 4.2.5) with ESMTP id 13069979 for freebsd-usb@FreeBSD.org; Thu, 11 Nov 2004 17:05:47 +0100 Received: (from root@localhost) by curly.tele2.no (8.12.5/8.12.3) id iABGAq1w001161 for freebsd-usb@FreeBSD.org; Thu, 11 Nov 2004 17:10:52 +0100 (CET) (envelope-from hselasky@c2i.net) Date: Thu, 11 Nov 2004 17:10:50 +0100 From: Hans Petter Selasky To: freebsd-usb@FreeBSD.org Message-ID: <20041111171049.B887@curly.tele2.no> References: <20041109232129.A283@curly.tele2.no> <200411110110.aa80909@salmon.maths.tcd.ie> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200411110110.aa80909@salmon.maths.tcd.ie>; from iedowse@maths.tcd.ie on Thu, Nov 11, 2004 at 01:10:53AM +0000 Subject: Re: new USB driver X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Nov 2004 16:05:59 -0000 On Thu, Nov 11, 2004 at 01:10:53AM +0000, Ian Dowse wrote: > In message <20041109232129.A283@curly.tele2.no>, Hans Petter Selasky writes: > > > >Does the USB developers agree that the USB-core should use and support > >mutexes? If you want mutex support you will need to to call the callback the > >way I have done, else you get reverse locking problems ... > > Yes, we would certainly like to see the USB code brought out from > under Giant (it's probably not quite as critical as having it > function reliably, but still very important). What is it about > callbacks that needs to be changed? The callback cannot be called from usb_transfer_complete(), like it is currently done, due to the locking situation: starting a transfer: lock(priv) // setup data // I don't think it is a good idea // to unlock priv before accessing // the hardware, because if another // thread is about to stop the same // transfer, one doesn't know which // thread will run first, because // there is no lock held. lock(usb) // access and start hardware unlock(usb) unlock(priv) when the HC interrupts: lock(usb) // check if the transfer is complete and // enqueue transfer for completion if it has not been // queued for completion by another thread already // (NOTE: the queue is on the stack) // cannot lock priv here because then the locking // order will reverse which might cause a dead-lock unlock(usb) lock(priv) // check if another thread has stopped the transfer // or called the callback (e.g. timeout) // call callback unlock(priv) See the file _uhci.c and the functions uhci_timeout() and uhci_interrupt(). > > >> Do you have time to bring your driver up to date with -current, and > >> start undoing some of the unnecessary changes? > > > >Yes, but it might take some time. When will USB 2.0 HUB support be in place? > > Basic support is there already, but only for talking to USB2 devices > through USB2 hubs. How much more works with your driver? I have not added more USB HUB support than there is in FreeBSD-5-current. Yours -HPS