# External HDD does not mount if "uas" module is loaded

## gemarcano

Hello everyone! I've been beating my head against the wall for a while on this problem, and searching hasn't yielded much help, other than some workarounds. I'm not experienced in debugging problems with the kernel or its modules, so any help is appreciated! The drive in question is a Hitachi Touro Mobile Pro 500GB external HDD (USB 3 capable). For as long as I have had it, this HDD has had problems in being loaded by the kernel in a USB 2 port (I do not have any USB 3 ports on my computer right now). A few months ago (or maybe almost a year ago) someone posted a workaround that worked for my drive in an Ubuntu forum here (I was actually trying to run Ubuntu off this drive at that point, and was able to do so with the workaround). The workaround was to simply blacklist the kernel module "uas". I put that hard drive aside for some time, and just brought it out yesterday, and ran into the problem on my Gentoo box. I can live with the workaround, but it leaves me wondering if there is something broken somewhere...

I found the following bug report from Ubuntu, where they claim a fix has been released https://bugs.launchpad.net/ubuntu/+source/linux/+bug/901215

Here are the relevant changes, according to them. I believe this is for kernel 3.0.0.

```
[ Upstream Kernel Changes ]

...

  * UAS: Re-add workqueue items if submission fails.

    - LP: #901215

  * UAS: Use unique tags on non-streams devices.

    - LP: #901215

  * UAS: Free status URB when we can't find the SCSI tag.

    - LP: #901215

  * usb/uas: use unique tags for all LUNs

    - LP: #901215

  * usb/uas: use scsi_host_find_tag() to find command from a tag

    - LP: #901215

  * usb/uas: one only one status URB/host on stream-less connection

    - LP: #901215

  * usb/uas: only bind if the hcd supports SG

    - LP: #901215

  * usb/uas: move UAS structs / defines into a header file

    - LP: #901215

  * usb/uas: add usb_pipe_usage_descriptor

    - LP: #901215

  * usb/uas: make sure data urb is gone if we receive status before that

    - LP: #901215

...
```

I was running the kernel version 3.3.5 and now am running 3.4.0 (both from gentoo-sources), and both exhibit the problem. I can also confirm the workaround still works.

If I do "sudo modprobe -r uas" and I plug in the HDD, it is recognized and I can mount it. Otherwise dmesg complains with the following:

```
usb 5-6: new high-speed USB device number 4 using ehci_hcd

usb 5-6: New USB device found, idVendor=4971, idProduct=1012

usb 5-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3

usb 5-6: Product: Touro Mobile Pro

usb 5-6: Manufacturer: Hitachi GST

usb 5-6: SerialNumber: 02100110330310001051

scsi5 : uas

scsi 5:0:0:0: Direct-Access     Hitachi  Touro Mobile Pro C70E PQ: 0 ANSI: 4

sd 5:0:0:0: [sdg] 976769024 512-byte logical blocks: (500 GB/465 GiB)

sd 5:0:0:0: [sdg] Write Protect is off

sd 5:0:0:0: [sdg] Mode Sense: 67 00 10 08

sd 5:0:0:0: uas_sense_old: urb length 26 disagrees with IU sense data length 510, using 18 bytes of sense data

sd 5:0:0:0: [sdg] Cache data unavailable

sd 5:0:0:0: [sdg] Assuming drive cache: write through

sd 5:0:0:0: uas_sense_old: urb length 26 disagrees with IU sense data length 510, using 18 bytes of sense data

sd 5:0:0:0: [sdg] Cache data unavailable

sd 5:0:0:0: [sdg] Assuming drive cache: write through

 sdg: sdg1 sdg2 < sdg5 sdg6 >

sd 5:0:0:0: uas_sense_old: urb length 26 disagrees with IU sense data length 510, using 18 bytes of sense data

sd 5:0:0:0: [sdg] Cache data unavailable

sd 5:0:0:0: [sdg] Assuming drive cache: write through

sd 5:0:0:0: [sdg] Attached SCSI disk

sd 5:0:0:0: uas_sense_old: urb length 26 disagrees with IU sense data length 510, using 18 bytes of sense data

sd 5:0:0:0: uas_sense_old: urb length 26 disagrees with IU sense data length 510, using 18 bytes of sense data
```

