Sunday 18 June 2017

Orico USB3.0 enclosure inactivity/disconnect fix

Many hardware (especially cheap) vendors will sell the same product but replace and gut the internal electronics. This makes finding compatible/previously successful devices a PITA. One such recent example is a cheap Orico external USB 3.0 enclosure for 2.5" harddisks that is readily available on place such as Amazon.

I bought 2 of these enclosures to use with my various Linux boxes and sure enough they had different USB vendor ids and they worked differently.

The Problem

The working enclosure had an unknown vendor/product ID 0080:a0001 (even when looking at the June 2017 usb id list) and describes itself as "External USB 3.0" but it has been trouble free in the 7+ months that I've had it and this has been attached to a RPi providing NAS for various Kodi and network music players - the enclosed harddisk also successfully spins down and up with no issues.

The troublesome enclosure identifies itself as a 357d:7788 which is apparently a Sharkoon QuickPort XT and descibes itself as "USB to ATA/ATAPI Bridge". Whlist this device will be recognised on my various Linux hardware (desktop/laptop/RPi) and different USB hosts (USB 2.0 and 3.0) it exhibits problems after a period of inactivity - the workaround is to unplug the device and reattach but this is a pain.

On initial attach:
[13344.377088] usb 2-1.8: new high-speed USB device number 11 using ehci-pci
[13344.456463] usb 2-1.8: New USB device found, idVendor=357d, idProduct=7788
[13344.456470] usb 2-1.8: New USB device strings: Mfr=10, Product=11, SerialNumber=3
[13344.456474] usb 2-1.8: Product: USB to ATA/ATAPI Bridge
[13344.456477] usb 2-1.8: Manufacturer: JMicron
[13344.456480] usb 2-1.8: SerialNumber: 000012345678
[13344.457185] scsi host7: uas
[13344.458356] scsi 7:0:0:0: Direct-Access Hitachi HTS545050A7E380 0100 PQ: 0 ANSI: 6
[13344.486979] sd 7:0:0:0: Attached scsi generic sg4 type 0
[13344.487248] sd 7:0:0:0: [sdd] 976773168 512-byte logical blocks: (500 GB/466 GiB)
[13344.487253] sd 7:0:0:0: [sdd] 4096-byte physical blocks
[13344.488998] sd 7:0:0:0: [sdd] Write Protect is off
[13344.489003] sd 7:0:0:0: [sdd] Mode Sense: 67 00 10 08
[13344.489595] sd 7:0:0:0: [sdd] Write cache: enabled, read cache: enabled, supports DPO and FUA
[13344.595091] sdd: sdd1
[13344.598031] sd 7:0:0:0: [sdd] Attached SCSI disk
[13344.924384] EXT4-fs (sdd1): mounting ext2 file system using the ext4 subsystem
[13344.955597] EXT4-fs (sdd1): mounted filesystem without journal. Opts: (null)

