diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-03 22:30:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-03 22:30:55 -0400 |
commit | 362f6729cbb1d6bbab59e069f19441b0622ff7ec (patch) | |
tree | 654070221092c34c97f48fbbdef7d5f02ffc7ba4 /tools | |
parent | 4422d80ed7d4bdb2d6e9fb890c66c3d9250ba694 (diff) | |
parent | 6836796de4019944f4ba4c99a360e8250fd2e735 (diff) |
Merge tag 'usb-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB/PHY updates from Greg KH:
"Here is the big patchset of USB and PHY driver updates for 4.13-rc1.
On the PHY side, they decided to move files around to "make things
easier" in their tree. Hopefully that wasn't a mistake, but in
linux-next testing, we haven't had any reported problems.
There's the usual set of gadget and xhci and musb updates in here as
well, along with a number of smaller updates for a raft of different
USB drivers. Full details in the shortlog, nothing really major.
All of these have been in linux-next for a while with no reported
issues"
* tag 'usb-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (173 commits)
Add USB quirk for HVR-950q to avoid intermittent device resets
USB hub_probe: rework ugly goto-into-compound-statement
usb: host: ohci-pxa27x: Handle return value of clk_prepare_enable
USB: serial: cp210x: add ID for CEL EM3588 USB ZigBee stick
usbip: Fix uninitialized variable bug in vhci
usb: core: read USB ports from DT in the usbport LED trigger driver
dt-bindings: leds: document new trigger-sources property
usb: typec: ucsi: Add ACPI driver
usb: typec: Add support for UCSI interface
usb: musb: compress return logic into one line
USB: serial: propagate late probe errors
USB: serial: refactor port endpoint setup
usb: musb: tusb6010_omap: Convert to DMAengine API
ARM: OMAP2+: DMA: Add slave map entries for 24xx external request lines
usb: musb: tusb6010: Handle DMA TX completion in DMA callback as well
usb: musb: tusb6010_omap: Allocate DMA channels upfront
usb: musb: tusb6010_omap: Create new struct for DMA data/parameters
usb: musb: tusb6010_omap: Use one musb_ep_select call in tusb_omap_dma_program
usb: musb: tusb6010: Add MUSB_G_NO_SKB_RESERVE to quirks
usb: musb: Add quirk to avoid skb reserve in gadget mode
...
Diffstat (limited to 'tools')
-rw-r--r-- | tools/usb/testusb.c | 16 | ||||
-rw-r--r-- | tools/usb/usbip/libsrc/vhci_driver.c | 133 | ||||
-rw-r--r-- | tools/usb/usbip/libsrc/vhci_driver.h | 10 | ||||
-rw-r--r-- | tools/usb/usbip/src/usbip_attach.c | 5 |
4 files changed, 118 insertions, 46 deletions
diff --git a/tools/usb/testusb.c b/tools/usb/testusb.c index 0692d99b6d8f..2d89b5f686b1 100644 --- a/tools/usb/testusb.c +++ b/tools/usb/testusb.c | |||
@@ -387,15 +387,17 @@ int main (int argc, char **argv) | |||
387 | /* pick defaults that works with all speeds, without short packets. | 387 | /* pick defaults that works with all speeds, without short packets. |
388 | * | 388 | * |
389 | * Best per-frame data rates: | 389 | * Best per-frame data rates: |
390 | * high speed, bulk 512 * 13 * 8 = 53248 | 390 | * super speed,bulk 1024 * 16 * 8 = 131072 |
391 | * interrupt 1024 * 3 * 8 = 24576 | 391 | * interrupt 1024 * 3 * 8 = 24576 |
392 | * full speed, bulk/intr 64 * 19 = 1216 | 392 | * high speed, bulk 512 * 13 * 8 = 53248 |
393 | * interrupt 64 * 1 = 64 | 393 | * interrupt 1024 * 3 * 8 = 24576 |
394 | * low speed, interrupt 8 * 1 = 8 | 394 | * full speed, bulk/intr 64 * 19 = 1216 |
395 | * interrupt 64 * 1 = 64 | ||
396 | * low speed, interrupt 8 * 1 = 8 | ||
395 | */ | 397 | */ |
396 | param.iterations = 1000; | 398 | param.iterations = 1000; |
397 | param.length = 1024; | 399 | param.length = 1024; |
398 | param.vary = 512; | 400 | param.vary = 1024; |
399 | param.sglen = 32; | 401 | param.sglen = 32; |
400 | 402 | ||
401 | /* for easy use when hotplugging */ | 403 | /* for easy use when hotplugging */ |
@@ -457,7 +459,7 @@ usage: | |||
457 | "\t-c iterations default 1000\n" | 459 | "\t-c iterations default 1000\n" |
458 | "\t-s transfer length default 1024\n" | 460 | "\t-s transfer length default 1024\n" |
459 | "\t-g sglen default 32\n" | 461 | "\t-g sglen default 32\n" |
460 | "\t-v vary default 512\n", | 462 | "\t-v vary default 1024\n", |
461 | argv[0]); | 463 | argv[0]); |
462 | return 1; | 464 | return 1; |
463 | } | 465 | } |
diff --git a/tools/usb/usbip/libsrc/vhci_driver.c b/tools/usb/usbip/libsrc/vhci_driver.c index f659c146cdc8..9bd2cd71645d 100644 --- a/tools/usb/usbip/libsrc/vhci_driver.c +++ b/tools/usb/usbip/libsrc/vhci_driver.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <limits.h> | 7 | #include <limits.h> |
8 | #include <netdb.h> | 8 | #include <netdb.h> |
9 | #include <libudev.h> | 9 | #include <libudev.h> |
10 | #include <dirent.h> | ||
10 | #include "sysfs_utils.h" | 11 | #include "sysfs_utils.h" |
11 | 12 | ||
12 | #undef PROGNAME | 13 | #undef PROGNAME |
@@ -35,18 +36,11 @@ err: | |||
35 | return NULL; | 36 | return NULL; |
36 | } | 37 | } |
37 | 38 | ||
38 | |||
39 | |||
40 | static int parse_status(const char *value) | 39 | static int parse_status(const char *value) |
41 | { | 40 | { |
42 | int ret = 0; | 41 | int ret = 0; |
43 | char *c; | 42 | char *c; |
44 | 43 | ||
45 | |||
46 | for (int i = 0; i < vhci_driver->nports; i++) | ||
47 | memset(&vhci_driver->idev[i], 0, sizeof(vhci_driver->idev[i])); | ||
48 | |||
49 | |||
50 | /* skip a header line */ | 44 | /* skip a header line */ |
51 | c = strchr(value, '\n'); | 45 | c = strchr(value, '\n'); |
52 | if (!c) | 46 | if (!c) |
@@ -57,9 +51,11 @@ static int parse_status(const char *value) | |||
57 | int port, status, speed, devid; | 51 | int port, status, speed, devid; |
58 | unsigned long socket; | 52 | unsigned long socket; |
59 | char lbusid[SYSFS_BUS_ID_SIZE]; | 53 | char lbusid[SYSFS_BUS_ID_SIZE]; |
54 | struct usbip_imported_device *idev; | ||
55 | char hub[3]; | ||
60 | 56 | ||
61 | ret = sscanf(c, "%d %d %d %x %lx %31s\n", | 57 | ret = sscanf(c, "%2s %d %d %d %x %lx %31s\n", |
62 | &port, &status, &speed, | 58 | hub, &port, &status, &speed, |
63 | &devid, &socket, lbusid); | 59 | &devid, &socket, lbusid); |
64 | 60 | ||
65 | if (ret < 5) { | 61 | if (ret < 5) { |
@@ -67,34 +63,36 @@ static int parse_status(const char *value) | |||
67 | BUG(); | 63 | BUG(); |
68 | } | 64 | } |
69 | 65 | ||
70 | dbg("port %d status %d speed %d devid %x", | 66 | dbg("hub %s port %d status %d speed %d devid %x", |
71 | port, status, speed, devid); | 67 | hub, port, status, speed, devid); |
72 | dbg("socket %lx lbusid %s", socket, lbusid); | 68 | dbg("socket %lx lbusid %s", socket, lbusid); |
73 | 69 | ||
74 | |||
75 | /* if a device is connected, look at it */ | 70 | /* if a device is connected, look at it */ |
76 | { | 71 | idev = &vhci_driver->idev[port]; |
77 | struct usbip_imported_device *idev = &vhci_driver->idev[port]; | 72 | memset(idev, 0, sizeof(*idev)); |
73 | |||
74 | if (strncmp("hs", hub, 2) == 0) | ||
75 | idev->hub = HUB_SPEED_HIGH; | ||
76 | else /* strncmp("ss", hub, 2) == 0 */ | ||
77 | idev->hub = HUB_SPEED_SUPER; | ||
78 | 78 | ||
79 | idev->port = port; | 79 | idev->port = port; |
80 | idev->status = status; | 80 | idev->status = status; |
81 | 81 | ||
82 | idev->devid = devid; | 82 | idev->devid = devid; |
83 | 83 | ||
84 | idev->busnum = (devid >> 16); | 84 | idev->busnum = (devid >> 16); |
85 | idev->devnum = (devid & 0x0000ffff); | 85 | idev->devnum = (devid & 0x0000ffff); |
86 | 86 | ||
87 | if (idev->status != VDEV_ST_NULL | 87 | if (idev->status != VDEV_ST_NULL |
88 | && idev->status != VDEV_ST_NOTASSIGNED) { | 88 | && idev->status != VDEV_ST_NOTASSIGNED) { |
89 | idev = imported_device_init(idev, lbusid); | 89 | idev = imported_device_init(idev, lbusid); |
90 | if (!idev) { | 90 | if (!idev) { |
91 | dbg("imported_device_init failed"); | 91 | dbg("imported_device_init failed"); |
92 | return -1; | 92 | return -1; |
93 | } | ||
94 | } | 93 | } |
95 | } | 94 | } |
96 | 95 | ||
97 | |||
98 | /* go to the next line */ | 96 | /* go to the next line */ |
99 | c = strchr(c, '\n'); | 97 | c = strchr(c, '\n'); |
100 | if (!c) | 98 | if (!c) |
@@ -107,18 +105,33 @@ static int parse_status(const char *value) | |||
107 | return 0; | 105 | return 0; |
108 | } | 106 | } |
109 | 107 | ||
108 | #define MAX_STATUS_NAME 16 | ||
109 | |||
110 | static int refresh_imported_device_list(void) | 110 | static int refresh_imported_device_list(void) |
111 | { | 111 | { |
112 | const char *attr_status; | 112 | const char *attr_status; |
113 | char status[MAX_STATUS_NAME+1] = "status"; | ||
114 | int i, ret; | ||
113 | 115 | ||
114 | attr_status = udev_device_get_sysattr_value(vhci_driver->hc_device, | 116 | for (i = 0; i < vhci_driver->ncontrollers; i++) { |
115 | "status"); | 117 | if (i > 0) |
116 | if (!attr_status) { | 118 | snprintf(status, sizeof(status), "status.%d", i); |
117 | err("udev_device_get_sysattr_value failed"); | 119 | |
118 | return -1; | 120 | attr_status = udev_device_get_sysattr_value(vhci_driver->hc_device, |
121 | status); | ||
122 | if (!attr_status) { | ||
123 | err("udev_device_get_sysattr_value failed"); | ||
124 | return -1; | ||
125 | } | ||
126 | |||
127 | dbg("controller %d", i); | ||
128 | |||
129 | ret = parse_status(attr_status); | ||
130 | if (ret != 0) | ||
131 | return ret; | ||
119 | } | 132 | } |
120 | 133 | ||
121 | return parse_status(attr_status); | 134 | return 0; |
122 | } | 135 | } |
123 | 136 | ||
124 | static int get_nports(void) | 137 | static int get_nports(void) |
@@ -134,6 +147,33 @@ static int get_nports(void) | |||
134 | return (int)strtoul(attr_nports, NULL, 10); | 147 | return (int)strtoul(attr_nports, NULL, 10); |
135 | } | 148 | } |
136 | 149 | ||
150 | static int vhci_hcd_filter(const struct dirent *dirent) | ||
151 | { | ||
152 | return strcmp(dirent->d_name, "vhci_hcd") >= 0; | ||
153 | } | ||
154 | |||
155 | static int get_ncontrollers(void) | ||
156 | { | ||
157 | struct dirent **namelist; | ||
158 | struct udev_device *platform; | ||
159 | int n; | ||
160 | |||
161 | platform = udev_device_get_parent(vhci_driver->hc_device); | ||
162 | if (platform == NULL) | ||
163 | return -1; | ||
164 | |||
165 | n = scandir(udev_device_get_syspath(platform), &namelist, vhci_hcd_filter, NULL); | ||
166 | if (n < 0) | ||
167 | err("scandir failed"); | ||
168 | else { | ||
169 | for (int i = 0; i < n; i++) | ||
170 | free(namelist[i]); | ||
171 | free(namelist); | ||
172 | } | ||
173 | |||
174 | return n; | ||
175 | } | ||
176 | |||
137 | /* | 177 | /* |
138 | * Read the given port's record. | 178 | * Read the given port's record. |
139 | * | 179 | * |
@@ -213,16 +253,31 @@ int usbip_vhci_driver_open(void) | |||
213 | vhci_driver->hc_device = | 253 | vhci_driver->hc_device = |
214 | udev_device_new_from_subsystem_sysname(udev_context, | 254 | udev_device_new_from_subsystem_sysname(udev_context, |
215 | USBIP_VHCI_BUS_TYPE, | 255 | USBIP_VHCI_BUS_TYPE, |
216 | USBIP_VHCI_DRV_NAME); | 256 | USBIP_VHCI_DEVICE_NAME); |
217 | if (!vhci_driver->hc_device) { | 257 | if (!vhci_driver->hc_device) { |
218 | err("udev_device_new_from_subsystem_sysname failed"); | 258 | err("udev_device_new_from_subsystem_sysname failed"); |
219 | goto err; | 259 | goto err; |
220 | } | 260 | } |
221 | 261 | ||
222 | vhci_driver->nports = get_nports(); | 262 | vhci_driver->nports = get_nports(); |
223 | |||
224 | dbg("available ports: %d", vhci_driver->nports); | 263 | dbg("available ports: %d", vhci_driver->nports); |
225 | 264 | ||
265 | if (vhci_driver->nports <= 0) { | ||
266 | err("no available ports"); | ||
267 | goto err; | ||
268 | } else if (vhci_driver->nports > MAXNPORT) { | ||
269 | err("port number exceeds %d", MAXNPORT); | ||
270 | goto err; | ||
271 | } | ||
272 | |||
273 | vhci_driver->ncontrollers = get_ncontrollers(); | ||
274 | dbg("available controllers: %d", vhci_driver->ncontrollers); | ||
275 | |||
276 | if (vhci_driver->ncontrollers <=0) { | ||
277 | err("no available usb controllers"); | ||
278 | goto err; | ||
279 | } | ||
280 | |||
226 | if (refresh_imported_device_list()) | 281 | if (refresh_imported_device_list()) |
227 | goto err; | 282 | goto err; |
228 | 283 | ||
@@ -270,11 +325,15 @@ err: | |||
270 | } | 325 | } |
271 | 326 | ||
272 | 327 | ||
273 | int usbip_vhci_get_free_port(void) | 328 | int usbip_vhci_get_free_port(uint32_t speed) |
274 | { | 329 | { |
275 | for (int i = 0; i < vhci_driver->nports; i++) { | 330 | for (int i = 0; i < vhci_driver->nports; i++) { |
331 | if (speed == USB_SPEED_SUPER && | ||
332 | vhci_driver->idev[i].hub != HUB_SPEED_SUPER) | ||
333 | continue; | ||
334 | |||
276 | if (vhci_driver->idev[i].status == VDEV_ST_NULL) | 335 | if (vhci_driver->idev[i].status == VDEV_ST_NULL) |
277 | return i; | 336 | return vhci_driver->idev[i].port; |
278 | } | 337 | } |
279 | 338 | ||
280 | return -1; | 339 | return -1; |
diff --git a/tools/usb/usbip/libsrc/vhci_driver.h b/tools/usb/usbip/libsrc/vhci_driver.h index fa2316cf2cac..4898d3bafb10 100644 --- a/tools/usb/usbip/libsrc/vhci_driver.h +++ b/tools/usb/usbip/libsrc/vhci_driver.h | |||
@@ -11,9 +11,16 @@ | |||
11 | #include "usbip_common.h" | 11 | #include "usbip_common.h" |
12 | 12 | ||
13 | #define USBIP_VHCI_BUS_TYPE "platform" | 13 | #define USBIP_VHCI_BUS_TYPE "platform" |
14 | #define USBIP_VHCI_DEVICE_NAME "vhci_hcd.0" | ||
14 | #define MAXNPORT 128 | 15 | #define MAXNPORT 128 |
15 | 16 | ||
17 | enum hub_speed { | ||
18 | HUB_SPEED_HIGH = 0, | ||
19 | HUB_SPEED_SUPER, | ||
20 | }; | ||
21 | |||
16 | struct usbip_imported_device { | 22 | struct usbip_imported_device { |
23 | enum hub_speed hub; | ||
17 | uint8_t port; | 24 | uint8_t port; |
18 | uint32_t status; | 25 | uint32_t status; |
19 | 26 | ||
@@ -31,6 +38,7 @@ struct usbip_vhci_driver { | |||
31 | /* /sys/devices/platform/vhci_hcd */ | 38 | /* /sys/devices/platform/vhci_hcd */ |
32 | struct udev_device *hc_device; | 39 | struct udev_device *hc_device; |
33 | 40 | ||
41 | int ncontrollers; | ||
34 | int nports; | 42 | int nports; |
35 | struct usbip_imported_device idev[MAXNPORT]; | 43 | struct usbip_imported_device idev[MAXNPORT]; |
36 | }; | 44 | }; |
@@ -44,7 +52,7 @@ void usbip_vhci_driver_close(void); | |||
44 | int usbip_vhci_refresh_device_list(void); | 52 | int usbip_vhci_refresh_device_list(void); |
45 | 53 | ||
46 | 54 | ||
47 | int usbip_vhci_get_free_port(void); | 55 | int usbip_vhci_get_free_port(uint32_t speed); |
48 | int usbip_vhci_attach_device2(uint8_t port, int sockfd, uint32_t devid, | 56 | int usbip_vhci_attach_device2(uint8_t port, int sockfd, uint32_t devid, |
49 | uint32_t speed); | 57 | uint32_t speed); |
50 | 58 | ||
diff --git a/tools/usb/usbip/src/usbip_attach.c b/tools/usb/usbip/src/usbip_attach.c index 70a6b507fb62..6e89768ffe30 100644 --- a/tools/usb/usbip/src/usbip_attach.c +++ b/tools/usb/usbip/src/usbip_attach.c | |||
@@ -94,6 +94,7 @@ static int import_device(int sockfd, struct usbip_usb_device *udev) | |||
94 | { | 94 | { |
95 | int rc; | 95 | int rc; |
96 | int port; | 96 | int port; |
97 | uint32_t speed = udev->speed; | ||
97 | 98 | ||
98 | rc = usbip_vhci_driver_open(); | 99 | rc = usbip_vhci_driver_open(); |
99 | if (rc < 0) { | 100 | if (rc < 0) { |
@@ -101,13 +102,15 @@ static int import_device(int sockfd, struct usbip_usb_device *udev) | |||
101 | return -1; | 102 | return -1; |
102 | } | 103 | } |
103 | 104 | ||
104 | port = usbip_vhci_get_free_port(); | 105 | port = usbip_vhci_get_free_port(speed); |
105 | if (port < 0) { | 106 | if (port < 0) { |
106 | err("no free port"); | 107 | err("no free port"); |
107 | usbip_vhci_driver_close(); | 108 | usbip_vhci_driver_close(); |
108 | return -1; | 109 | return -1; |
109 | } | 110 | } |
110 | 111 | ||
112 | dbg("got free port %d", port); | ||
113 | |||
111 | rc = usbip_vhci_attach_device(port, sockfd, udev->busnum, | 114 | rc = usbip_vhci_attach_device(port, sockfd, udev->busnum, |
112 | udev->devnum, udev->speed); | 115 | udev->devnum, udev->speed); |
113 | if (rc < 0) { | 116 | if (rc < 0) { |