I also just tested the following, I don't know if this has any bearing on the situation: I "sudo modprobe -r uas", then modprobed it back into the kernel, and THEN plugged the drive back in, and it connects just fine with the following dmesg output:

```
usb 5-6: new high-speed USB device number 9 using ehci_hcd

usb 5-6: New USB device found, idVendor=4971, idProduct=1012

usb 5-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3

usb 5-6: Product: Touro Mobile Pro

usb 5-6: Manufacturer: Hitachi GST

usb 5-6: SerialNumber: 02100110330310001051

scsi10 : usb-storage 5-6:1.0

scsi 10:0:0:0: Direct-Access     Hitachi  Touro Mobile Pro C70E PQ: 0 ANSI: 4

sd 10:0:0:0: [sdg] 976769024 512-byte logical blocks: (500 GB/465 GiB)

sd 10:0:0:0: [sdg] Write Protect is off

sd 10:0:0:0: [sdg] Mode Sense: 67 00 10 08

sd 10:0:0:0: [sdg] No Caching mode page present

sd 10:0:0:0: [sdg] Assuming drive cache: write through

sd 10:0:0:0: [sdg] No Caching mode page present

sd 10:0:0:0: [sdg] Assuming drive cache: write through

 sdg: sdg1 sdg2 < sdg5 sdg6 >

sd 10:0:0:0: [sdg] No Caching mode page present

sd 10:0:0:0: [sdg] Assuming drive cache: write through

sd 10:0:0:0: [sdg] Attached SCSI disk
```

Which is the same output I get if I "sudo modprobe -r uas" and then connect the device.

If this helps at all, my Gentoo box is running ~x86 keyword.

Right before I started writing this, I found someone here that suggested the solution was that the module usb-storage could be passed a parameter for delay_use greater than what the system had, and that the default value was 5. Well, I checked for my system at the value for delay_use was 1...   :Question: 

```
cat /sys/module/usb_storage/parameters/delay_use

1
```

I tried to change it via /etc/conf.d/modules:

```
module_usb_storage_args="delay_use=5"
```

Upon rebooting, this did not affect the system's value. I even used find and xargs grep to try to find delay_use being set, but as of yet I was unable to find it. The kernel docs (/usr/src/linux/Documentation/kernel-parameters.txt) mention that the default it 5, not 1, unless a Gentoo patch changes that or something like that. That having been said, I was having this problem on other computers when booting off a Ubuntu live USB, giving a practically identical dmesg output. So this might transcend specific distributions. Any ideas? I'm a little clueless on what to do, but I'm willing to test things out.

----------

## gemarcano

Alright, I haven't done too much testing lately, but that has been mainly because I just built a new computer and spent almost a week setting up Gentoo and Windows on it (Linux doesn't seem to be ready for UEFI devices...). This new computer has some USB 3.0 ports, so I plugged in my Hitachi drive to see what would happen. The messages are a little different, but almost the same:

```
usb 4-3.3: new SuperSpeed USB device number 4 using xhci_hcd

scsi11 : uas

scsi 11:0:0:0: Direct-Access     Hitachi  Touro Mobile Pro C70E PQ: 0 ANSI: 4

sd 11:0:0:0: [sdb] 976769024 512-byte logical blocks: (500 GB/465 GiB)

sd 11:0:0:0: [sdb] Write Protect is off

sd 11:0:0:0: [sdb] Mode Sense: 67 00 10 08

sd 11:0:0:0: uas_sense_old: urb length 26 disagrees with IU sense data length 510, using 18 bytes of sense data

xhci_hcd 0000:00:14.0: WARN Set TR Deq Ptr cmd invalid because of stream ID configuration

sd 11:0:0:0: [sdb] Cache data unavailable

sd 11:0:0:0: [sdb] Assuming drive cache: write through

xhci_hcd 0000:00:14.0: WARN Set TR Deq Ptr cmd invalid because of stream ID configuration

sd 11:0:0:0: [sdb] Sector size 0 reported, assuming 512.

sd 11:0:0:0: [sdb] 1 512-byte logical blocks: (512 B/512 B)

sd 11:0:0:0: [sdb] 0-byte physical blocks

xhci_hcd 0000:00:14.0: ERROR Transfer event for disabled endpoint or incorrect stream ring

xhci_hcd 0000:00:14.0: @00000000df036460 00000000 00000000 04000000 03098001

sd 11:0:0:0: uas_eh_abort_handler tag 0

sd 11:0:0:0: uas_eh_device_reset_handler tag 0

sd 11:0:0:0: uas_eh_target_reset_handler tag 0

sd 11:0:0:0: uas_eh_bus_reset_handler tag 0

usb 4-3.3: reset SuperSpeed USB device number 4 using xhci_hcd

xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8803fd362bc0

xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8803fd362c00

xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8803fd362c40

xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8803fd362c80

xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 6 with no TDs queued?

usb 4-3.3: URB BAD STATUS -108

xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 8 with no TDs queued?

sd 11:0:0:0: Device offlined - not ready after error recovery

sd 11:0:0:0: rejecting I/O to offline device

sd 11:0:0:0: [sdb] Asking for cache data failed

sd 11:0:0:0: [sdb] Assuming drive cache: write through

sdb: detected capacity change from 500105740288 to 512

 sdb: unknown partition table

sd 11:0:0:0: [sdb] Attached SCSI disk
```

