summaryrefslogtreecommitdiff
diff options
authorTaihsiang Ho <taihsiang.ho@canonical.com>2014-10-19 18:18:41 +0000
committerDaniel Manrique <>2014-10-19 18:18:41 +0000
commit57fcc40c826e4a6f49b26460e6899970503ef097 (patch)
tree902faf92a7e1eba4a5245b38abd7f8c80b81ec8e
parent2b94df1c9858b8085563f5351e2dc493ec6b0c09 (diff)
parentb79f445fb4fb807b37097bda5778a5259842b20a (diff)
"Implement xhci driver detection for the controller
of superspeed usb as udisks1 device. Now both of udisks1 and udisks2 USB disk device xhci detection are integrated and work. LP: #1378724 [r=zkrynicki][bug=1378724][author=taihsiangho]"
-rwxr-xr-xbin/removable_storage_test95
1 files changed, 70 insertions, 25 deletions
diff --git a/bin/removable_storage_test b/bin/removable_storage_test
index e1869597..8e7732b8 100755
--- a/bin/removable_storage_test
+++ b/bin/removable_storage_test
@@ -253,24 +253,6 @@ class DiskTest():
else:
self.rem_disks_memory_cards_nm[dev_file] = None
self.rem_disks_nm[dev_file] = None
- # LP: #1313581
- # Compare the pci slot name of the devices using xhci and
- # the pci slot name of the disks,
- # which is usb3 disks in this case so far,
- # to make sure the usb3 disk does be on the bus using xhci
- # TODO: it will be better to extend to be all kinds of drivers.
- try:
- udev_devices_xhci = get_udev_xhci_devices(udev_client)
- for udev_device_xhci in udev_devices_xhci:
- pci_slot_name = udev_device_xhci.get_property('PCI_SLOT_NAME')
- for udev_device in udev_devices:
- devpath = udev_device.get_property('DEVPATH')
- if (self._compare_pci_slot_from_devpath(devpath,
- pci_slot_name)):
- self.rem_disks_xhci[
- udev_device.get_property('DEVNAME')] = 'xhci'
- except:
- logging.error("Failed to get driver information.")
def _probe_disks_udisks1(self, bus):
"""
@@ -321,6 +303,30 @@ class DiskTest():
self.rem_disks_nm[dev_file] = None
self.rem_disks_memory_cards_nm[dev_file] = None
+ def get_disks_xhci(self):
+ """
+ Compare
+ 1. the pci slot name of the devices using xhci
+ 2. the pci slot name of the disks,
+ which is usb3 disks in this case so far,
+ to make sure the usb3 disk does be on the controller using xhci
+ """
+ # LP: #1378724
+ udev_client = GUdev.Client()
+ # Get a collection of all udev devices corresponding to block devices
+ udev_devices = get_udev_block_devices(udev_client)
+ # Get a collection of all udev devices corresponding to xhci devices
+ udev_devices_xhci = get_udev_xhci_devices(udev_client)
+ for udev_device_xhci in udev_devices_xhci:
+ pci_slot_name = udev_device_xhci.get_property('PCI_SLOT_NAME')
+ for udev_device in udev_devices:
+ devpath = udev_device.get_property('DEVPATH')
+ if (self._compare_pci_slot_from_devpath(devpath,
+ pci_slot_name)):
+ self.rem_disks_xhci[
+ udev_device.get_property('DEVNAME')] = 'xhci'
+ return self.rem_disks_xhci
+
def mount(self):
passed_mount = {}
@@ -645,18 +651,57 @@ def main():
return 1
else:
# LP: 1313581
+ # Try to figure out whether the disk
+ # is SuperSpeed USB and using xhci_hcd driver.
if (args.driver == 'xhci_hcd'):
- if(5000000000 == test.rem_disks_speed[disk] and
- 'xhci' == test.rem_disks_xhci[disk]):
+ # The speed reported by udisks is sometimes
+ # less than 5G bits/s, for example,
+ # it may be 705032705 bits/s
+ # So using
+ # 500000000
+ # = 500 M bits/s
+ # > 480 M bits/s ( USB 2.0 spec.)
+ # to make sure that it is higher USB version than 2.0
+ #
+ # int() for int(test.rem_disks_speed[disk])
+ # is necessary
+ # because the speed value of
+ # the dictionary rem_disks_speed is
+ # 1. str or int from _probe_disks_udisks2
+ # 2. int from _probe_disks_udisks1.
+ # This is really a mess. : (
+ print("\t\t--------------------------------")
+ if(500000000 < int(test.rem_disks_speed[disk])):
print("\t\tDevice Detected: SuperSpeed USB")
- print("\t\tDriver Detected: xhci_hcd")
+ # Unlike rem_disks_speed,
+ # which must has the connect speed
+ # for each disk devices,
+ # disk devices may not use xhci as
+ # controller drivers.
+ # This will raise KeyError for no
+ # associated disk device was found.
+ xhci_disks = test.get_disks_xhci()
+ # pep8 style suggest to limit the try clause
+ # to the absolute minimum amount of code necessary
+ try:
+ disk_xhci_flag = xhci_disks[disk]
+ except KeyError:
+ print("\t\tDisk does not use xhci_hci.")
+ return 1
+ else:
+ if('xhci' == disk_xhci_flag):
+ print("\t\tDriver Detected: xhci_hcd")
+ else:
+ print("\t\tDisk does not use xhci_hci.")
+ logging.debug("disk_xhci_flag is not xhci")
+ return 1
else:
# Give it a hint for the detection failure.
# LP: #1362902
- print("No SuperSpeed USB using xhci_hcd \
- was detected correctly.")
- print("Hint: please use dmesg to check \
- the system status again.")
+ print(("\t\tNo SuperSpeed USB using xhci_hcd "
+ "was detected correctly."))
+ print(("\t\tHint: please use dmesg to check "
+ "the system status again."))
return 1
# Pass is not assured
if (not args.pass_speed or