>Number:         110122
>Category:       usb
>Synopsis:       usb_interrupt_read does not respect timeout
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-usb
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 09 09:30:03 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Maurice Castro
>Release:        6.2-Release etc
>Organization:
Clarinet Internet Solutions
>Environment:
FreeBSD mud.clari.net.au 6.2-RC1 FreeBSD 6.2-RC1 #2: Tue Mar  6 09:56:42 EST 
2007     [EMAIL PROTECTED]:/usr/src/sys/i386/compile/USB  i386
>Description:
usb_interrupt_read does not respect timeouts. This is necessary for the correct 
operation of libusb. The attached patch returns a zero length read after a 
timeout. This is consistent with the behaviour expected by libusb.

This PR replaces to broken reports: 

usb/109959
usb/110031

The problem exists in all versions of FreeBSD up to 6.2 and possibly NetBSD and 
OpenBSD.
>How-To-Repeat:
The problem is easily reproduced. The bcmxcp_usb driver freezes on 
initialisation without the patch as the call to usb_interrupt_read never 
returns.
>Fix:
The patch applies src/sys/dev/usb/ugen.c

Patch attached with submission follows:

--- ugen.c.orig Tue Mar  6 13:36:15 2007
+++ ugen.c      Tue Mar  6 09:56:20 2007
@@ -740,11 +740,17 @@
                        }
                        sce->state |= UGEN_ASLP;
                        DPRINTFN(5, ("ugenread: sleep on %p\n", sce));
-                       error = tsleep(sce, PZERO | PCATCH, "ugenri", 0);
+                       error = tsleep(sce, PZERO | PCATCH, "ugenri", 
sce->timeout);
                        sce->state &= ~UGEN_ASLP;
                        DPRINTFN(5, ("ugenread: woke, error=%d\n", error));
                        if (sc->sc_dying)
                                error = EIO;
+                       /* we timed out - return 0 bytes */
+                       if (error == EAGAIN)
+                       {
+                               error = 0;
+                               break;
+                       }
                        if (error)
                                break;
                }

>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to