And just as a recap, here is the message fired when plugged into a USB 2.0 port:

```
usb 2-1.5: new high-speed USB device number 4 using ehci_hcd

scsi12 : uas

scsi 12:0:0:0: Direct-Access     Hitachi  Touro Mobile Pro C70E PQ: 0 ANSI: 4

sd 12:0:0:0: [sdb] 976769024 512-byte logical blocks: (500 GB/465 GiB)

sd 12:0:0:0: [sdb] Write Protect is off

sd 12:0:0:0: [sdb] Mode Sense: 67 00 10 08

sd 12:0:0:0: uas_sense_old: urb length 26 disagrees with IU sense data length 510, using 18 bytes of sense data

sd 12:0:0:0: [sdb] Cache data unavailable

sd 12:0:0:0: [sdb] Assuming drive cache: write through

sd 12:0:0:0: uas_sense_old: urb length 26 disagrees with IU sense data length 510, using 18 bytes of sense data

sd 12:0:0:0: [sdb] Cache data unavailable

sd 12:0:0:0: [sdb] Assuming drive cache: write through

 sdb: sdb1 sdb2 < sdb5 sdb6 >

sd 12:0:0:0: uas_sense_old: urb length 26 disagrees with IU sense data length 510, using 18 bytes of sense data

sd 12:0:0:0: [sdb] Cache data unavailable

sd 12:0:0:0: [sdb] Assuming drive cache: write through

sd 12:0:0:0: [sdb] Attached SCSI disk

sd 12:0:0:0: uas_sense_old: urb length 26 disagrees with IU sense data length 510, using 18 bytes of sense data

sd 12:0:0:0: uas_eh_abort_handler tag 0

sd 12:0:0:0: uas_eh_device_reset_handler tag 0

sd 12:0:0:0: uas_eh_target_reset_handler tag 0

sd 12:0:0:0: uas_eh_bus_reset_handler tag 0

usb 2-1.5: URB BAD STATUS -71

usb 2-1.5: reset high-speed USB device number 4 using ehci_hcd

sd 12:0:0:0: Device offlined - not ready after error recovery

sd 12:0:0:0: [sdb] Unhandled error code

sd 12:0:0:0: [sdb]  Result: hostbyte=0x03 driverbyte=0x00

sd 12:0:0:0: [sdb] CDB: cdb[0]=0x28: 28 00 00 00 00 78 00 00 08 00

end_request: I/O error, dev sdb, sector 120

quiet_error: 1 callbacks suppressed

Buffer I/O error on device sdb, logical block 15

sd 12:0:0:0: rejecting I/O to offline device

...

```

That last line "rejecting I/O to offline device" repeats a lot.

Once again, disabling uas makes the hard drive load fine. I think it's a bug in my hard drive. Let's say it's a hardware problem from the design of the device not conforming to specifications. Would it be possible to make a workaround for it? I'm not familiar at all with kernel programming, but I'd be more than happy to supply information if needed. Should I bring this up elsewhere as well?

----------

