Subject: Re: aue panic in 3.0
To: Iain Hibbert <plunky@rya-online.net>
From: Hans Petter Selasky <hselasky@c2i.net>
List: tech-kern
Date: 09/16/2006 09:16:40
On Friday 15 September 2006 21:56, Iain Hibbert wrote:
> On Thu, 14 Sep 2006, Hans Petter Selasky wrote:
> > On Thursday 14 September 2006 20:38, Iain Hibbert wrote:
> > > Is usbd_transfer allowed to be called from interrupt context?
> >
> > The answer is no. Deep inside the [old] USB system, usbd_transfer can
> > allocate memory when it is called, that can sleep
>
> That is true but I think 'can' is not 'will' - if the driver wants to call
> usbd_transfer from interrupt context, the allocation can be arranged
> safely in advance, so far as I can tell..?

Last time I checked, the NetBSD USB stack will start allocating memory at the 
moment usbd_transfer() is called. This is USB hardware memory like transfer 
descriptors and DMA memory for the data-buffers. And it can sleep! The old 
system is simply wrong. It is not possible to pre-allocate all memory. Only 
some parts like the "struct usbd_xfer" and "struct usbd_xfer -> buffer".

Secondly you will get another headache if you try to modify the USB network 
drivers into using pre-allocated USB transfers. That is, many times the USB 
network drivers will read a value before they write a value, and that has to  
sleep.

I suggest you take my example, and allocate a separate per device thread for 
configuration of the chip. That way you will be able to tear down the thread 
when the chip detaches, so that no more accesses to the USB device will 
happen after detach.

--HPS