diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-16 18:04:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-16 18:04:26 -0400 |
commit | 971f115a50afbe409825c9f3399d5a3b9aca4381 (patch) | |
tree | cb42dc07a032e325f22b64d961587c081225c6d6 /tools | |
parent | 2e270d84223262a38d4755c61d55f5c73ea89e56 (diff) | |
parent | 500132a0f26ad7d9916102193cbc6c1b1becb373 (diff) |
Merge branch 'usb-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* 'usb-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (172 commits)
USB: Add support for SuperSpeed isoc endpoints
xhci: Clean up cycle bit math used during stalls.
xhci: Fix cycle bit calculation during stall handling.
xhci: Update internal dequeue pointers after stalls.
USB: Disable auto-suspend for USB 3.0 hubs.
USB: Remove bogus USB_PORT_STAT_SUPER_SPEED symbol.
xhci: Return canceled URBs immediately when host is halted.
xhci: Fixes for suspend/resume of shared HCDs.
xhci: Fix re-init on power loss after resume.
xhci: Make roothub functions deal with device removal.
xhci: Limit roothub ports to 15 USB3 & 31 USB2 ports.
xhci: Return a USB 3.0 hub descriptor for USB3 roothub.
xhci: Register second xHCI roothub.
xhci: Change xhci_find_slot_id_by_port() API.
xhci: Refactor bus suspend state into a struct.
xhci: Index with a port array instead of PORTSC addresses.
USB: Set usb_hcd->state and flags for shared roothubs.
usb: Make core allocate resources per PCI-device.
usb: Store bus type in usb_hcd, not in driver flags.
usb: Change usb_hcd->bandwidth_mutex to a pointer.
...
Diffstat (limited to 'tools')
-rw-r--r-- | tools/usb/Makefile | 13 | ||||
-rw-r--r-- | tools/usb/ffs-test.c | 4 | ||||
-rw-r--r-- | tools/usb/hcd-tests.sh | 275 |
3 files changed, 290 insertions, 2 deletions
diff --git a/tools/usb/Makefile b/tools/usb/Makefile new file mode 100644 index 000000000000..8b704af14349 --- /dev/null +++ b/tools/usb/Makefile | |||
@@ -0,0 +1,13 @@ | |||
1 | # Makefile for USB tools | ||
2 | |||
3 | CC = $(CROSS_COMPILE)gcc | ||
4 | PTHREAD_LIBS = -lpthread | ||
5 | WARNINGS = -Wall -Wextra | ||
6 | CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) | ||
7 | |||
8 | all: testusb ffs-test | ||
9 | %: %.c | ||
10 | $(CC) $(CFLAGS) -o $@ $^ | ||
11 | |||
12 | clean: | ||
13 | $(RM) testusb ffs-test | ||
diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c index bbe2e3a2ea62..b9c798631699 100644 --- a/tools/usb/ffs-test.c +++ b/tools/usb/ffs-test.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <sys/types.h> | 37 | #include <sys/types.h> |
38 | #include <unistd.h> | 38 | #include <unistd.h> |
39 | 39 | ||
40 | #include <linux/usb/functionfs.h> | 40 | #include "../../include/linux/usb/functionfs.h" |
41 | 41 | ||
42 | 42 | ||
43 | /******************** Little Endian Handling ********************************/ | 43 | /******************** Little Endian Handling ********************************/ |
@@ -450,7 +450,7 @@ invalid: | |||
450 | len, expected, *p); | 450 | len, expected, *p); |
451 | for (p = buf, len = 0; len < nbytes; ++p, ++len) { | 451 | for (p = buf, len = 0; len < nbytes; ++p, ++len) { |
452 | if (0 == (len % 32)) | 452 | if (0 == (len % 32)) |
453 | fprintf(stderr, "%4d:", len); | 453 | fprintf(stderr, "%4zd:", len); |
454 | fprintf(stderr, " %02x", *p); | 454 | fprintf(stderr, " %02x", *p); |
455 | if (31 == (len % 32)) | 455 | if (31 == (len % 32)) |
456 | fprintf(stderr, "\n"); | 456 | fprintf(stderr, "\n"); |
diff --git a/tools/usb/hcd-tests.sh b/tools/usb/hcd-tests.sh new file mode 100644 index 000000000000..b30b3dc4c788 --- /dev/null +++ b/tools/usb/hcd-tests.sh | |||
@@ -0,0 +1,275 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # test types can be passed on the command line: | ||
4 | # | ||
5 | # - control: any device can do this | ||
6 | # - out, in: out needs 'bulk sink' firmware, in needs 'bulk src' | ||
7 | # - iso-out, iso-in: out needs 'iso sink' firmware, in needs 'iso src' | ||
8 | # - halt: needs bulk sink+src, tests halt set/clear from host | ||
9 | # - unlink: needs bulk sink and/or src, test HCD unlink processing | ||
10 | # - loop: needs firmware that will buffer N transfers | ||
11 | # | ||
12 | # run it for hours, days, weeks. | ||
13 | # | ||
14 | |||
15 | # | ||
16 | # this default provides a steady test load for a bulk device | ||
17 | # | ||
18 | TYPES='control out in' | ||
19 | #TYPES='control out in halt' | ||
20 | |||
21 | # | ||
22 | # to test HCD code | ||
23 | # | ||
24 | # - include unlink tests | ||
25 | # - add some ${RANDOM}ness | ||
26 | # - connect several devices concurrently (same HC) | ||
27 | # - keep HC's IRQ lines busy with unrelated traffic (IDE, net, ...) | ||
28 | # - add other concurrent system loads | ||
29 | # | ||
30 | |||
31 | declare -i COUNT BUFLEN | ||
32 | |||
33 | COUNT=50000 | ||
34 | BUFLEN=2048 | ||
35 | |||
36 | # NOTE: the 'in' and 'out' cases are usually bulk, but can be | ||
37 | # set up to use interrupt transfers by 'usbtest' module options | ||
38 | |||
39 | |||
40 | if [ "$DEVICE" = "" ]; then | ||
41 | echo "testing ALL recognized usbtest devices" | ||
42 | echo "" | ||
43 | TEST_ARGS="-a" | ||
44 | else | ||
45 | TEST_ARGS="" | ||
46 | fi | ||
47 | |||
48 | do_test () | ||
49 | { | ||
50 | if ! ./testusb $TEST_ARGS -s $BUFLEN -c $COUNT $* 2>/dev/null | ||
51 | then | ||
52 | echo "FAIL" | ||
53 | exit 1 | ||
54 | fi | ||
55 | } | ||
56 | |||
57 | ARGS="$*" | ||
58 | |||
59 | if [ "$ARGS" = "" ]; | ||
60 | then | ||
61 | ARGS="$TYPES" | ||
62 | fi | ||
63 | |||
64 | # FIXME use /sys/bus/usb/device/$THIS/bConfigurationValue to | ||
65 | # check and change configs | ||
66 | |||
67 | CONFIG='' | ||
68 | |||
69 | check_config () | ||
70 | { | ||
71 | if [ "$CONFIG" = "" ]; then | ||
72 | CONFIG=$1 | ||
73 | echo "assuming $CONFIG configuration" | ||
74 | return | ||
75 | fi | ||
76 | if [ "$CONFIG" = $1 ]; then | ||
77 | return | ||
78 | fi | ||
79 | |||
80 | echo "** device must be in $1 config, but it's $CONFIG instead" | ||
81 | exit 1 | ||
82 | } | ||
83 | |||
84 | |||
85 | echo "TESTING: $ARGS" | ||
86 | |||
87 | while : true | ||
88 | do | ||
89 | echo $(date) | ||
90 | |||
91 | for TYPE in $ARGS | ||
92 | do | ||
93 | # restore defaults | ||
94 | COUNT=5000 | ||
95 | BUFLEN=2048 | ||
96 | |||
97 | # FIXME automatically multiply COUNT by 10 when | ||
98 | # /sys/bus/usb/device/$THIS/speed == "480" | ||
99 | |||
100 | # COUNT=50000 | ||
101 | |||
102 | case $TYPE in | ||
103 | control) | ||
104 | # any device, in any configuration, can use this. | ||
105 | echo '** Control test cases:' | ||
106 | |||
107 | echo "test 9: ch9 postconfig" | ||
108 | do_test -t 9 -c 5000 | ||
109 | echo "test 10: control queueing" | ||
110 | do_test -t 10 -c 5000 | ||
111 | |||
112 | # this relies on some vendor-specific commands | ||
113 | echo "test 14: control writes" | ||
114 | do_test -t 14 -c 15000 -s 256 -v 1 | ||
115 | |||
116 | echo "test 21: control writes, unaligned" | ||
117 | do_test -t 21 -c 100 -s 256 -v 1 | ||
118 | |||
119 | ;; | ||
120 | |||
121 | out) | ||
122 | check_config sink-src | ||
123 | echo '** Host Write (OUT) test cases:' | ||
124 | |||
125 | echo "test 1: $COUNT transfers, same size" | ||
126 | do_test -t 1 | ||
127 | echo "test 3: $COUNT transfers, variable/short size" | ||
128 | do_test -t 3 -v 421 | ||
129 | |||
130 | COUNT=100 | ||
131 | echo "test 17: $COUNT transfers, unaligned DMA map by core" | ||
132 | do_test -t 17 | ||
133 | |||
134 | echo "test 19: $COUNT transfers, unaligned DMA map by usb_alloc_coherent" | ||
135 | do_test -t 19 | ||
136 | |||
137 | COUNT=2000 | ||
138 | echo "test 5: $COUNT scatterlists, same size entries" | ||
139 | do_test -t 5 | ||
140 | |||
141 | # try to trigger short OUT processing bugs | ||
142 | echo "test 7a: $COUNT scatterlists, variable size/short entries" | ||
143 | do_test -t 7 -v 579 | ||
144 | BUFLEN=4096 | ||
145 | echo "test 7b: $COUNT scatterlists, variable size/bigger entries" | ||
146 | do_test -t 7 -v 41 | ||
147 | BUFLEN=64 | ||
148 | echo "test 7c: $COUNT scatterlists, variable size/micro entries" | ||
149 | do_test -t 7 -v 63 | ||
150 | ;; | ||
151 | |||
152 | iso-out) | ||
153 | check_config sink-src | ||
154 | echo '** Host ISOCHRONOUS Write (OUT) test cases:' | ||
155 | |||
156 | # at peak iso transfer rates: | ||
157 | # - usb 2.0 high bandwidth, this is one frame. | ||
158 | # - usb 1.1, it's twenty-four frames. | ||
159 | BUFLEN=24500 | ||
160 | |||
161 | COUNT=1000 | ||
162 | |||
163 | # COUNT=10000 | ||
164 | |||
165 | echo "test 15: $COUNT transfers, same size" | ||
166 | # do_test -t 15 -g 3 -v 0 | ||
167 | BUFLEN=32768 | ||
168 | do_test -t 15 -g 8 -v 0 | ||
169 | |||
170 | # FIXME it'd make sense to have an iso OUT test issuing | ||
171 | # short writes on more packets than the last one | ||
172 | |||
173 | COUNT=100 | ||
174 | echo "test 22: $COUNT transfers, non aligned" | ||
175 | do_test -t 22 -g 8 -v 0 | ||
176 | |||
177 | ;; | ||
178 | |||
179 | in) | ||
180 | check_config sink-src | ||
181 | echo '** Host Read (IN) test cases:' | ||
182 | |||
183 | # NOTE: these "variable size" reads are just multiples | ||
184 | # of 512 bytes, no EOVERFLOW testing is done yet | ||
185 | |||
186 | echo "test 2: $COUNT transfers, same size" | ||
187 | do_test -t 2 | ||
188 | echo "test 4: $COUNT transfers, variable size" | ||
189 | do_test -t 4 | ||
190 | |||
191 | COUNT=100 | ||
192 | echo "test 18: $COUNT transfers, unaligned DMA map by core" | ||
193 | do_test -t 18 | ||
194 | |||
195 | echo "test 20: $COUNT transfers, unaligned DMA map by usb_alloc_coherent" | ||
196 | do_test -t 20 | ||
197 | |||
198 | COUNT=2000 | ||
199 | echo "test 6: $COUNT scatterlists, same size entries" | ||
200 | do_test -t 6 | ||
201 | echo "test 8: $COUNT scatterlists, variable size entries" | ||
202 | do_test -t 8 | ||
203 | ;; | ||
204 | |||
205 | iso-in) | ||
206 | check_config sink-src | ||
207 | echo '** Host ISOCHRONOUS Read (IN) test cases:' | ||
208 | |||
209 | # at peak iso transfer rates: | ||
210 | # - usb 2.0 high bandwidth, this is one frame. | ||
211 | # - usb 1.1, it's twenty-four frames. | ||
212 | BUFLEN=24500 | ||
213 | |||
214 | COUNT=1000 | ||
215 | |||
216 | # COUNT=10000 | ||
217 | |||
218 | echo "test 16: $COUNT transfers, same size" | ||
219 | # do_test -t 16 -g 3 -v 0 | ||
220 | BUFLEN=32768 | ||
221 | do_test -t 16 -g 8 -v 0 | ||
222 | |||
223 | # FIXME since iso expects faults, it'd make sense | ||
224 | # to have an iso IN test issuing short reads ... | ||
225 | |||
226 | COUNT=100 | ||
227 | echo "test 23: $COUNT transfers, unaligned" | ||
228 | do_test -t 23 -g 8 -v 0 | ||
229 | |||
230 | ;; | ||
231 | |||
232 | halt) | ||
233 | # NOTE: sometimes hardware doesn't cooperate well with halting | ||
234 | # endpoints from the host side. so long as mass-storage class | ||
235 | # firmware can halt them from the device, don't worry much if | ||
236 | # you can't make this test work on your device. | ||
237 | COUNT=2000 | ||
238 | echo "test 13: $COUNT halt set/clear" | ||
239 | do_test -t 13 | ||
240 | ;; | ||
241 | |||
242 | unlink) | ||
243 | COUNT=2000 | ||
244 | echo "test 11: $COUNT read unlinks" | ||
245 | do_test -t 11 | ||
246 | |||
247 | echo "test 12: $COUNT write unlinks" | ||
248 | do_test -t 12 | ||
249 | ;; | ||
250 | |||
251 | loop) | ||
252 | # defaults need too much buffering for ez-usb devices | ||
253 | BUFLEN=2048 | ||
254 | COUNT=32 | ||
255 | |||
256 | # modprobe g_zero qlen=$COUNT buflen=$BUFLEN loopdefault | ||
257 | check_config loopback | ||
258 | |||
259 | # FIXME someone needs to write and merge a version of this | ||
260 | |||
261 | echo "write $COUNT buffers of $BUFLEN bytes, read them back" | ||
262 | |||
263 | echo "write $COUNT variable size buffers, read them back" | ||
264 | |||
265 | ;; | ||
266 | |||
267 | *) | ||
268 | echo "Don't understand test type $TYPE" | ||
269 | exit 1; | ||
270 | esac | ||
271 | echo '' | ||
272 | done | ||
273 | done | ||
274 | |||
275 | # vim: sw=4 | ||