From owner-freebsd-current@FreeBSD.ORG Sun Feb 19 13:23:48 2006 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 40F4716A420 for ; Sun, 19 Feb 2006 13:23:48 +0000 (GMT) (envelope-from fli+freebsd-current@shapeshifter.se) Received: from mx1.h3q.net (manticore.shapeshifter.se [212.37.5.30]) by mx1.FreeBSD.org (Postfix) with ESMTP id 20B8E43D45 for ; Sun, 19 Feb 2006 13:23:46 +0000 (GMT) (envelope-from fli+freebsd-current@shapeshifter.se) Received: from localhost (localhost [127.0.0.1]) by mx1.h3q.net (Postfix) with ESMTP id 90C2C1A726 for ; Sun, 19 Feb 2006 14:23:44 +0100 (CET) Received: from mx1.h3q.net ([127.0.0.1]) by localhost (mx1.h3q.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 94665-08 for ; Sun, 19 Feb 2006 14:23:43 +0100 (CET) Received: from [192.168.0.81] (81-234-243-91-o926.tbon.telia.com [81.234.243.91]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.h3q.net (Postfix) with ESMTP id 097CD1A723 for ; Sun, 19 Feb 2006 14:23:42 +0100 (CET) Message-ID: <43F87155.3050103@shapeshifter.se> Date: Sun, 19 Feb 2006 14:23:33 +0100 From: Fredrik Lindberg User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050928) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-current@freebsd.org Content-Type: multipart/mixed; boundary="------------040001020400000200060600" X-Virus-Scanned: amavisd-new at h3q.net Subject: USB and clear endpoint stall X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Feb 2006 13:23:48 -0000 This is a multi-part message in MIME format. --------------040001020400000200060600 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit After a quite recent -current update, UPEKs touchchip driver began to run dead slow and by turning on debugging for libusb (which the driver utilize) I noticed several 5 seconds long read timeouts. These timeouts were not present with the same driver on an earlier current and I think I've tracked it down to the commits on Jan 8 which dropped usbd_clear_endpoint_stall() from usbd_setup_pipe(). Apparently this device needs this, because after re-adding this functionallity the timeout disappears. I've attached a patch that works for me, it's basicly the same as before Jan 8, but with the quirk reversed. My USB-foo isn't that good so people with better understanding of the USB stack might have a better fix for this. Fredrik Lindberg --------------040001020400000200060600 Content-Type: text/plain; name="usb-open-clearstall-20060219.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="usb-open-clearstall-20060219.patch" Index: sys/dev/usb/usb_quirks.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/usb_quirks.c,v retrieving revision 1.47 diff -u -r1.47 usb_quirks.c --- sys/dev/usb/usb_quirks.c 8 Jan 2006 03:34:29 -0000 1.47 +++ sys/dev/usb/usb_quirks.c 19 Feb 2006 09:59:34 -0000 @@ -79,6 +79,8 @@ { USB_VENDOR_TELEX, USB_PRODUCT_TELEX_MIC1, 0x009, { UQ_AU_NO_FRAC }}, { USB_VENDOR_SILICONPORTALS, USB_PRODUCT_SILICONPORTALS_YAPPHONE, 0x100, { UQ_AU_INP_ASYNC }}, + { USB_VENDOR_STMICRO, USB_PRODUCT_STMICRO_BIOCPU, + ANY, { UQ_OPEN_CLEARSTALL }}, /* XXX These should have a revision number, but I don't know what they are. */ { USB_VENDOR_HP, USB_PRODUCT_HP_895C, ANY, { UQ_BROKEN_BIDIR }}, { USB_VENDOR_HP, USB_PRODUCT_HP_880C, ANY, { UQ_BROKEN_BIDIR }}, Index: sys/dev/usb/usb_quirks.h =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/usb_quirks.h,v retrieving revision 1.21 diff -u -r1.21 usb_quirks.h --- sys/dev/usb/usb_quirks.h 8 Jan 2006 03:34:29 -0000 1.21 +++ sys/dev/usb/usb_quirks.h 19 Feb 2006 09:59:34 -0000 @@ -54,6 +54,7 @@ #define UQ_AU_INP_ASYNC 0x0800 /* input is async despite claim of adaptive */ #define UQ_ASSUME_CM_OVER_DATA 0x1000 /* modem device breaks on cm over data */ #define UQ_BROKEN_BIDIR 0x2000 /* printer has broken bidir mode */ +#define UQ_OPEN_CLEARSTALL 0x4000 /* device needs clear endpoint stall */ #define UQ_HID_IGNORE 0x8000 /* device should be ignored by hid class */ }; Index: sys/dev/usb/usb_subr.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/usb_subr.c,v retrieving revision 1.80 diff -u -r1.80 usb_subr.c --- sys/dev/usb/usb_subr.c 11 Feb 2006 03:41:20 -0000 1.80 +++ sys/dev/usb/usb_subr.c 19 Feb 2006 09:59:34 -0000 @@ -780,6 +780,18 @@ return (err); } + if (dev->quirks->uq_flags & UQ_OPEN_CLEARSTALL) { + /* Clear any stall and make sure DATA0 toggle will be used next. */ + if (UE_GET_ADDR(ep->edesc->bEndpointAddress) != USB_CONTROL_ENDPOINT) { + err = usbd_clear_endpoint_stall(p); + if (err && err != USBD_STALLED && err != USBD_TIMEOUT) { + printf("usbd_setup_pipe: failed to start " + "endpoint, %s\n", usbd_errstr(err)); + return (err); + } + } + } + *pipe = p; return (USBD_NORMAL_COMPLETION); } Index: sys/dev/usb/usbdevs =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/usbdevs,v retrieving revision 1.253 diff -u -r1.253 usbdevs --- sys/dev/usb/usbdevs 11 Feb 2006 03:27:57 -0000 1.253 +++ sys/dev/usb/usbdevs 19 Feb 2006 09:59:34 -0000 @@ -1529,6 +1529,7 @@ product SOURCENEXT KEIKAI8_CHG 0x012e KeikaiDenwa 8 with charger /* STMicroelectronics products */ +product STMICRO BIOCPU 0x2016 Biometric Coprocessor product STMICRO COMMUNICATOR 0x7554 USB Communicator /* STSN products */ --------------040001020400000200060600--