and after a period with no access to the disk $ ls: reading directory '/run/media/ray/533f2f7d-cc19-4f4a-9b3e-4254ff7d8c6d/2017-04/tmp/': Input/output error with the system reporting:
[13914.040172] sd 7:0:0:0: [sdd] tag#0 uas_eh_abort_handler 0 uas-tag 1 inflight: CMD
[13914.040182] sd 7:0:0:0: [sdd] tag#0 CDB: Read(10) 28 00 0b bc de 78 00 00 08 00
[13914.040279] scsi host7: uas_eh_bus_reset_handler start
[13914.107202] usb 2-1.8: reset high-speed USB device number 11 using ehci-pci
[13914.186467] scsi host7: uas_eh_bus_reset_handler success
[13924.269081] sd 7:0:0:0: [sdd] tag#0 uas_eh_abort_handler 0 uas-tag 1 inflight: CMD
[13924.269087] sd 7:0:0:0: [sdd] tag#0 CDB: Test Unit Ready 00 00 00 00 00 00
[13924.269090] scsi host7: uas_eh_bus_reset_handler start
[13924.336064] usb 2-1.8: reset high-speed USB device number 11 using ehci-pci
[13924.412088] usb 2-1.8: device descriptor read/64, error -71
[13924.593066] usb 2-1.8: device descriptor read/64, error -71
[13924.765091] usb 2-1.8: reset high-speed USB device number 11 using ehci-pci
[13924.841055] usb 2-1.8: device descriptor read/64, error -71
[13925.025064] usb 2-1.8: device descriptor read/64, error -71
[13925.197012] usb 2-1.8: reset high-speed USB device number 11 using ehci-pci
[13925.614072] usb 2-1.8: device not accepting address 11, error -71
[13925.678075] usb 2-1.8: reset high-speed USB device number 11 using ehci-pci
[13926.093101] usb 2-1.8: device not accepting address 11, error -71
[13926.093369] scsi host7: uas_eh_bus_reset_handler FAILED err -19
[13926.093377] sd 7:0:0:0: Device offlined - not ready after error recovery
[13926.093388] sd 7:0:0:0: [sdd] tag#0 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_TIMEOUT
[13926.093394] sd 7:0:0:0: [sdd] tag#0 CDB: Read(10) 28 00 0b bc de 78 00 00 08 00
[13926.093399] blk_update_request: I/O error, dev sdd, sector 196927096
[13926.093479] EXT4-fs warning (device sdd1): dx_probe:741: inode #6152361: lblock 0: comm ls: error -5 reading directory block
[13926.093737] usb 2-1.8: USB disconnect, device number 11
[13926.095825] blk_update_request: I/O error, dev sdd, sector 0
[13926.097895] sd 7:0:0:0: [sdd] Synchronizing SCSI cache
[13926.218078] sd 7:0:0:0: [sdd] Synchronize Cache(10) failed: Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
[13926.286074] usb 2-1.8: new high-speed USB device number 12 using ehci-pci
[13926.362061] usb 2-1.8: device descriptor read/64, error -71
[13926.544991] usb 2-1.8: device descriptor read/64, error -71
[13926.717036] usb 2-1.8: new high-speed USB device number 13 using ehci-pci
[13926.794068] usb 2-1.8: device descriptor read/64, error -71
[13926.977073] usb 2-1.8: device descriptor read/64, error -71
[13927.149077] usb 2-1.8: new high-speed USB device number 14 using ehci-pci
[13927.565093] usb 2-1.8: device not accepting address 14, error -71
[13927.629012] usb 2-1.8: new high-speed USB device number 15 using ehci-pci
[13928.045056] usb 2-1.8: device not accepting address 15, error -71
[13928.045199] usb 2-1-port8: unable to enumerate USB device

At this point the device is not seen on the USB bus.

The problem appears to be due to some issue within the UAS kernel subsystem which is a newer/faster subsystem to maximise inefficiencies when using USB 3.0 hard disks. Unfortunately, something isn't playing nice which leads to the issues seen above.

You can confirm the driver used by mass storage by checking the USB bus and used drivers via lsusb -t
$ lsusb -t
..
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
|__ Port 2: Dev 2, If 0, Class=Mass Storage, Driver=uas, 5000M
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
|__ Port 1: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 480M
The above listing shows a machine with both USB2 and USB3 ports with external drives attached - the top shows the uas driver in use.

The Fix

The fix/workaround is to blacklist and disable UAS for the given USB enclosure.
#/etc/modprobe.d/blacklist-uas.conf
options usb-storage quirks=357d:7788:u

#ensure boot initramfs img is also update with blacklist
$ mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.orig
$ dracut
$ ls -l /boot/initramfs-$(uname -r).img
With the quirk registered, either by reloading module (modprobe -r uas; modprobe -r usb_storage) or rebooting post-dracut, re-attaching the USB enclosure:
[15698.768513] usb 2-1.8: new high-speed USB device number 16 using ehci-pci
[15698.848661] usb 2-1.8: New USB device found, idVendor=357d, idProduct=7788
[15698.848668] usb 2-1.8: New USB device strings: Mfr=10, Product=11, SerialNumber=3
[15698.848672] usb 2-1.8: Product: USB to ATA/ATAPI Bridge
[15698.848676] usb 2-1.8: Manufacturer: JMicron
[15698.848679] usb 2-1.8: SerialNumber: 000012345678
[15698.874203] usb-storage 2-1.5.1.1:1.0: USB Mass Storage device detected
[15698.874316] scsi host6: usb-storage 2-1.5.1.1:1.0
[15698.874429] usb 2-1.8: UAS is blacklisted for this device, using usb-storage instead
[15698.874431] usb-storage 2-1.8:1.0: USB Mass Storage device detected
[15698.874956] usb-storage 2-1.8:1.0: Quirks match for vid 357d pid 7788: 800000
[15698.874992] scsi host7: usb-storage 2-1.8:1.0
[15698.875129] usbcore: registered new interface driver usb-storage
[15698.880025] usbcore: registered new interface driver uas
[15699.925652] scsi 7:0:0:0: Direct-Access Hitachi HTS545050A7E380 0100 PQ: 0 ANSI: 6
[15699.926432] sd 7:0:0:0: Attached scsi generic sg3 type 0
[15699.927219] sd 7:0:0:0: [sdc] 976773168 512-byte logical blocks: (500 GB/466 GiB)
[15699.928202] sd 7:0:0:0: [sdc] Write Protect is off
[15699.928209] sd 7:0:0:0: [sdc] Mode Sense: 67 00 10 08
[15699.929205] sd 7:0:0:0: [sdc] Write cache: enabled, read cache: enabled, supports DPO and FUA
[15699.935909] scsi 6:0:0:0: Direct-Access Generic Ultra HS-SD/MMC 1.82 PQ: 0 ANSI: 0
[15699.936446] sd 6:0:0:0: Attached scsi generic sg4 type 0
[15699.952681] sd 6:0:0:0: [sdd] Attached SCSI removable disk
[15700.036987] sdc: sdc1
[15700.040331] sd 7:0:0:0: [sdc] Attached SCSI disk
[15700.342171] EXT4-fs (sdc1): mounting ext2 file system using the ext4 subsystem
[15700.371376] EXT4-fs (sdc1): mounted filesystem without journal. Opts: (null)

