USB 3 devices not reliably connecting at 5Gbps
Hans Petter Selasky
hps at selasky.org
Fri Apr 11 08:28:04 UTC 2014
On 04/11/14 09:29, Daniel O'Connor wrote:
>
> On 11 Apr 2014, at 16:06, Hans Petter Selasky <hps at 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
More information about the freebsd-usb
mailing list