From owner-freebsd-usb@FreeBSD.ORG Fri Apr 11 08:28:04 2014 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 53BE65DB for ; Fri, 11 Apr 2014 08:28:04 +0000 (UTC) Received: from mail.turbocat.net (heidi.turbocat.net [88.198.202.214]) (using TLSv1.1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 115DA1770 for ; Fri, 11 Apr 2014 08:28:03 +0000 (UTC) Received: from laptop015.home.selasky.org (cm-176.74.213.204.customer.telag.net [176.74.213.204]) (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 1B6741FE027; Fri, 11 Apr 2014 10:28:00 +0200 (CEST) Message-ID: <5347A7C2.9000704@selasky.org> Date: Fri, 11 Apr 2014 10:28:50 +0200 From: Hans Petter Selasky User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Daniel O'Connor Subject: Re: USB 3 devices not reliably connecting at 5Gbps References: <53478D5B.3090205@selasky.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 08:28:04 -0000 On 04/11/14 09:29, Daniel O'Connor wrote: > > 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. >> >> 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: >> >> #define XHCI_IMOD_DEFAULT 0x000003E8U /* 8000 IRQ/second */ >> >> 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 = 0; i < EP_FDNREQ; i++) { > usb_xf[i].xf = libusb_alloc_transfer(0); > usb_xf[i].idx = i; > usb_xf[i].done = 0; > usb_xf[i].submitted = 0; > p = malloc(EP_FDXFAMT); > > 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. Hi, Looks like a bug there. Can you try this patch: http://svnweb.freebsd.org/changeset/base/264340 --HPS