diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-05 19:14:12 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-05 19:14:12 -0400 |
commit | 07c4dd3435aa387d3b58f4e941dc516513f14507 (patch) | |
tree | 26ebc60562ba573ec499f850c53ffd48f2bfdf72 /tools | |
parent | f60342fac9fae20ada2cd5faadbc2a1337cae03f (diff) | |
parent | c2ef60fea2dc7f903450926aee1f9c282ea529ca (diff) |
Merge tag 'usb-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB and PHY updates from Greg KH:
"Here is the big USB pull request for 4.18-rc1.
Lots of stuff here, the highlights are:
- phy driver updates and new additions
- usual set of xhci driver updates
- normal set of musb updates
- gadget driver updates and new controllers
- typec work, it's getting closer to getting fully out of the staging
portion of the tree.
- lots of minor cleanups and bugfixes.
All of these have been in linux-next for a while with no reported
issues"
* tag 'usb-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (263 commits)
Revert "xhci: Reset Renesas uPD72020x USB controller for 32-bit DMA issue"
xhci: Add quirk to zero 64bit registers on Renesas PCIe controllers
xhci: Allow more than 32 quirks
usb: xhci: force all memory allocations to node
selftests: add test for USB over IP driver
USB: typec: fsusb302: no need to check return value of debugfs_create_dir()
USB: gadget: udc: s3c2410_udc: no need to check return value of debugfs_create functions
USB: gadget: udc: renesas_usb3: no need to check return value of debugfs_create functions
USB: gadget: udc: pxa27x_udc: no need to check return value of debugfs_create functions
USB: gadget: udc: gr_udc: no need to check return value of debugfs_create functions
USB: gadget: udc: bcm63xx_udc: no need to check return value of debugfs_create functions
USB: udc: atmel_usba_udc: no need to check return value of debugfs_create functions
USB: dwc3: no need to check return value of debugfs_create functions
USB: dwc2: no need to check return value of debugfs_create functions
USB: core: no need to check return value of debugfs_create functions
USB: chipidea: no need to check return value of debugfs_create functions
USB: ehci-hcd: no need to check return value of debugfs_create functions
USB: fhci-hcd: no need to check return value of debugfs_create functions
USB: fotg210-hcd: no need to check return value of debugfs_create functions
USB: imx21-hcd: no need to check return value of debugfs_create functions
...
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/testing/selftests/drivers/usb/usbip/usbip_test.sh | 198 | ||||
-rw-r--r-- | tools/usb/usbip/libsrc/vhci_driver.c | 32 | ||||
-rw-r--r-- | tools/usb/usbip/libsrc/vhci_driver.h | 3 | ||||
-rw-r--r-- | tools/usb/usbip/src/usbip_detach.c | 46 |
4 files changed, 253 insertions, 26 deletions
diff --git a/tools/testing/selftests/drivers/usb/usbip/usbip_test.sh b/tools/testing/selftests/drivers/usb/usbip/usbip_test.sh new file mode 100755 index 000000000000..1893d0f59ad7 --- /dev/null +++ b/tools/testing/selftests/drivers/usb/usbip/usbip_test.sh | |||
@@ -0,0 +1,198 @@ | |||
1 | #!/bin/bash | ||
2 | # SPDX-License-Identifier: GPL-2.0 | ||
3 | |||
4 | # Kselftest framework requirement - SKIP code is 4. | ||
5 | ksft_skip=4 | ||
6 | |||
7 | usage() { echo "usbip_test.sh -b <busid> -p <usbip tools path>"; exit 1; } | ||
8 | |||
9 | while getopts "h:b:p:" arg; do | ||
10 | case "${arg}" in | ||
11 | h) | ||
12 | usage | ||
13 | ;; | ||
14 | b) | ||
15 | busid=${OPTARG} | ||
16 | ;; | ||
17 | p) | ||
18 | tools_path=${OPTARG} | ||
19 | ;; | ||
20 | *) | ||
21 | usage | ||
22 | ;; | ||
23 | esac | ||
24 | done | ||
25 | shift $((OPTIND-1)) | ||
26 | |||
27 | if [ -z "${busid}" ]; then | ||
28 | usage | ||
29 | fi | ||
30 | |||
31 | echo "Running USB over IP Testing on $busid"; | ||
32 | |||
33 | test_end_msg="End of USB over IP Testing on $busid" | ||
34 | |||
35 | if [ $UID != 0 ]; then | ||
36 | echo "Please run usbip_test as root [SKIP]" | ||
37 | echo $test_end_msg | ||
38 | exit $ksft_skip | ||
39 | fi | ||
40 | |||
41 | echo "Load usbip_host module" | ||
42 | if ! /sbin/modprobe -q -n usbip_host; then | ||
43 | echo "usbip_test: module usbip_host is not found [SKIP]" | ||
44 | echo $test_end_msg | ||
45 | exit $ksft_skip | ||
46 | fi | ||
47 | |||
48 | if /sbin/modprobe -q usbip_host; then | ||
49 | /sbin/modprobe -q -r test_bitmap | ||
50 | echo "usbip_test: module usbip_host is loaded [OK]" | ||
51 | else | ||
52 | echo "usbip_test: module usbip_host failed to load [FAIL]" | ||
53 | echo $test_end_msg | ||
54 | exit 1 | ||
55 | fi | ||
56 | |||
57 | echo "Load vhci_hcd module" | ||
58 | if /sbin/modprobe -q vhci_hcd; then | ||
59 | /sbin/modprobe -q -r test_bitmap | ||
60 | echo "usbip_test: module vhci_hcd is loaded [OK]" | ||
61 | else | ||
62 | echo "usbip_test: module vhci_hcd failed to load [FAIL]" | ||
63 | echo $test_end_msg | ||
64 | exit 1 | ||
65 | fi | ||
66 | echo "==============================================================" | ||
67 | |||
68 | cd $tools_path; | ||
69 | |||
70 | if [ ! -f src/usbip ]; then | ||
71 | echo "Please build usbip tools" | ||
72 | echo $test_end_msg | ||
73 | exit $ksft_skip | ||
74 | fi | ||
75 | |||
76 | echo "Expect to see export-able devices"; | ||
77 | src/usbip list -l; | ||
78 | echo "==============================================================" | ||
79 | |||
80 | echo "Run lsusb to see all usb devices" | ||
81 | lsusb -t; | ||
82 | echo "==============================================================" | ||
83 | |||
84 | src/usbipd -D; | ||
85 | |||
86 | echo "Get exported devices from localhost - expect to see none"; | ||
87 | src/usbip list -r localhost; | ||
88 | echo "==============================================================" | ||
89 | |||
90 | echo "bind devices"; | ||
91 | src/usbip bind -b $busid; | ||
92 | echo "==============================================================" | ||
93 | |||
94 | echo "Run lsusb - bound devices should be under usbip_host control" | ||
95 | lsusb -t; | ||
96 | echo "==============================================================" | ||
97 | |||
98 | echo "bind devices - expect already bound messages" | ||
99 | src/usbip bind -b $busid; | ||
100 | echo "==============================================================" | ||
101 | |||
102 | echo "Get exported devices from localhost - expect to see exported devices"; | ||
103 | src/usbip list -r localhost; | ||
104 | echo "==============================================================" | ||
105 | |||
106 | echo "unbind devices"; | ||
107 | src/usbip unbind -b $busid; | ||
108 | echo "==============================================================" | ||
109 | |||
110 | echo "Run lsusb - bound devices should be rebound to original drivers" | ||
111 | lsusb -t; | ||
112 | echo "==============================================================" | ||
113 | |||
114 | echo "unbind devices - expect no devices bound message"; | ||
115 | src/usbip unbind -b $busid; | ||
116 | echo "==============================================================" | ||
117 | |||
118 | echo "Get exported devices from localhost - expect to see none"; | ||
119 | src/usbip list -r localhost; | ||
120 | echo "==============================================================" | ||
121 | |||
122 | echo "List imported devices - expect to see none"; | ||
123 | src/usbip port; | ||
124 | echo "==============================================================" | ||
125 | |||
126 | echo "Import devices from localhost - should fail with no devices" | ||
127 | src/usbip attach -r localhost -b $busid; | ||
128 | echo "==============================================================" | ||
129 | |||
130 | echo "bind devices"; | ||
131 | src/usbip bind -b $busid; | ||
132 | echo "==============================================================" | ||
133 | |||
134 | echo "List imported devices - expect to see exported devices"; | ||
135 | src/usbip list -r localhost; | ||
136 | echo "==============================================================" | ||
137 | |||
138 | echo "List imported devices - expect to see none"; | ||
139 | src/usbip port; | ||
140 | echo "==============================================================" | ||
141 | |||
142 | echo "Import devices from localhost - should work" | ||
143 | src/usbip attach -r localhost -b $busid; | ||
144 | echo "==============================================================" | ||
145 | |||
146 | echo "List imported devices - expect to see imported devices"; | ||
147 | src/usbip port; | ||
148 | echo "==============================================================" | ||
149 | |||
150 | echo "Import devices from localhost - expect already imported messages" | ||
151 | src/usbip attach -r localhost -b $busid; | ||
152 | echo "==============================================================" | ||
153 | |||
154 | echo "Un-import devices"; | ||
155 | src/usbip detach -p 00; | ||
156 | src/usbip detach -p 01; | ||
157 | echo "==============================================================" | ||
158 | |||
159 | echo "List imported devices - expect to see none"; | ||
160 | src/usbip port; | ||
161 | echo "==============================================================" | ||
162 | |||
163 | echo "Un-import devices - expect no devices to detach messages"; | ||
164 | src/usbip detach -p 00; | ||
165 | src/usbip detach -p 01; | ||
166 | echo "==============================================================" | ||
167 | |||
168 | echo "Detach invalid port tests - expect invalid port error message"; | ||
169 | src/usbip detach -p 100; | ||
170 | echo "==============================================================" | ||
171 | |||
172 | echo "Expect to see export-able devices"; | ||
173 | src/usbip list -l; | ||
174 | echo "==============================================================" | ||
175 | |||
176 | echo "Remove usbip_host module"; | ||
177 | rmmod usbip_host; | ||
178 | |||
179 | echo "Run lsusb - bound devices should be rebound to original drivers" | ||
180 | lsusb -t; | ||
181 | echo "==============================================================" | ||
182 | |||
183 | echo "Run bind without usbip_host - expect fail" | ||
184 | src/usbip bind -b $busid; | ||
185 | echo "==============================================================" | ||
186 | |||
187 | echo "Run lsusb - devices that failed to bind aren't bound to any driver" | ||
188 | lsusb -t; | ||
189 | echo "==============================================================" | ||
190 | |||
191 | echo "modprobe usbip_host - does it work?" | ||
192 | /sbin/modprobe usbip_host | ||
193 | echo "Should see -busid- is not in match_busid table... skip! dmesg" | ||
194 | echo "==============================================================" | ||
195 | dmesg | grep "is not in match_busid table" | ||
196 | echo "==============================================================" | ||
197 | |||
198 | echo $test_end_msg | ||
diff --git a/tools/usb/usbip/libsrc/vhci_driver.c b/tools/usb/usbip/libsrc/vhci_driver.c index c9c81614a66a..4204359c9fee 100644 --- a/tools/usb/usbip/libsrc/vhci_driver.c +++ b/tools/usb/usbip/libsrc/vhci_driver.c | |||
@@ -135,11 +135,11 @@ static int refresh_imported_device_list(void) | |||
135 | return 0; | 135 | return 0; |
136 | } | 136 | } |
137 | 137 | ||
138 | static int get_nports(void) | 138 | static int get_nports(struct udev_device *hc_device) |
139 | { | 139 | { |
140 | const char *attr_nports; | 140 | const char *attr_nports; |
141 | 141 | ||
142 | attr_nports = udev_device_get_sysattr_value(vhci_driver->hc_device, "nports"); | 142 | attr_nports = udev_device_get_sysattr_value(hc_device, "nports"); |
143 | if (!attr_nports) { | 143 | if (!attr_nports) { |
144 | err("udev_device_get_sysattr_value nports failed"); | 144 | err("udev_device_get_sysattr_value nports failed"); |
145 | return -1; | 145 | return -1; |
@@ -242,35 +242,41 @@ static int read_record(int rhport, char *host, unsigned long host_len, | |||
242 | 242 | ||
243 | int usbip_vhci_driver_open(void) | 243 | int usbip_vhci_driver_open(void) |
244 | { | 244 | { |
245 | int nports; | ||
246 | struct udev_device *hc_device; | ||
247 | |||
245 | udev_context = udev_new(); | 248 | udev_context = udev_new(); |
246 | if (!udev_context) { | 249 | if (!udev_context) { |
247 | err("udev_new failed"); | 250 | err("udev_new failed"); |
248 | return -1; | 251 | return -1; |
249 | } | 252 | } |
250 | 253 | ||
251 | vhci_driver = calloc(1, sizeof(struct usbip_vhci_driver)); | ||
252 | |||
253 | /* will be freed in usbip_driver_close() */ | 254 | /* will be freed in usbip_driver_close() */ |
254 | vhci_driver->hc_device = | 255 | hc_device = |
255 | udev_device_new_from_subsystem_sysname(udev_context, | 256 | udev_device_new_from_subsystem_sysname(udev_context, |
256 | USBIP_VHCI_BUS_TYPE, | 257 | USBIP_VHCI_BUS_TYPE, |
257 | USBIP_VHCI_DEVICE_NAME); | 258 | USBIP_VHCI_DEVICE_NAME); |
258 | if (!vhci_driver->hc_device) { | 259 | if (!hc_device) { |
259 | err("udev_device_new_from_subsystem_sysname failed"); | 260 | err("udev_device_new_from_subsystem_sysname failed"); |
260 | goto err; | 261 | goto err; |
261 | } | 262 | } |
262 | 263 | ||
263 | vhci_driver->nports = get_nports(); | 264 | nports = get_nports(hc_device); |
264 | dbg("available ports: %d", vhci_driver->nports); | 265 | if (nports <= 0) { |
265 | |||
266 | if (vhci_driver->nports <= 0) { | ||
267 | err("no available ports"); | 266 | err("no available ports"); |
268 | goto err; | 267 | goto err; |
269 | } else if (vhci_driver->nports > MAXNPORT) { | 268 | } |
270 | err("port number exceeds %d", MAXNPORT); | 269 | dbg("available ports: %d", nports); |
270 | |||
271 | vhci_driver = calloc(1, sizeof(struct usbip_vhci_driver) + | ||
272 | nports * sizeof(struct usbip_imported_device)); | ||
273 | if (!vhci_driver) { | ||
274 | err("vhci_driver allocation failed"); | ||
271 | goto err; | 275 | goto err; |
272 | } | 276 | } |
273 | 277 | ||
278 | vhci_driver->nports = nports; | ||
279 | vhci_driver->hc_device = hc_device; | ||
274 | vhci_driver->ncontrollers = get_ncontrollers(); | 280 | vhci_driver->ncontrollers = get_ncontrollers(); |
275 | dbg("available controllers: %d", vhci_driver->ncontrollers); | 281 | dbg("available controllers: %d", vhci_driver->ncontrollers); |
276 | 282 | ||
@@ -285,7 +291,7 @@ int usbip_vhci_driver_open(void) | |||
285 | return 0; | 291 | return 0; |
286 | 292 | ||
287 | err: | 293 | err: |
288 | udev_device_unref(vhci_driver->hc_device); | 294 | udev_device_unref(hc_device); |
289 | 295 | ||
290 | if (vhci_driver) | 296 | if (vhci_driver) |
291 | free(vhci_driver); | 297 | free(vhci_driver); |
diff --git a/tools/usb/usbip/libsrc/vhci_driver.h b/tools/usb/usbip/libsrc/vhci_driver.h index 418b404d5121..6c9aca216705 100644 --- a/tools/usb/usbip/libsrc/vhci_driver.h +++ b/tools/usb/usbip/libsrc/vhci_driver.h | |||
@@ -13,7 +13,6 @@ | |||
13 | 13 | ||
14 | #define USBIP_VHCI_BUS_TYPE "platform" | 14 | #define USBIP_VHCI_BUS_TYPE "platform" |
15 | #define USBIP_VHCI_DEVICE_NAME "vhci_hcd.0" | 15 | #define USBIP_VHCI_DEVICE_NAME "vhci_hcd.0" |
16 | #define MAXNPORT 128 | ||
17 | 16 | ||
18 | enum hub_speed { | 17 | enum hub_speed { |
19 | HUB_SPEED_HIGH = 0, | 18 | HUB_SPEED_HIGH = 0, |
@@ -41,7 +40,7 @@ struct usbip_vhci_driver { | |||
41 | 40 | ||
42 | int ncontrollers; | 41 | int ncontrollers; |
43 | int nports; | 42 | int nports; |
44 | struct usbip_imported_device idev[MAXNPORT]; | 43 | struct usbip_imported_device idev[]; |
45 | }; | 44 | }; |
46 | 45 | ||
47 | 46 | ||
diff --git a/tools/usb/usbip/src/usbip_detach.c b/tools/usb/usbip/src/usbip_detach.c index 9db9d21bb2ec..777f7286a0c5 100644 --- a/tools/usb/usbip/src/usbip_detach.c +++ b/tools/usb/usbip/src/usbip_detach.c | |||
@@ -43,9 +43,12 @@ void usbip_detach_usage(void) | |||
43 | 43 | ||
44 | static int detach_port(char *port) | 44 | static int detach_port(char *port) |
45 | { | 45 | { |
46 | int ret; | 46 | int ret = 0; |
47 | uint8_t portnum; | 47 | uint8_t portnum; |
48 | char path[PATH_MAX+1]; | 48 | char path[PATH_MAX+1]; |
49 | int i; | ||
50 | struct usbip_imported_device *idev; | ||
51 | int found = 0; | ||
49 | 52 | ||
50 | unsigned int port_len = strlen(port); | 53 | unsigned int port_len = strlen(port); |
51 | 54 | ||
@@ -55,27 +58,48 @@ static int detach_port(char *port) | |||
55 | return -1; | 58 | return -1; |
56 | } | 59 | } |
57 | 60 | ||
58 | /* check max port */ | ||
59 | |||
60 | portnum = atoi(port); | 61 | portnum = atoi(port); |
61 | 62 | ||
62 | /* remove the port state file */ | 63 | ret = usbip_vhci_driver_open(); |
64 | if (ret < 0) { | ||
65 | err("open vhci_driver"); | ||
66 | return -1; | ||
67 | } | ||
68 | |||
69 | /* check for invalid port */ | ||
70 | for (i = 0; i < vhci_driver->nports; i++) { | ||
71 | idev = &vhci_driver->idev[i]; | ||
72 | |||
73 | if (idev->port == portnum) { | ||
74 | found = 1; | ||
75 | if (idev->status != VDEV_ST_NULL) | ||
76 | break; | ||
77 | info("Port %d is already detached!\n", idev->port); | ||
78 | goto call_driver_close; | ||
79 | } | ||
80 | } | ||
63 | 81 | ||
82 | if (!found) { | ||
83 | err("Invalid port %s > maxports %d", | ||
84 | port, vhci_driver->nports); | ||
85 | goto call_driver_close; | ||
86 | } | ||
87 | |||
88 | /* remove the port state file */ | ||
64 | snprintf(path, PATH_MAX, VHCI_STATE_PATH"/port%d", portnum); | 89 | snprintf(path, PATH_MAX, VHCI_STATE_PATH"/port%d", portnum); |
65 | 90 | ||
66 | remove(path); | 91 | remove(path); |
67 | rmdir(VHCI_STATE_PATH); | 92 | rmdir(VHCI_STATE_PATH); |
68 | 93 | ||
69 | ret = usbip_vhci_driver_open(); | 94 | ret = usbip_vhci_detach_device(portnum); |
70 | if (ret < 0) { | 95 | if (ret < 0) { |
71 | err("open vhci_driver"); | 96 | ret = -1; |
72 | return -1; | 97 | err("Port %d detach request failed!\n", portnum); |
98 | goto call_driver_close; | ||
73 | } | 99 | } |
100 | info("Port %d is now detached!\n", portnum); | ||
74 | 101 | ||
75 | ret = usbip_vhci_detach_device(portnum); | 102 | call_driver_close: |
76 | if (ret < 0) | ||
77 | return -1; | ||
78 | |||
79 | usbip_vhci_driver_close(); | 103 | usbip_vhci_driver_close(); |
80 | 104 | ||
81 | return ret; | 105 | return ret; |