USB device driver question: timeout() and usbd_do_request()

Bernd Walter ticso at cicely12.cicely.de
Mon May 3 05:10:51 PDT 2004


On Sun, May 02, 2004 at 10:38:42AM -0400, Rita Lin wrote:
> Hello,
> 
> I'm writing a USB driver for a device that does not have any interrupt. It only has Bulk-in and Bulk-out. A periodic polling status from default pipe is required to have a smooth data transfer. I used timeout() routine to call usbd_do_request() for polling. I thought maybe timeout() is called under interrupt context, since usbd_do_request() access system I/O, it crashes. However, by adding this timeout() in ucomstart(), it didn't crash until the third call to timeout(). Removing usbd_do_request() allows the timeout() to work without any problem. From the USB analyzer, I could see that even if the system crashed, a request was sent to the USB device correctly. There are two crashdump messages printed out to the screen, I could only catch the second one. The first one scrolled off the screen too fast. By counting the byte and the instruction pointer, the routine crashed in acquire_lock(). I 'greped' the kernel source code, didn't see this routine.
> 
> I know I'm missing some important FreeBSD concept since I'm new to it, by reading related document did not reveal anything that might help me. If usbd_do_request() should never be used in timeout() as a callback routine, what other options do I have, to implement a status-polling scheme? 

You can't use usbd_do_request in timeout as it requires memory
allocation, etc...

But I don't understand the whole issue you have.
Just schedule a request and wait for the device to ack.
The Host controller does the polling for you as long as the request is
queued and the timeout value supplied with the request did not time out.
That has nothing to do with FreeBSD - it's how things work with USB in
general.

PS: please break lines

-- 
B.Walter                   BWCT                http://www.bwct.de
bernd at bwct.de                                  info at bwct.de



More information about the freebsd-hackers mailing list