new USB driver
Hans Petter Selasky
hselasky at c2i.net
Thu Nov 11 08:05:59 PST 2004
On Thu, Nov 11, 2004 at 01:10:53AM +0000, Ian Dowse wrote:
> In message <20041109232129.A283 at 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:
// 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.
// access and start hardware
when the HC interrupts:
// 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
// check if another thread has stopped the transfer
// or called the callback (e.g. timeout)
// call callback
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.
More information about the freebsd-usb