Merge lp:~sylvain-pineau/checkbox/usb_version_check into lp:checkbox

Proposed by Sylvain Pineau
Status: Merged
Merged at revision: 1532
Proposed branch: lp:~sylvain-pineau/checkbox/usb_version_check
Merge into: lp:checkbox
Diff against target: 134 lines (+71/-3)
4 files modified
debian/changelog (+6/-0)
jobs/usb.txt.in (+18/-0)
scripts/block_device_resource (+33/-2)
scripts/disk_read_performance_test (+14/-1)
To merge this branch: bzr merge lp:~sylvain-pineau/checkbox/usb_version_check
Reviewer Review Type Date Requested Status
Daniel Manrique (community) Approve
Review via email: mp+115901@code.launchpad.net

Description of the change

This MR modifies the existing block_device_resource job to add usb3 compliance information.
A new read performance test has been added to usb.txt.in specific for usb3 devices.

For relevant results, USB3 devices must be plugged in before checkbox starts.

To post a comment you must log in.
Revision history for this message
Daniel Manrique (roadmr) wrote :

I tested this by merging and building a test checkbox package, adding the tests to whitelists, and doing a checkbox run with a USB 3.0 device inserted.

The test passed and the device (a hard disk) returned a throughput of 84 MB/s, just above the required threshold of 80.

I even looked at the very nice checkbox report with this information.

I have the following comments/requests for information:

1- On the test selection screen, the "Verify USB3 external storage" tests created by the usb/usb3_read_performance job don't appear below the usb category, which looks ugly :( can this be fixed somehow?

2- The test ran on /dev/sda (internal harddisk), even though it had block_device.state=='internal' and block_device.usb3=='unsupported'. I think this relates to bug 1027849, which is being worked on, so we may end up having to wait for that to get fixed.

3- Is it possible to determine whether the motherboard/controller supports USB3 without plugging in a USB3 device? This test will mainly be used for certification, but if we need to plug in a USB3 device into systems before the tests start, this means we can only test as many systems as we have USB3 devices. Compare this with how the existing usb tests work: if the system supports usb2, then you get prompted to insert a compatible device to test, if you have no device you can skip the test.

One possible way of detecting this is looking for xhci initialization in the kernel log:

[ 1.150592] calling xhci_hcd_init+0x0/0x29 @ 1
[ 1.150608] xhci_hcd 0000:06:00.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
[ 1.150622] xhci_hcd 0000:06:00.0: setting latency timer to 64
[ 1.150626] xhci_hcd 0000:06:00.0: xHCI Host Controller
[ 1.150658] xhci_hcd 0000:06:00.0: new USB bus registered, assigned bus number 3
[ 1.150818] xhci_hcd 0000:06:00.0: irq 16, io mem 0xca100000
[ 1.150878] xhci_hcd 0000:06:00.0: irq 42 for MSI/MSI-X
[ 1.150882] xhci_hcd 0000:06:00.0: irq 43 for MSI/MSI-X
[ 1.150885] xhci_hcd 0000:06:00.0: irq 44 for MSI/MSI-X
[ 1.150889] xhci_hcd 0000:06:00.0: irq 45 for MSI/MSI-X
[ 1.150892] xhci_hcd 0000:06:00.0: irq 46 for MSI/MSI-X
[ 1.151030] xHCI xhci_add_endpoint called for root hub
[ 1.151032] xHCI xhci_check_bandwidth called for root hub
[ 1.151101] xhci_hcd 0000:06:00.0: xHCI Host Controller
[ 1.151130] xhci_hcd 0000:06:00.0: new USB bus registered, assigned bus number 4
[ 1.154277] xHCI xhci_add_endpoint called for root hub
[ 1.154279] xHCI xhci_check_bandwidth called for root hub
[ 1.198284] initcall xhci_hcd_init+0x0/0x29 returned 0 after 46671 usecs

Compare to what happens on a non-USB3.0 system:
[ 0.577014] calling xhci_hcd_init+0x0/0x49 @ 1
[ 0.577031] initcall xhci_hcd_init+0x0/0x49 returned 0 after 13 usecs

review: Needs Information
Revision history for this message
Daniel Manrique (roadmr) wrote :

On a system with USB 3.0 I went to /sys/bus/usb/devices. There's a device for each of the USB controllers (4 in all). The USB 3.0 controller seems to be distinguished by:

cat bDeviceClass
09 (09 means Hub)
cat speed
5000 (as opposed to 480 for USB 2.0 controllers).
cat version
3.0
cat product
xHCI Host Controller (as opposed to EHCI Host Controller or even OHCI for USB 1.0).

I think this could be used to determine whether a system supports USB 3.0 even if an actual device is not currently plugged in.

Unfortunately not a lot of this information seems present in udevadm output :(

Revision history for this message
Daniel Manrique (roadmr) wrote :

OK, I've been looking into this, and I think spineau's research is quite sound; the problem is that we can't know if a specific disk device supports usb3 if it's not inserted beforehand. This is needed because we're running the disk_performance test, not the usb_storage_transfer test like we do for manual USB testing. So even though the user experience may not be ideal, this seems to be the only way to know which disks to run the tests against... :(

Revision history for this message
Chris Gagnon (chris.gagnon) wrote :

I've done some usb3 tests in the sutton project

You can look at lsusb and grep for 'Linux Foundation 3.0 root hub' or 1d6b:0003 to see if usb 3.0 is supported, if the device is on the same bus you can tell if it's being seen as a USB 3.0 device or a USB 2.0 Device.

Example

$lsusb
<stuff here>
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
<more stuff here>
Bus 006 Device 002: ID <idof>:<usbkey>

if the device is on bus 006 it's a usb 3.0 device on the 3.0 root hub.

If it's a 3.0 device on a 2.0 port it will show up as on the same bus as a 1d6b:0002 Linux Foundation 2.0 root hub...

Revision history for this message
Daniel Manrique (roadmr) wrote :

OK, so the issue here is not USB3 device detection, but test creation for each connected drive. That's where the need to have the device plugged in beforehand comes from. Based on that, I have no objections and I'll merge this now. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-07-19 15:32:45 +0000
3+++ debian/changelog 2012-07-20 07:45:25 +0000
4@@ -2,6 +2,12 @@
5
6 [Daniel Manrique]
7 * New version 0.14.3 for Quantal Quetzal development.
8+
9+ [Sylvain Pineau]
10+ * jobs/usb.txt.in, scripts/disk_read_performance_test: Add a USB3 read
11+ performance test.
12+ scripts/block_device_resource: Add the maximum usb specification supported
13+ by both a block device and the corresponding root hub port.
14
15 [Jeff Marcom]
16 * Added timeout to job call for disk smart test.
17
18=== modified file 'jobs/usb.txt.in'
19--- jobs/usb.txt.in 2012-07-11 19:01:24 +0000
20+++ jobs/usb.txt.in 2012-07-20 07:45:25 +0000
21@@ -140,3 +140,21 @@
22 5. Repeat with each external USB slot.
23 VERIFICATION:
24 Do all USB slots work with the device?
25+
26+plugin: local
27+name: usb/usb3_read_performance
28+requires:
29+ device.category == 'DISK'
30+_description: Verify USB3 external storage performs at or above baseline performance
31+command:
32+ cat <<'EOF' | run_templates -t -s 'udev_resource | filter_templates -w "category=DISK"'
33+ plugin: shell
34+ name: usb/usb3_read_performance_`ls /sys$path/block`
35+ requires:
36+ device.path == "$path"
37+ block_device.name == "`ls /sys$path/block`" and block_device.state == 'removable' and block_device.usb3 == 'supported'
38+ package.name == 'linux'
39+ description: USB3 read performance test for $product
40+ user: root
41+ command: disk_read_performance_test `ls /sys$path/block | sed 's|!|/|'`
42+ EOF
43
44=== modified file 'scripts/block_device_resource'
45--- scripts/block_device_resource 2012-06-29 19:47:58 +0000
46+++ scripts/block_device_resource 2012-07-20 07:45:25 +0000
47@@ -4,6 +4,7 @@
48 import re
49 from glob import glob
50
51+rootdir_pattern = re.compile('^.*?/devices')
52
53 def device_state(name):
54 """
55@@ -13,7 +14,6 @@
56 if f.read(1) == '1':
57 return 'removable'
58
59- rootdir_pattern = re.compile('^.*?/devices')
60 path = rootdir_pattern.sub('', os.readlink('/sys/block/%s' % name))
61 hotplug_buses = ("usb", "ieee1394", "mmc", "pcmcia", "firewire")
62 for bus in hotplug_buses:
63@@ -27,10 +27,41 @@
64 return 'internal'
65
66
67+def usb_support(name, version):
68+ """
69+ Check the USB specification number for both hub port and device
70+ """
71+ path = rootdir_pattern.sub('', os.readlink('/sys/block/%s' % name))
72+
73+ # Remove the usb config.interface part of the path
74+ m = re.match('((.*usb\d+).*\/)\d-[\d\.:\-]+\/.*', path)
75+ if m:
76+ device_path = m.group(1)
77+ hub_port_path = m.group(2)
78+
79+ # Check the highest version of USB the device supports
80+ with open('/sys/devices/%s/version' %device_path) as f:
81+ if float(f.readline()) < version:
82+ return 'unsupported'
83+
84+ # Check the highest version of USB the hub supports
85+ with open('/sys/devices/%s/version' %hub_port_path) as f:
86+ if float(f.readline()) < version:
87+ return 'unsupported'
88+
89+ return 'supported'
90+
91+ return 'unsupported'
92+
93+
94 for path in glob('/sys/block/*/device'):
95 name = re.sub('.*/(.*?)/device', '\g<1>', path)
96 state = device_state(name)
97+ usb2 = usb_support(name, 2.00)
98+ usb3 = usb_support(name, 3.00)
99 print("""\
100 name: %s
101 state: %s
102-""" % (name, state))
103+usb2: %s
104+usb3: %s
105+""" % (name, state, usb2, usb3))
106
107=== modified file 'scripts/disk_read_performance_test'
108--- scripts/disk_read_performance_test 2012-07-11 02:54:40 +0000
109+++ scripts/disk_read_performance_test 2012-07-20 07:45:25 +0000
110@@ -12,10 +12,23 @@
111 echo "---------------------------------------------------"
112
113 disk_type=`udevadm info --name /dev/$disk --query property | grep "ID_BUS" | awk '{gsub(/ID_BUS=/," ")}{printf $1}'`
114+ dev_path=`udevadm info --name /dev/$disk --query property | grep "DEVPATH" | awk '{gsub(/DEVPATH=/," ")}{printf $1}'`
115 echo "INFO: $disk type is $disk_type"
116
117 case $disk_type in
118- "usb" ) MIN_BUF_READ=7;; #Custom metrics are guesstimates for now...
119+ "usb" )
120+ #Custom metrics are guesstimates for now...
121+ MIN_BUF_READ=7
122+
123+ # Increase MIN_BUF_READ if a USB3 device is plugged in a USB3 hub port
124+ if [[ $dev_path =~ ((.*usb[0-9]+).*\/)[0-9]-[0-9\.:\-]+\/.* ]]; then
125+ device_version=`cat '/sys/'${BASH_REMATCH[1]}'/version'`
126+ hub_port_version=`cat '/sys/'${BASH_REMATCH[2]}'/version'`
127+ if [ $(echo "$device_version >= 3.00"|bc -l) -eq 1 -a $(echo "$hub_port_version >= 3.00"|bc -l) -eq 1 ]; then
128+ MIN_BUF_READ=80
129+ fi
130+ fi
131+ ;;
132 "ide" ) MIN_BUF_READ=40;;
133 * ) MIN_BUF_READ=$DEFAULT_BUF_READ;;
134 esac

Subscribers

People subscribed via source and target branches