From owner-freebsd-usb@FreeBSD.ORG Fri Dec 21 07:37:00 2012 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6443AE72; Fri, 21 Dec 2012 07:37:00 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe02.c2i.net [212.247.154.34]) by mx1.freebsd.org (Postfix) with ESMTP id 9D59B8FC15; Fri, 21 Dec 2012 07:36:58 +0000 (UTC) X-T2-Spam-Status: No, hits=-1.0 required=5.0 tests=ALL_TRUSTED Received: from [176.74.213.204] (account mc467741@c2i.net HELO laptop015.hselasky.homeunix.org) by mailfe02.swip.net (CommuniGate Pro SMTP 5.4.4) with ESMTPA id 361348592; Fri, 21 Dec 2012 08:36:56 +0100 From: Hans Petter Selasky To: Xiaofan Chen Subject: Re: usb/173666: [USB, LIBUSB] usb_reset() behavior different between GNU/Linux and FreeBSD Date: Fri, 21 Dec 2012 08:38:32 +0100 User-Agent: KMail/1.13.7 (FreeBSD/9.1-PRERELEASE; KDE/4.8.4; amd64; ; ) References: <201211162247.qAGMlTm2057387@red.freebsd.org> <201211171319.34781.hselasky@c2i.net> In-Reply-To: X-Face: 'mmZ:T{)),Oru^0c+/}w'`gU1$ubmG?lp!=R4Wy\ELYo2)@'UZ24N@d2+AyewRX}mAm; Yp |U[@, _z/([?1bCfM{_"B<.J>mICJCHAzzGHI{y7{%JVz%R~yJHIji`y>Y}k1C4TfysrsUI -%GU9V5]iUZF&nRn9mJ'?&>O MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201212210838.32260.hselasky@c2i.net> Cc: "Wojciech A. Koszek" , freebsd-usb@freebsd.org X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Dec 2012 07:37:00 -0000 On Friday 21 December 2012 08:15:23 Xiaofan Chen wrote: > On Sat, Nov 17, 2012 at 8:19 PM, Hans Petter Selasky wrote: > > On Friday 16 November 2012 23:47:29 Wojciech A. Koszek wrote: > >> >Number: 173666 > >> >Category: usb > >> >Synopsis: [USB, LIBUSB] usb_reset() behavior different between > >> >GNU/Linux and FreeBSD Confidential: no > >> >Severity: non-critical > >> >Priority: low > >> >Responsible: freebsd-usb > >> >State: open > >> >Quarter: > >> >Keywords: > >> >Date-Required: > >> >Class: sw-bug > >> >Submitter-Id: current-users > >> >Arrival-Date: Fri Nov 16 22:50:00 UTC 2012 > >> >Closed-Date: > >> >Last-Modified: > >> >Originator: Wojciech A. Koszek > >> >Release: 9.0-RELEASE > >> > >> >Organization: > >> FreeBSD > >> > >> >Environment: > >> FreeBSD seu 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:15:25 UTC > >> 2012 root@obrian.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386 > >> > >> >Description: > >> I have a driver written for libusb, which works fine under GNU/Linux and > >> libusb. Device: > >> > >> gen0.2: at usbus0, cfg=0 md=HOST > >> spd=LOW (1.5Mbps) pwr=ON > >> > >> (I used USB sniffer to uncover traffic based on what Windows was doing) > >> > >> Under Linux usb_reset()+usb_set_configuration() calls works fine. Under > >> FreeBSD I have to disable calling usb_reset(), otherwise > >> usb_set_configuration() fails with I/O error. > > > > According to: > > > > http://libusb.sourceforge.net/doc/function.usbreset.html > > > > What you describe is the expected behaviour. > > The above document is really meant for libusb-0.1 but the > behavior of libusb-compat's usb_reset() is different since > it is based on libusb-1.0's libusb_reset_device. > > http://git.libusb.org/?p=libusb-compat-0.1.git;a=blob;f=libusb/core.c > 743 API_EXPORTED int usb_reset(usb_dev_handle *dev) > 744 { > 745 usbi_dbg(""); > 746 return compat_err(libusb_reset_device(dev->handle)); > 747 } > > For libusb-1.0 under Linux and Mac OS X, usually > libusb_reset_device will not cause enumeration. > > Reference: > http://libusb.6.n5.nabble.com/PATCH-make-libusb-reset-force-re-enumeration- > on-Mac-td4499375.html > > http://libusb.sourceforge.net/api-1.0/group__dev.html#ga7321bd8dc28e9a20b41 > 1bf18e6d0e9aa > > int libusb_reset_device ( libusb_device_handle * dev ) > Perform a USB port reset to reinitialize a device. > > The system will attempt to restore the previous configuration and > alternate settings after the reset has completed. > > If the reset fails, the descriptors change, or the previous state > cannot be restored, the device will appear to be disconnected > and reconnected. This means that the device handle is no longer > valid (you should close it) and rediscover the device. A return code > of LIBUSB_ERROR_NOT_FOUND indicates when this is the case. > > This is a blocking function which usually incurs a noticeable delay. > > Parameters: > dev a handle of the device to reset > Returns: > 0 on success > LIBUSB_ERROR_NOT_FOUND if re-enumeration is required, or if the > device has been disconnected > another LIBUSB_ERROR code on other failure Hi, If you look in the old libusb-0.1 code you'll see something different I think. Could you check that? --HPS