# USB 3.0 - XHCI. Too slow.

## pinopineta

Hi all.

I've 

 *Quote:*   

> CONFIG_USB_ARCH_HAS_XHCI=y
> 
> CONFIG_USB_XHCI_HCD=y
> 
> # CONFIG_USB_XHCI_HCD_DEBUGGING is not set

 

and my laptop has a usb3 port.

I've linked it with my 2.5 hd which has usb 3 support.

But the average of transfer time is around 30-50 MB/sec.

Why?  :Sad: 

----------

## gentoo_ram

What are you using to test it with?  If it's a hard drive, maybe you've hit the limit of the hard drive.  Any bus-powered USB hard drives are probably not going to be terribly fast.

----------

## pinopineta

I saw the average from the pop-up of nautilus when I drag and dropped some GB of files.

My internal hd is quite empty (about 200GB of 750 is full) and the external USB3 hd is full only for 100GB of 1TB.

What do you mean with BUS-powered hard drive?

Either HD are 7200RPM, internal have 64MB of cache and external maybe 16MB.

But the external is USB 3.0 compilant.

I dunno if it a problem of mykernel config.

But the speed seems like of USB 2.0 protocol specs.

----------

## depontius

Cable?

USB3 uses a different cable than USB1 or USB2, which are pretty much fully compatible with each other.  USB2 uses the same wire set as USB1, but will require higher signal quality, so it's possible a cheap USB1 cable will force USB2 to fall back to USB1.  USB3 uses 9 wires instead of the 4 wires of USB1 and USB2.  It isn't simply a signal quality issue.  USB3 is sufficiently compatible to fall back to USB 1 or 2 performance if that's all the cabling will support.  I'll also presume that a USB3 cable will carry USB 1 or 2 signals.  It'll all work, but to get full performance everything from end-to-end has to be USB3.

Since you were explicit about USB3 for both computer and hard drive, I presume you were using an existing USB cable.

----------

## lagalopex

40 MiB/s would be a very good score for USB2.

I have a usb3 external hdd (bus-powered, 5400rpm) on an usb3 port and i reach 95 MiB/s seq. reading.

I have the same xhci options enabled you have.

What does dmesg tell you? Is xhci used?

What cabled do you use? Just the cable (from your external hdd) to the back-port on your motherboard? (No "front usb-plugs" or other type of extension cords.)

----------

## Ant P.

50MB/s for a portable spinning-rust hard drive is actually pretty fast.

----------

## HeissFuss

Try running 'hdparm -t' on the raw sd device.

----------

## pinopineta

Ok.

The cable is an USB3 cable shipped with my external USB3 capable HD.

So The cable, the HD, the USB port on my laptop are all USB3 capable.

hdparm report values that are very similar to my internal hd ... So I think that is strange and maybe hdparm is tuned for ata drive and not for sata compilant?

----------

## HeissFuss

Could you share the output from hdparm?  The -t test is just sequentially reading blocks from the device, nothing special.  It avoids filesystem/alignment issues though, so should be close to max raw throughput from a single device (reading from the edge of the platters.)

Also, what's the external drive model?

----------

## depontius

What does dmesg say right after you plug the USB drive in?  (Plug it in after booting, that is.)  In this case, you're not looking to use the filesystem or even the drive itself, I'm wondering what messages the USB subsystem emits upon plugin.  Having a roottail on /var/log/messages while you do it would be a good idea, too.

----------

## pinopineta

After plug in the usb3 laptop port:

```
[ 2916.930119] wlan0: no IPv6 routers present

[ 4970.732217] hub 4-0:1.0: state 7 ports 2 chg 0000 evt 0002

[ 4970.732236] hub 4-0:1.0: port 1, status 0203, change 0001, 5.0 Gb/s

[ 4970.835370] hub 4-0:1.0: debounce: port 1: total 100ms stable 100ms status 0x203

[ 4970.940716] usb 4-1: new SuperSpeed USB device number 2 using xhci_hcd

[ 4970.951805] usb 4-1: skipped 1 descriptor after endpoint

[ 4970.951809] usb 4-1: skipped 1 descriptor after endpoint

[ 4970.951881] xhci_hcd 0000:04:00.0: WARN: short transfer on control ep

[ 4970.951901] usb 4-1: default language 0x0409

[ 4970.952054] xhci_hcd 0000:04:00.0: WARN: short transfer on control ep

[ 4970.952183] xhci_hcd 0000:04:00.0: WARN: short transfer on control ep

[ 4970.952423] xhci_hcd 0000:04:00.0: WARN: short transfer on control ep

[ 4970.952503] usb 4-1: udev 2, busnum 4, minor = 385

[ 4970.952507] usb 4-1: New USB device found, idVendor=1058, idProduct=0730

[ 4970.952510] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3

[ 4970.952513] usb 4-1: Product: My Passport 0730

[ 4970.952517] usb 4-1: Manufacturer: Western Digital

[ 4970.952521] usb 4-1: SerialNumber: 57584C3145313159464D3134

[ 4970.952586] usb 4-1: usb_probe_device

[ 4970.952590] usb 4-1: configuration #1 chosen from 1 choice

[ 4970.953598] usb 4-1: Successful Endpoint Configure command

[ 4970.953668] usb 4-1: adding 4-1:1.0 (config #1, interface 0)

[ 4970.953707] usb-storage 4-1:1.0: usb_probe_interface

[ 4970.953713] usb-storage 4-1:1.0: usb_probe_interface - got id

[ 4970.953826] scsi6 : usb-storage 4-1:1.0

[ 4970.953892] drivers/usb/core/inode.c: creating file '002'

[ 4972.920115] scsi 6:0:0:0: Direct-Access     WD       My Passport 0730 1015 PQ: 0 ANSI: 6

[ 4972.920244] sd 6:0:0:0: Attached scsi generic sg2 type 0

[ 4978.132681] sd 6:0:0:0: [sdb] 1953458176 512-byte logical blocks: (1.00 TB/931 GiB)

[ 4978.132894] sd 6:0:0:0: [sdb] Write Protect is off

[ 4978.132898] sd 6:0:0:0: [sdb] Mode Sense: 47 00 10 08

[ 4978.133197] sd 6:0:0:0: [sdb] No Caching mode page present

[ 4978.133199] sd 6:0:0:0: [sdb] Assuming drive cache: write through

[ 4978.134202] sd 6:0:0:0: [sdb] No Caching mode page present

[ 4978.134206] sd 6:0:0:0: [sdb] Assuming drive cache: write through

[ 4978.183076]  sdb: sdb1 sdb2 < sdb5 sdb6 >

[ 4978.184204] sd 6:0:0:0: [sdb] No Caching mode page present

[ 4978.184208] sd 6:0:0:0: [sdb] Assuming drive cache: write through

[ 4978.184211] sd 6:0:0:0: [sdb] Attached SCSI disk

[ 4978.185457] xhci_hcd 0000:04:00.0: WARN: Stalled endpoint

[ 4978.346405] xhci_hcd 0000:04:00.0: WARN: Stalled endpoint

```

