From owner-freebsd-usb@FreeBSD.ORG Fri Apr 11 07:29:59 2014 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DF204A05 for ; Fri, 11 Apr 2014 07:29:58 +0000 (UTC) Received: from cain.gsoft.com.au (cain.gsoft.com.au [203.31.81.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5D13610DA for ; Fri, 11 Apr 2014 07:29:57 +0000 (UTC) Received: from ur.gsoft.com.au (Ur.gsoft.com.au [203.31.81.34]) (authenticated bits=0) by cain.gsoft.com.au (8.14.4/8.14.3) with ESMTP id s3B7TWFk024876 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Fri, 11 Apr 2014 16:59:37 +0930 (CST) (envelope-from doconnor@gsoft.com.au) Subject: Re: USB 3 devices not reliably connecting at 5Gbps Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Content-Type: multipart/signed; boundary="Apple-Mail=_A05482E1-A348-4B13-8583-CDAAB0EC7481"; protocol="application/pgp-signature"; micalg=pgp-sha1 From: "Daniel O'Connor" In-Reply-To: <53478D5B.3090205@selasky.org> Date: Fri, 11 Apr 2014 16:59:31 +0930 Message-Id: References: <53478D5B.3090205@selasky.org> To: Hans Petter Selasky X-Mailer: Apple Mail (2.1874) X-Spam-Score: -3.551 () ALL_TRUSTED,BAYES_00,RP_MATCHES_RCVD X-Scanned-By: MIMEDefang 2.67 on 203.31.81.10 Cc: freebsd-usb@freebsd.org X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Apr 2014 07:29:59 -0000 --Apple-Mail=_A05482E1-A348-4B13-8583-CDAAB0EC7481 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 On 11 Apr 2014, at 16:06, Hans Petter Selasky wrote: > On 04/11/14 06:33, Daniel O'Connor wrote: >> Also, when it does connect at 5Gbps the speed seems quite slow - on = my laptop (with USB controller VID 0x8086 PID 0x9c31 - Lynx point I = think) I get 225MB/sec using libusb. On FreeBSD I get around 92MB/sec = although only after lowering(!!) the amount read per transfer. >=20 > FreeBSD sets an IRQ latency of 125us, while the others use the default = of 62.5us. Are you double buffering the USB transfers? The IRQ latency = can be changed by editing a macro in the XHCI driver: >=20 > #define XHCI_IMOD_DEFAULT 0x000003E8U /* 8000 IRQ/second */ >=20 > At a rate of 225MB/s you need around 2x32Kbyte of buffer and you need = to avoid short transfers. Interesting.. My test program looks like.. for (i =3D 0; i < EP_FDNREQ; i++) { usb_xf[i].xf =3D libusb_alloc_transfer(0); usb_xf[i].idx =3D i; usb_xf[i].done =3D 0; usb_xf[i].submitted =3D 0; p =3D malloc(EP_FDXFAMT); =09 libusb_fill_bulk_transfer(usb_xf[i].xf, h, EP_UDBUS, p, = EP_FDXFAMT, usbcb, &usb_xf[i], 10000); } I then submit all these and then have the call back log the speed (after = N transfers) and reissue the request. (I can send you the full code if you like) I find that on OSX if I have.. #define EP_FDXFAMT 32768 /* Number of bytes per = tranfer */ #define EP_FDNREQ 4 /* Number of request to = keep in flight */ I get 225MB/sec pretty much constantly, if I lower those values then the = transfer rate is much lumpier. With the same code I get 125MB/sec on FreeBSD. I tried fiddling the numbers to get more but that seems to be the = maximum. Curiously if I increase the number of bytes per transfer to 64k the = throughput drops to 86MB/sec. Lowering it to 16k gives 125MB/sec, 8k gives 62MB/sec. Finally, I ran systat -vmstat 1 while running the test and I see 4000 = IRQ/sec on the xhci device, not 8000 as your comment above would = suggest. -- Daniel O'Connor software and network engineer for Genesis Software - http://www.gsoft.com.au "The nice thing about standards is that there are so many of them to choose from." -- Andrew Tanenbaum GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C --Apple-Mail=_A05482E1-A348-4B13-8583-CDAAB0EC7481 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iD8DBQFTR5nb5ZPcIHs/zowRAg6EAKCf7Bya6rX4I1VfbXvozsMe8h/AegCgpwON sN9Y9BO/KidRxoOMUFjSX64= =6Lrl -----END PGP SIGNATURE----- --Apple-Mail=_A05482E1-A348-4B13-8583-CDAAB0EC7481--