The only downside of this blacklisting means we are using the older USB subsystem which means slower read/writes speeds but probably a small price to pay to save on inconveinience.


Fully working enclosure

$ sudo lsusb -v -d 0080:a001

Bus 001 Device 006: ID 0080:a001
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x0080
idProduct 0xa001
bcdDevice 2.03
iManufacturer 1 TOSHIBA
iProduct 2 External USB 3.0

iSerial 3 2015033100063
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 85
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk-Only
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 1
bNumEndpoints 4
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 98
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Command pipe (0x01)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Status pipe (0x02)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Data-in pipe (0x03)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x04 EP 4 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Data-out pipe (0x04)
Binary Object Store Descriptor:
bLength 5
bDescriptorType 15
wTotalLength 22
bNumDeviceCaps 2
USB 2.0 Extension Device Capability:
bLength 7
bDescriptorType 16
bDevCapabilityType 2
bmAttributes 0x00000f0e
Link Power Management (LPM) Supported
SuperSpeed USB Device Capability:
bLength 10
bDescriptorType 16
bDevCapabilityType 3
bmAttributes 0x00
wSpeedsSupported 0x000e
Device can operate at Full Speed (12Mbps)
Device can operate at High Speed (480Mbps)
Device can operate at SuperSpeed (5Gbps)
bFunctionalitySupport 1
Lowest fully-functional device speed is Full Speed (12Mbps)
bU1DevExitLat 10 micro seconds
bU2DevExitLat 32 micro seconds
Device Status: 0x0000
(Bus Powered)


UAS troublesome enclosure

$ sudo lsusb -v -d 357d:7788
Bus 002 Device 016: ID 357d:7788 Sharkoon QuickPort XT
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.10
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x357d Sharkoon
idProduct 0x7788 QuickPort XT
bcdDevice 0.00
iManufacturer 10 JMicron
iProduct 11 USB to ATA/ATAPI Bridge

iSerial 3 000012345678
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 85
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 4 USB Mass Storage
bmAttributes 0xc0
Self Powered
MaxPower 50mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk-Only
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 1
bNumEndpoints 4
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 98
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Command pipe (0x01)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Status pipe (0x02)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Data-in pipe (0x03)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x04 EP 4 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Data-out pipe (0x04)
Binary Object Store Descriptor:
bLength 5
bDescriptorType 15
wTotalLength 22
bNumDeviceCaps 2
USB 2.0 Extension Device Capability:
bLength 7
bDescriptorType 16
bDevCapabilityType 2
bmAttributes 0x00000002
HIRD Link Power Management (LPM) Supported
SuperSpeed USB Device Capability:
bLength 10
bDescriptorType 16
bDevCapabilityType 3
bmAttributes 0x00
wSpeedsSupported 0x000e
Device can operate at Full Speed (12Mbps)
Device can operate at High Speed (480Mbps)
Device can operate at SuperSpeed (5Gbps)
bFunctionalitySupport 1
Lowest fully-functional device speed is Full Speed (12Mbps)
bU1DevExitLat 10 micro seconds
bU2DevExitLat 2047 micro seconds
can't get debug descriptor: Resource temporarily unavailable
Device Status: 0x0001
Self Powered

No comments:

Post a Comment