Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Apr 2014 16:59:31 +0930
From:      "Daniel O'Connor" <doconnor@gsoft.com.au>
To:        Hans Petter Selasky <hps@selasky.org>
Cc:        freebsd-usb@freebsd.org
Subject:   Re: USB 3 devices not reliably connecting at 5Gbps
Message-ID:  <ACC91511-A630-4262-AFE4-441AA154E405@gsoft.com.au>
In-Reply-To: <53478D5B.3090205@selasky.org>
References:  <A9616810-7BD9-49FC-BFA7-44206E4CCAC1@gsoft.com.au> <53478D5B.3090205@selasky.org>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]

On 11 Apr 2014, at 16:06, Hans Petter Selasky <hps@selasky.org> 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.

--
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







[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org

iD8DBQFTR5nb5ZPcIHs/zowRAg6EAKCf7Bya6rX4I1VfbXvozsMe8h/AegCgpwON
sN9Y9BO/KidRxoOMUFjSX64=
=6Lrl
-----END PGP SIGNATURE-----
home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ACC91511-A630-4262-AFE4-441AA154E405>