Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Mar 2007 09:28:28 GMT
From:      Maurice Castro<maurice@castro.aus.net>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   usb/110122: usb_interrupt_read does not respect timeout
Message-ID:  <200703090928.l299SSgR077668@www.freebsd.org>
Resent-Message-ID: <200703090930.l299U3f7089232@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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     root@mud.clari.net.au:/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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200703090928.l299SSgR077668>