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

Rita Lin ritalin at
Sun May 2 07:50:23 PDT 2004


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? 

Thank you very much in advance.

More information about the freebsd-hackers mailing list