From owner-freebsd-usb@FreeBSD.ORG Wed Mar 7 11:30:04 2007 Return-Path: X-Original-To: freebsd-usb@hub.freebsd.org Delivered-To: freebsd-usb@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9011D16A401 for ; Wed, 7 Mar 2007 11:30:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id 707CF13C48E for ; Wed, 7 Mar 2007 11:30:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l27BU4j9069045 for ; Wed, 7 Mar 2007 11:30:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l27BU4uK069044; Wed, 7 Mar 2007 11:30:04 GMT (envelope-from gnats) Resent-Date: Wed, 7 Mar 2007 11:30:04 GMT Resent-Message-Id: <200703071130.l27BU4uK069044@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-usb@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Maurice Castro Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B6C3316A402 for ; Wed, 7 Mar 2007 11:20:06 +0000 (UTC) (envelope-from maurice@sphinx.clari.net.au) Received: from sphinx.clari.net.au (sphinx.clari.net.au [203.8.14.117]) by mx1.freebsd.org (Postfix) with ESMTP id 3AAC913C4A3 for ; Wed, 7 Mar 2007 11:20:05 +0000 (UTC) (envelope-from maurice@sphinx.clari.net.au) Received: from sphinx.clari.net.au (localhost.clari.net.au [127.0.0.1]) by sphinx.clari.net.au (8.13.3/8.13.3) with ESMTP id l27BK3CG042085 for ; Wed, 7 Mar 2007 22:20:03 +1100 (EST) (envelope-from maurice@sphinx.clari.net.au) Received: (from maurice@localhost) by sphinx.clari.net.au (8.13.3/8.13.3/Submit) id l27BK2fu042084; Wed, 7 Mar 2007 22:20:02 +1100 (EST) (envelope-from maurice) Message-Id: <200703071120.l27BK2fu042084@sphinx.clari.net.au> Date: Wed, 7 Mar 2007 22:20:02 +1100 (EST) From: Maurice Castro To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: usb/110031: usb_interrupt_read does not respect timeout X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Maurice Castro List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Mar 2007 11:30:04 -0000 >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: