Subject: Re: USB stack needs early review (Re: Someone has fixed our USB stack!)
To: ITOH Yasufumi <itohy@netbsd.org>
From: Hans Petter Selasky <hselasky@c2i.net>
List: tech-kern
Date: 04/25/2007 13:03:16
On Wednesday 11 April 2007 15:11, ITOH Yasufumi wrote:
> Hello, sorry for delay...,
>
> I'm now planning to change the API a little.
>
> now we have:
> 	usbd_xfer_handle usbd_alloc_xfer(usbd_device_handle dev)
>
> proposed API:
> 	usbd_xfer_handle usbd_alloc_xfer(usbd_device_handle dev,
> 	    usbd_pipe_handle pipe)
> 	Also modify usbd_setup_xfer() etc. not to take pipe argument.
>
> This is because pre-allocating resources (such as transfer descriptors
> (TDs)) requires information on the pipe.
> I found allocating TDs on interrupt context causes problems and trying
> to allocate them along with allocation of buffer memory.
>
> This change requires modification of each driver, augh.

How are things going?

When you pre-allocate resources you need an upper bound on the data-buffer 
also?

Another thing you might consider, is introducing mutexes into the USB driver.

Some tests I performed on FreeBSD, comparing the Giant-locked USB driver with 
the non-Giant-locked USB driver, showed a noticable performance improvement, 
when I stressed the computer. For example I did a test using a WLAN USB 
adapter, playing back a 128kBit/s audio stream. With the Giant-locked USB 
stack I had regular dropouts. With the Giant-free USB stack I had no 
dropouts.

Again, it would be very nice if we could join heads, and develop a common 
mutex enabled USB stack for *BSD. I have my proposal at:

http://www.turbocat.net/~hselasky/usb4bsd

Here is a code reference for the new USB stack:

http://www.turbocat.net/~hselasky/usb4bsd/dev_new_usb.pdf

--HPS