```

pineta pino # hdparm -tT /dev/sdb

/dev/sdb:

 Timing cached reads:   17542 MB in  2.00 seconds = 8779.71 MB/sec

 Timing buffered disk reads: 256 MB in  3.02 seconds =  84.88 MB/sec
```

----------

## HeissFuss

 *pinopineta wrote:*   

> 
> 
> ```
> 
> pineta pino # hdparm -tT /dev/sdb
> ...

 

It looks like the bottleneck is you external drive, not the USB3 connection.  You can't really expect better from a 7.2k 2.5" drive.

Also, this is certainly much faster than USB2 would be.  I don't think I've ever seen a USB2 device go over ~35MB/s.

----------

## NeddySeagoon

pinopineta,

```
8779.71 MB/sec
```

is the speed readiging from the cache RAM in the drive.  The mechanical parts of the drive are not involved in this.

```
84.88 MB/sec
```

is the sequential read sprred from the outside edge of the platter.  Thats as good as it gets. Thats the head/platter data rate limit.

----------

## wcg

 *Quote:*   

> 
> 
> ```
> 
> 4978.133197] sd 6:0:0:0: [sdb] No Caching mode page present
> ...

 

Some kernel discussion last week indicated that the opposite is

true, that most drives where the caching mode page is not

present are shipped with the caching mode default set to write back.

(Not specifically USB drives, this was in the context of ATA drives,

including SATA, which is probably what USB drives are under the covers.)

There was discussion of a change to some kernel subsystem to assume

that the drives are in write-back mode if the caching mode page is not present.

("When in doubt, flush the drive cache." Apparently there is a low-level scsi

command for this. I wonder if it is a noop in the firmware of drives that

lack a caching mode page.)

"Consumers do not need enterprise level data integrity."

What, this is a drive for an Xbox? Sheesh.

edit:

I did not mean to insult the OP's drive particularly, but my

opinion of USB firmware in general is low. I think too often manufacturers

view this stuff as consumer junk. ("Real users would be backing up to

an NAS box with enterprise sas drives, for a lot more money.") I mean,

who ships a drive with a missing caching mode page? ("Windows users

would not notice.")

----------

## pinopineta

 *NeddySeagoon wrote:*   

> pinopineta,
> 
> ```
> 8779.71 MB/sec
> ```
> ...

 

So.. what could be the benefit to buy an USB3 hard drive?

It's quite similar to an usb2 hard drive...

The usb3 port of my laptop is not useful if I can use quite to 10x usb2 ..

Usb3 specs say that speed can reach some Gbits/s of transfer rate!

----------

## NeddySeagoon

pinopineta,

A USB3 2.5" rotating hard drive cannot deliver data fast enough to justify USB3 ... but it looks good in the glossy sales brouchers.

On the other hand, a 2.5" SSD can sustain 500Mb/sec, which needs something much better than USB2

It all depends on what you put at the end of your USB3.

----------

## wcg

 *Quote:*   

> It all depends on what you put at the end of your USB3.

 

The bit about the missing caching mode page and whether the drive

cache is in write-through or write-back mode depends on that, too.

The USB Storage driver is not simply being ignorant here. All it sees

is "a USB Storage block device". It does not know whether that

device is rotating media (a traditional hard drive, like the OP's

Passport drive) or a USB stick or an SD memory card or Compact

Flash card or whatever. Only the actual rotating media will likely

have a drive cache.

The USB Storage driver asks for the caching mode page and gets

back "not found" from the USB firmware on the device. What is

it supposed to think? "Oh, this is probably flash memory. Of course

it is write-through, it does not even have a drive cache."

(I still think the firmware is crap. It looks like the manufacturer

spliced the firmware from USB flash memory onto the firmware of

an ATA drive and simply ignored the drive's cache mode, so that

they would not have to modify the USB firmware and debug the

resulting firmware mods. Who cares whether the user wants

the drive in write-through or write-back mode.)

----------

