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

next in thread | previous in thread | raw e-mail | index | archive | help
On 04/11/14 09:29, Daniel O'Connor wrote:
>
> 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.

Hi,

Looks like a bug there. Can you try this patch:

http://svnweb.freebsd.org/changeset/base/264340

--HPS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5347A7C2.9000704>