Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Mar 2007 22:20:02 +1100 (EST)
From:      Maurice Castro <maurice@clari.net.au>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   usb/110031: usb_interrupt_read does not respect timeout
Message-ID:  <200703071120.l27BK2fu042084@sphinx.clari.net.au>
Resent-Message-ID: <200703071130.l27BU4uK069044@freefall.freebsd.org>

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

>Number:         110031
>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:   Wed Mar 07 11:30:03 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Maurice Castro
>Release:        FreeBSD 5.4-RELEASE i386
>Organization:
Clarinet Internet Solutions
>Environment:
System: FreeBSD sphinx.clari.net.au 5.4-RELEASE FreeBSD 5.4-RELEASE #1: Wed Nov 30 11:05:23 EST 2005 mjb@sphinx.clari.net.au:/work/src/sys/i386/compile/sphinx i386

All versions of Freebsd since at least 5.4. 

	
>Description:
	The usb_interrupt_read does not timeout when timout is requested 
	with ioctl. This behaviour is not compatible with the behaviour 
	expected by libusb. Libusb expects to get back a zero length
	read after a timeout.
>How-To-Repeat:
	The bcmxcp_usb driver in ports sysutils/nut-usb hangs without the patch. 
>Fix:

This pr is a duplicate of usb/109959 because it appears to be inaccessible.
This patch relates to the same problem described in usb/94311, however,
the patch contained in that PR is not compatible with the existing libusb's
expectations.

The following patch is applied to src/sys/dev/usb/ugen.c

--- 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?200703071120.l27BK2fu042084>