aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-12-08 21:46:32 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-12-08 21:46:32 -0500
commitb19d69c72d4e3da67f0feb2ecf45d6e60c82baf1 (patch)
tree48f59f5e39acd24bbba98ada4c6e115211cf911d /drivers
parent7d49efe2edbde8e2b585f3168fa89184893645c8 (diff)
parent2d51f3cd11f414c56a87dc018196b85fd50b04a4 (diff)
Merge tag 'usb-3.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are a bunch of USB fixes for 3.13-rc3. Nothing major, but we seem to have an argument about a XHCI fix, so I'm not including a revert that Sarah requested, because that breaks a USB network driver, and I can't revert the USB network driver fix without reintroducing other bugs that it fixed. So as it is, everything should now be working. Worse case, I can revert the XHCI fix before 3.13-final is out, but it seems to work well here with my testing, so all should be good. Other than that, some driver updates based on reports" * tag 'usb-3.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (40 commits) usb: hub: Use correct reset for wedged USB3 devices that are NOTATTACHED usb: ohci-pxa27x: include linux/dma-mapping.h USB: cdc-acm: Added support for the Lenovo RD02-D400 USB Modem usb: tools: fix a regression issue that gcc can't link to pthread USB: switch maintainership of chipidea to Peter USB: pl2303: fixed handling of CS5 setting USB: ftdi_sio: fixed handling of unsupported CSIZE setting USB: mos7840: correct handling of CS5 setting USB: spcp8x5: correct handling of CS5 setting usb: wusbcore: fix deadlock in wusbhc_gtk_rekey usb: wusbcore: do device lookup while holding the hc mutex usb: wusbcore: send keepalives to unauthenticated devices USB: option: support new huawei devices USB: serial: option: blacklist interface 1 for Huawei E173s-6 usb: xhci: Link TRB must not occur within a USB payload burst usb: gadget: f_mass_storage: call try_to_freeze only when its safe usb: gadget: tcm_usb_gadget: mark bot_cleanup_old_alt static usb: gadget: ffs: fix sparse warning usb: gadget: zero: module parameters can be static usb: gadget: storage: fix sparse warning ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/class/cdc-acm.c2
-rw-r--r--drivers/usb/core/hub.c5
-rw-r--r--drivers/usb/dwc3/ep0.c2
-rw-r--r--drivers/usb/dwc3/gadget.c5
-rw-r--r--drivers/usb/gadget/Kconfig1
-rw-r--r--drivers/usb/gadget/composite.c1
-rw-r--r--drivers/usb/gadget/f_fs.c2
-rw-r--r--drivers/usb/gadget/f_mass_storage.c27
-rw-r--r--drivers/usb/gadget/pxa25x_udc.c1
-rw-r--r--drivers/usb/gadget/s3c-hsotg.c7
-rw-r--r--drivers/usb/gadget/storage_common.h4
-rw-r--r--drivers/usb/gadget/tcm_usb_gadget.c2
-rw-r--r--drivers/usb/gadget/zero.c6
-rw-r--r--drivers/usb/host/ohci-pxa27x.c1
-rw-r--r--drivers/usb/host/xhci-ring.c54
-rw-r--r--drivers/usb/musb/musb_core.c9
-rw-r--r--drivers/usb/musb/musb_cppi41.c164
-rw-r--r--drivers/usb/musb/musb_gadget.c4
-rw-r--r--drivers/usb/phy/phy-am335x.c5
-rw-r--r--drivers/usb/phy/phy-generic.c68
-rw-r--r--drivers/usb/phy/phy-generic.h4
-rw-r--r--drivers/usb/phy/phy-mxs-usb.c2
-rw-r--r--drivers/usb/phy/phy-rcar-gen2-usb.c4
-rw-r--r--drivers/usb/serial/ftdi_sio.c37
-rw-r--r--drivers/usb/serial/generic.c12
-rw-r--r--drivers/usb/serial/mos7840.c32
-rw-r--r--drivers/usb/serial/option.c27
-rw-r--r--drivers/usb/serial/pl2303.c30
-rw-r--r--drivers/usb/serial/spcp8x5.c30
-rw-r--r--drivers/usb/wusbcore/devconnect.c72
-rw-r--r--drivers/usb/wusbcore/security.c98
-rw-r--r--drivers/usb/wusbcore/wusbhc.h6
32 files changed, 462 insertions, 262 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 3e7560f004f8..e8404319ca68 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1515,6 +1515,8 @@ static int acm_reset_resume(struct usb_interface *intf)
1515 1515
1516static const struct usb_device_id acm_ids[] = { 1516static const struct usb_device_id acm_ids[] = {
1517 /* quirky and broken devices */ 1517 /* quirky and broken devices */
1518 { USB_DEVICE(0x17ef, 0x7000), /* Lenovo USB modem */
1519 .driver_info = NO_UNION_NORMAL, },/* has no union descriptor */
1518 { USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */ 1520 { USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */
1519 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1521 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1520 }, 1522 },
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a7c04e24ca48..bd9dc3504b51 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4832,8 +4832,9 @@ static void hub_events(void)
4832 hub->ports[i - 1]->child; 4832 hub->ports[i - 1]->child;
4833 4833
4834 dev_dbg(hub_dev, "warm reset port %d\n", i); 4834 dev_dbg(hub_dev, "warm reset port %d\n", i);
4835 if (!udev || !(portstatus & 4835 if (!udev ||
4836 USB_PORT_STAT_CONNECTION)) { 4836 !(portstatus & USB_PORT_STAT_CONNECTION) ||
4837 udev->state == USB_STATE_NOTATTACHED) {
4837 status = hub_port_reset(hub, i, 4838 status = hub_port_reset(hub, i,
4838 NULL, HUB_BH_RESET_TIME, 4839 NULL, HUB_BH_RESET_TIME,
4839 true); 4840 true);
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 95f7649c71a7..21a352079bc2 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -459,6 +459,8 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
459 dep = dwc3_wIndex_to_dep(dwc, wIndex); 459 dep = dwc3_wIndex_to_dep(dwc, wIndex);
460 if (!dep) 460 if (!dep)
461 return -EINVAL; 461 return -EINVAL;
462 if (set == 0 && (dep->flags & DWC3_EP_WEDGE))
463 break;
462 ret = __dwc3_gadget_ep_set_halt(dep, set); 464 ret = __dwc3_gadget_ep_set_halt(dep, set);
463 if (ret) 465 if (ret)
464 return -EINVAL; 466 return -EINVAL;
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 5452c0fce360..02e44fcaf205 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1200,9 +1200,6 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value)
1200 else 1200 else
1201 dep->flags |= DWC3_EP_STALL; 1201 dep->flags |= DWC3_EP_STALL;
1202 } else { 1202 } else {
1203 if (dep->flags & DWC3_EP_WEDGE)
1204 return 0;
1205
1206 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, 1203 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number,
1207 DWC3_DEPCMD_CLEARSTALL, &params); 1204 DWC3_DEPCMD_CLEARSTALL, &params);
1208 if (ret) 1205 if (ret)
@@ -1210,7 +1207,7 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value)
1210 value ? "set" : "clear", 1207 value ? "set" : "clear",
1211 dep->name); 1208 dep->name);
1212 else 1209 else
1213 dep->flags &= ~DWC3_EP_STALL; 1210 dep->flags &= ~(DWC3_EP_STALL | DWC3_EP_WEDGE);
1214 } 1211 }
1215 1212
1216 return ret; 1213 return ret;
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index a91e6422f930..f66d96ad1f51 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -682,6 +682,7 @@ config USB_CONFIGFS_PHONET
682config USB_CONFIGFS_MASS_STORAGE 682config USB_CONFIGFS_MASS_STORAGE
683 boolean "Mass storage" 683 boolean "Mass storage"
684 depends on USB_CONFIGFS 684 depends on USB_CONFIGFS
685 depends on BLOCK
685 select USB_F_MASS_STORAGE 686 select USB_F_MASS_STORAGE
686 help 687 help
687 The Mass Storage Gadget acts as a USB Mass Storage disk drive. 688 The Mass Storage Gadget acts as a USB Mass Storage disk drive.
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 3e7ae707f691..2018ba1a2172 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -593,6 +593,7 @@ static void reset_config(struct usb_composite_dev *cdev)
593 bitmap_zero(f->endpoints, 32); 593 bitmap_zero(f->endpoints, 32);
594 } 594 }
595 cdev->config = NULL; 595 cdev->config = NULL;
596 cdev->delayed_status = 0;
596} 597}
597 598
598static int set_config(struct usb_composite_dev *cdev, 599static int set_config(struct usb_composite_dev *cdev,
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 774e8b89cdb5..241fc873ffa4 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -1304,7 +1304,7 @@ static struct ffs_data *ffs_data_new(void)
1304{ 1304{
1305 struct ffs_data *ffs = kzalloc(sizeof *ffs, GFP_KERNEL); 1305 struct ffs_data *ffs = kzalloc(sizeof *ffs, GFP_KERNEL);
1306 if (unlikely(!ffs)) 1306 if (unlikely(!ffs))
1307 return 0; 1307 return NULL;
1308 1308
1309 ENTER(); 1309 ENTER();
1310 1310
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index a03ba2c83589..b96393908860 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -523,7 +523,7 @@ static int fsg_setup(struct usb_function *f,
523 */ 523 */
524 DBG(fsg, "bulk reset request\n"); 524 DBG(fsg, "bulk reset request\n");
525 raise_exception(fsg->common, FSG_STATE_RESET); 525 raise_exception(fsg->common, FSG_STATE_RESET);
526 return DELAYED_STATUS; 526 return USB_GADGET_DELAYED_STATUS;
527 527
528 case US_BULK_GET_MAX_LUN: 528 case US_BULK_GET_MAX_LUN:
529 if (ctrl->bRequestType != 529 if (ctrl->bRequestType !=
@@ -602,13 +602,14 @@ static bool start_out_transfer(struct fsg_common *common, struct fsg_buffhd *bh)
602 return true; 602 return true;
603} 603}
604 604
605static int sleep_thread(struct fsg_common *common) 605static int sleep_thread(struct fsg_common *common, bool can_freeze)
606{ 606{
607 int rc = 0; 607 int rc = 0;
608 608
609 /* Wait until a signal arrives or we are woken up */ 609 /* Wait until a signal arrives or we are woken up */
610 for (;;) { 610 for (;;) {
611 try_to_freeze(); 611 if (can_freeze)
612 try_to_freeze();
612 set_current_state(TASK_INTERRUPTIBLE); 613 set_current_state(TASK_INTERRUPTIBLE);
613 if (signal_pending(current)) { 614 if (signal_pending(current)) {
614 rc = -EINTR; 615 rc = -EINTR;
@@ -682,7 +683,7 @@ static int do_read(struct fsg_common *common)
682 /* Wait for the next buffer to become available */ 683 /* Wait for the next buffer to become available */
683 bh = common->next_buffhd_to_fill; 684 bh = common->next_buffhd_to_fill;
684 while (bh->state != BUF_STATE_EMPTY) { 685 while (bh->state != BUF_STATE_EMPTY) {
685 rc = sleep_thread(common); 686 rc = sleep_thread(common, false);
686 if (rc) 687 if (rc)
687 return rc; 688 return rc;
688 } 689 }
@@ -937,7 +938,7 @@ static int do_write(struct fsg_common *common)
937 } 938 }
938 939
939 /* Wait for something to happen */ 940 /* Wait for something to happen */
940 rc = sleep_thread(common); 941 rc = sleep_thread(common, false);
941 if (rc) 942 if (rc)
942 return rc; 943 return rc;
943 } 944 }
@@ -1504,7 +1505,7 @@ static int throw_away_data(struct fsg_common *common)
1504 } 1505 }
1505 1506
1506 /* Otherwise wait for something to happen */ 1507 /* Otherwise wait for something to happen */
1507 rc = sleep_thread(common); 1508 rc = sleep_thread(common, true);
1508 if (rc) 1509 if (rc)
1509 return rc; 1510 return rc;
1510 } 1511 }
@@ -1625,7 +1626,7 @@ static int send_status(struct fsg_common *common)
1625 /* Wait for the next buffer to become available */ 1626 /* Wait for the next buffer to become available */
1626 bh = common->next_buffhd_to_fill; 1627 bh = common->next_buffhd_to_fill;
1627 while (bh->state != BUF_STATE_EMPTY) { 1628 while (bh->state != BUF_STATE_EMPTY) {
1628 rc = sleep_thread(common); 1629 rc = sleep_thread(common, true);
1629 if (rc) 1630 if (rc)
1630 return rc; 1631 return rc;
1631 } 1632 }
@@ -1828,7 +1829,7 @@ static int do_scsi_command(struct fsg_common *common)
1828 bh = common->next_buffhd_to_fill; 1829 bh = common->next_buffhd_to_fill;
1829 common->next_buffhd_to_drain = bh; 1830 common->next_buffhd_to_drain = bh;
1830 while (bh->state != BUF_STATE_EMPTY) { 1831 while (bh->state != BUF_STATE_EMPTY) {
1831 rc = sleep_thread(common); 1832 rc = sleep_thread(common, true);
1832 if (rc) 1833 if (rc)
1833 return rc; 1834 return rc;
1834 } 1835 }
@@ -2174,7 +2175,7 @@ static int get_next_command(struct fsg_common *common)
2174 /* Wait for the next buffer to become available */ 2175 /* Wait for the next buffer to become available */
2175 bh = common->next_buffhd_to_fill; 2176 bh = common->next_buffhd_to_fill;
2176 while (bh->state != BUF_STATE_EMPTY) { 2177 while (bh->state != BUF_STATE_EMPTY) {
2177 rc = sleep_thread(common); 2178 rc = sleep_thread(common, true);
2178 if (rc) 2179 if (rc)
2179 return rc; 2180 return rc;
2180 } 2181 }
@@ -2193,7 +2194,7 @@ static int get_next_command(struct fsg_common *common)
2193 2194
2194 /* Wait for the CBW to arrive */ 2195 /* Wait for the CBW to arrive */
2195 while (bh->state != BUF_STATE_FULL) { 2196 while (bh->state != BUF_STATE_FULL) {
2196 rc = sleep_thread(common); 2197 rc = sleep_thread(common, true);
2197 if (rc) 2198 if (rc)
2198 return rc; 2199 return rc;
2199 } 2200 }
@@ -2379,7 +2380,7 @@ static void handle_exception(struct fsg_common *common)
2379 } 2380 }
2380 if (num_active == 0) 2381 if (num_active == 0)
2381 break; 2382 break;
2382 if (sleep_thread(common)) 2383 if (sleep_thread(common, true))
2383 return; 2384 return;
2384 } 2385 }
2385 2386
@@ -2516,7 +2517,7 @@ static int fsg_main_thread(void *common_)
2516 } 2517 }
2517 2518
2518 if (!common->running) { 2519 if (!common->running) {
2519 sleep_thread(common); 2520 sleep_thread(common, true);
2520 continue; 2521 continue;
2521 } 2522 }
2522 2523
@@ -3111,7 +3112,7 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
3111 fsg->common->can_stall); 3112 fsg->common->can_stall);
3112 if (ret) 3113 if (ret)
3113 return ret; 3114 return ret;
3114 fsg_common_set_inquiry_string(fsg->common, 0, 0); 3115 fsg_common_set_inquiry_string(fsg->common, NULL, NULL);
3115 ret = fsg_common_run_thread(fsg->common); 3116 ret = fsg_common_run_thread(fsg->common);
3116 if (ret) 3117 if (ret)
3117 return ret; 3118 return ret;
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c
index 0ac6064aa3b8..409a3c45a36a 100644
--- a/drivers/usb/gadget/pxa25x_udc.c
+++ b/drivers/usb/gadget/pxa25x_udc.c
@@ -54,6 +54,7 @@
54 */ 54 */
55#ifdef CONFIG_ARCH_PXA 55#ifdef CONFIG_ARCH_PXA
56#include <mach/pxa25x-udc.h> 56#include <mach/pxa25x-udc.h>
57#include <mach/hardware.h>
57#endif 58#endif
58 59
59#ifdef CONFIG_ARCH_LUBBOCK 60#ifdef CONFIG_ARCH_LUBBOCK
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 9875d9c0823f..e20bc109fdd7 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -1180,6 +1180,7 @@ static int s3c_hsotg_process_req_feature(struct s3c_hsotg *hsotg,
1180} 1180}
1181 1181
1182static void s3c_hsotg_enqueue_setup(struct s3c_hsotg *hsotg); 1182static void s3c_hsotg_enqueue_setup(struct s3c_hsotg *hsotg);
1183static void s3c_hsotg_disconnect(struct s3c_hsotg *hsotg);
1183 1184
1184/** 1185/**
1185 * s3c_hsotg_process_control - process a control request 1186 * s3c_hsotg_process_control - process a control request
@@ -1221,6 +1222,7 @@ static void s3c_hsotg_process_control(struct s3c_hsotg *hsotg,
1221 if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) { 1222 if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) {
1222 switch (ctrl->bRequest) { 1223 switch (ctrl->bRequest) {
1223 case USB_REQ_SET_ADDRESS: 1224 case USB_REQ_SET_ADDRESS:
1225 s3c_hsotg_disconnect(hsotg);
1224 dcfg = readl(hsotg->regs + DCFG); 1226 dcfg = readl(hsotg->regs + DCFG);
1225 dcfg &= ~DCFG_DevAddr_MASK; 1227 dcfg &= ~DCFG_DevAddr_MASK;
1226 dcfg |= ctrl->wValue << DCFG_DevAddr_SHIFT; 1228 dcfg |= ctrl->wValue << DCFG_DevAddr_SHIFT;
@@ -1245,7 +1247,9 @@ static void s3c_hsotg_process_control(struct s3c_hsotg *hsotg,
1245 /* as a fallback, try delivering it to the driver to deal with */ 1247 /* as a fallback, try delivering it to the driver to deal with */
1246 1248
1247 if (ret == 0 && hsotg->driver) { 1249 if (ret == 0 && hsotg->driver) {
1250 spin_unlock(&hsotg->lock);
1248 ret = hsotg->driver->setup(&hsotg->gadget, ctrl); 1251 ret = hsotg->driver->setup(&hsotg->gadget, ctrl);
1252 spin_lock(&hsotg->lock);
1249 if (ret < 0) 1253 if (ret < 0)
1250 dev_dbg(hsotg->dev, "driver->setup() ret %d\n", ret); 1254 dev_dbg(hsotg->dev, "driver->setup() ret %d\n", ret);
1251 } 1255 }
@@ -1308,10 +1312,12 @@ static void s3c_hsotg_complete_setup(struct usb_ep *ep,
1308 return; 1312 return;
1309 } 1313 }
1310 1314
1315 spin_lock(&hsotg->lock);
1311 if (req->actual == 0) 1316 if (req->actual == 0)
1312 s3c_hsotg_enqueue_setup(hsotg); 1317 s3c_hsotg_enqueue_setup(hsotg);
1313 else 1318 else
1314 s3c_hsotg_process_control(hsotg, req->buf); 1319 s3c_hsotg_process_control(hsotg, req->buf);
1320 spin_unlock(&hsotg->lock);
1315} 1321}
1316 1322
1317/** 1323/**
@@ -2533,7 +2539,6 @@ irq_retry:
2533 writel(GINTSTS_USBSusp, hsotg->regs + GINTSTS); 2539 writel(GINTSTS_USBSusp, hsotg->regs + GINTSTS);
2534 2540
2535 call_gadget(hsotg, suspend); 2541 call_gadget(hsotg, suspend);
2536 s3c_hsotg_disconnect(hsotg);
2537 } 2542 }
2538 2543
2539 if (gintsts & GINTSTS_WkUpInt) { 2544 if (gintsts & GINTSTS_WkUpInt) {
diff --git a/drivers/usb/gadget/storage_common.h b/drivers/usb/gadget/storage_common.h
index c74c2fdbd56e..70c891469f57 100644
--- a/drivers/usb/gadget/storage_common.h
+++ b/drivers/usb/gadget/storage_common.h
@@ -119,10 +119,6 @@ static inline bool fsg_lun_is_open(struct fsg_lun *curlun)
119 return curlun->filp != NULL; 119 return curlun->filp != NULL;
120} 120}
121 121
122/* Big enough to hold our biggest descriptor */
123#define EP0_BUFSIZE 256
124#define DELAYED_STATUS (EP0_BUFSIZE + 999) /* An impossibly large value */
125
126/* Default size of buffer length. */ 122/* Default size of buffer length. */
127#define FSG_BUFLEN ((u32)16384) 123#define FSG_BUFLEN ((u32)16384)
128 124
diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c
index 6c3d7950d2a9..0f8aad78b54f 100644
--- a/drivers/usb/gadget/tcm_usb_gadget.c
+++ b/drivers/usb/gadget/tcm_usb_gadget.c
@@ -370,7 +370,7 @@ err:
370 return -ENOMEM; 370 return -ENOMEM;
371} 371}
372 372
373void bot_cleanup_old_alt(struct f_uas *fu) 373static void bot_cleanup_old_alt(struct f_uas *fu)
374{ 374{
375 if (!(fu->flags & USBG_ENABLED)) 375 if (!(fu->flags & USBG_ENABLED))
376 return; 376 return;
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index 0dd07ae1555d..f49b0b61ecc8 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -91,17 +91,17 @@ static struct usb_zero_options gzero_options = {
91 * functional coverage for the "USBCV" test harness from USB-IF. 91 * functional coverage for the "USBCV" test harness from USB-IF.
92 * It's always set if OTG mode is enabled. 92 * It's always set if OTG mode is enabled.
93 */ 93 */
94unsigned autoresume = DEFAULT_AUTORESUME; 94static unsigned autoresume = DEFAULT_AUTORESUME;
95module_param(autoresume, uint, S_IRUGO); 95module_param(autoresume, uint, S_IRUGO);
96MODULE_PARM_DESC(autoresume, "zero, or seconds before remote wakeup"); 96MODULE_PARM_DESC(autoresume, "zero, or seconds before remote wakeup");
97 97
98/* Maximum Autoresume time */ 98/* Maximum Autoresume time */
99unsigned max_autoresume; 99static unsigned max_autoresume;
100module_param(max_autoresume, uint, S_IRUGO); 100module_param(max_autoresume, uint, S_IRUGO);
101MODULE_PARM_DESC(max_autoresume, "maximum seconds before remote wakeup"); 101MODULE_PARM_DESC(max_autoresume, "maximum seconds before remote wakeup");
102 102
103/* Interval between two remote wakeups */ 103/* Interval between two remote wakeups */
104unsigned autoresume_interval_ms; 104static unsigned autoresume_interval_ms;
105module_param(autoresume_interval_ms, uint, S_IRUGO); 105module_param(autoresume_interval_ms, uint, S_IRUGO);
106MODULE_PARM_DESC(autoresume_interval_ms, 106MODULE_PARM_DESC(autoresume_interval_ms,
107 "milliseconds to increase successive wakeup delays"); 107 "milliseconds to increase successive wakeup delays");
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index e89ac4d4b87e..9b7435f0dcd6 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -21,6 +21,7 @@
21 21
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/device.h> 23#include <linux/device.h>
24#include <linux/dma-mapping.h>
24#include <linux/io.h> 25#include <linux/io.h>
25#include <linux/kernel.h> 26#include <linux/kernel.h>
26#include <linux/module.h> 27#include <linux/module.h>
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 1e2f3f495843..53c2e296467f 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2973,8 +2973,58 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring,
2973 } 2973 }
2974 2974
2975 while (1) { 2975 while (1) {
2976 if (room_on_ring(xhci, ep_ring, num_trbs)) 2976 if (room_on_ring(xhci, ep_ring, num_trbs)) {
2977 break; 2977 union xhci_trb *trb = ep_ring->enqueue;
2978 unsigned int usable = ep_ring->enq_seg->trbs +
2979 TRBS_PER_SEGMENT - 1 - trb;
2980 u32 nop_cmd;
2981
2982 /*
2983 * Section 4.11.7.1 TD Fragments states that a link
2984 * TRB must only occur at the boundary between
2985 * data bursts (eg 512 bytes for 480M).
2986 * While it is possible to split a large fragment
2987 * we don't know the size yet.
2988 * Simplest solution is to fill the trb before the
2989 * LINK with nop commands.
2990 */
2991 if (num_trbs == 1 || num_trbs <= usable || usable == 0)
2992 break;
2993
2994 if (ep_ring->type != TYPE_BULK)
2995 /*
2996 * While isoc transfers might have a buffer that
2997 * crosses a 64k boundary it is unlikely.
2998 * Since we can't add NOPs without generating
2999 * gaps in the traffic just hope it never
3000 * happens at the end of the ring.
3001 * This could be fixed by writing a LINK TRB
3002 * instead of the first NOP - however the
3003 * TRB_TYPE_LINK_LE32() calls would all need
3004 * changing to check the ring length.
3005 */
3006 break;
3007
3008 if (num_trbs >= TRBS_PER_SEGMENT) {
3009 xhci_err(xhci, "Too many fragments %d, max %d\n",
3010 num_trbs, TRBS_PER_SEGMENT - 1);
3011 return -ENOMEM;
3012 }
3013
3014 nop_cmd = cpu_to_le32(TRB_TYPE(TRB_TR_NOOP) |
3015 ep_ring->cycle_state);
3016 ep_ring->num_trbs_free -= usable;
3017 do {
3018 trb->generic.field[0] = 0;
3019 trb->generic.field[1] = 0;
3020 trb->generic.field[2] = 0;
3021 trb->generic.field[3] = nop_cmd;
3022 trb++;
3023 } while (--usable);
3024 ep_ring->enqueue = trb;
3025 if (room_on_ring(xhci, ep_ring, num_trbs))
3026 break;
3027 }
2978 3028
2979 if (ep_ring == xhci->cmd_ring) { 3029 if (ep_ring == xhci->cmd_ring) {
2980 xhci_err(xhci, "Do not support expand command ring\n"); 3030 xhci_err(xhci, "Do not support expand command ring\n");
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 0a43329569d1..4d4499b80449 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1809,7 +1809,6 @@ static void musb_free(struct musb *musb)
1809 disable_irq_wake(musb->nIrq); 1809 disable_irq_wake(musb->nIrq);
1810 free_irq(musb->nIrq, musb); 1810 free_irq(musb->nIrq, musb);
1811 } 1811 }
1812 cancel_work_sync(&musb->irq_work);
1813 1812
1814 musb_host_free(musb); 1813 musb_host_free(musb);
1815} 1814}
@@ -1896,6 +1895,9 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
1896 musb_platform_disable(musb); 1895 musb_platform_disable(musb);
1897 musb_generic_disable(musb); 1896 musb_generic_disable(musb);
1898 1897
1898 /* Init IRQ workqueue before request_irq */
1899 INIT_WORK(&musb->irq_work, musb_irq_work);
1900
1899 /* setup musb parts of the core (especially endpoints) */ 1901 /* setup musb parts of the core (especially endpoints) */
1900 status = musb_core_init(plat->config->multipoint 1902 status = musb_core_init(plat->config->multipoint
1901 ? MUSB_CONTROLLER_MHDRC 1903 ? MUSB_CONTROLLER_MHDRC
@@ -1905,9 +1907,6 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
1905 1907
1906 setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) musb); 1908 setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) musb);
1907 1909
1908 /* Init IRQ workqueue before request_irq */
1909 INIT_WORK(&musb->irq_work, musb_irq_work);
1910
1911 /* attach to the IRQ */ 1910 /* attach to the IRQ */
1912 if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) { 1911 if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) {
1913 dev_err(dev, "request_irq %d failed!\n", nIrq); 1912 dev_err(dev, "request_irq %d failed!\n", nIrq);
@@ -1981,6 +1980,7 @@ fail4:
1981 musb_host_cleanup(musb); 1980 musb_host_cleanup(musb);
1982 1981
1983fail3: 1982fail3:
1983 cancel_work_sync(&musb->irq_work);
1984 if (musb->dma_controller) 1984 if (musb->dma_controller)
1985 dma_controller_destroy(musb->dma_controller); 1985 dma_controller_destroy(musb->dma_controller);
1986fail2_5: 1986fail2_5:
@@ -2043,6 +2043,7 @@ static int musb_remove(struct platform_device *pdev)
2043 if (musb->dma_controller) 2043 if (musb->dma_controller)
2044 dma_controller_destroy(musb->dma_controller); 2044 dma_controller_destroy(musb->dma_controller);
2045 2045
2046 cancel_work_sync(&musb->irq_work);
2046 musb_free(musb); 2047 musb_free(musb);
2047 device_init_wakeup(dev, 0); 2048 device_init_wakeup(dev, 0);
2048 return 0; 2049 return 0;
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index ff9d6de2b746..a12bd30401e0 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -38,6 +38,7 @@ struct cppi41_dma_channel {
38 u32 prog_len; 38 u32 prog_len;
39 u32 transferred; 39 u32 transferred;
40 u32 packet_sz; 40 u32 packet_sz;
41 struct list_head tx_check;
41}; 42};
42 43
43#define MUSB_DMA_NUM_CHANNELS 15 44#define MUSB_DMA_NUM_CHANNELS 15
@@ -47,6 +48,8 @@ struct cppi41_dma_controller {
47 struct cppi41_dma_channel rx_channel[MUSB_DMA_NUM_CHANNELS]; 48 struct cppi41_dma_channel rx_channel[MUSB_DMA_NUM_CHANNELS];
48 struct cppi41_dma_channel tx_channel[MUSB_DMA_NUM_CHANNELS]; 49 struct cppi41_dma_channel tx_channel[MUSB_DMA_NUM_CHANNELS];
49 struct musb *musb; 50 struct musb *musb;
51 struct hrtimer early_tx;
52 struct list_head early_tx_list;
50 u32 rx_mode; 53 u32 rx_mode;
51 u32 tx_mode; 54 u32 tx_mode;
52 u32 auto_req; 55 u32 auto_req;
@@ -96,31 +99,27 @@ static void update_rx_toggle(struct cppi41_dma_channel *cppi41_channel)
96 cppi41_channel->usb_toggle = toggle; 99 cppi41_channel->usb_toggle = toggle;
97} 100}
98 101
99static void cppi41_dma_callback(void *private_data) 102static bool musb_is_tx_fifo_empty(struct musb_hw_ep *hw_ep)
100{ 103{
101 struct dma_channel *channel = private_data; 104 u8 epnum = hw_ep->epnum;
102 struct cppi41_dma_channel *cppi41_channel = channel->private_data; 105 struct musb *musb = hw_ep->musb;
103 struct musb_hw_ep *hw_ep = cppi41_channel->hw_ep; 106 void __iomem *epio = musb->endpoints[epnum].regs;
104 struct musb *musb = hw_ep->musb; 107 u16 csr;
105 unsigned long flags;
106 struct dma_tx_state txstate;
107 u32 transferred;
108 108
109 spin_lock_irqsave(&musb->lock, flags); 109 csr = musb_readw(epio, MUSB_TXCSR);
110 if (csr & MUSB_TXCSR_TXPKTRDY)
111 return false;
112 return true;
113}
110 114
111 dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie, 115static void cppi41_dma_callback(void *private_data);
112 &txstate);
113 transferred = cppi41_channel->prog_len - txstate.residue;
114 cppi41_channel->transferred += transferred;
115 116
116 dev_dbg(musb->controller, "DMA transfer done on hw_ep=%d bytes=%d/%d\n", 117static void cppi41_trans_done(struct cppi41_dma_channel *cppi41_channel)
117 hw_ep->epnum, cppi41_channel->transferred, 118{
118 cppi41_channel->total_len); 119 struct musb_hw_ep *hw_ep = cppi41_channel->hw_ep;
120 struct musb *musb = hw_ep->musb;
119 121
120 update_rx_toggle(cppi41_channel); 122 if (!cppi41_channel->prog_len) {
121
122 if (cppi41_channel->transferred == cppi41_channel->total_len ||
123 transferred < cppi41_channel->packet_sz) {
124 123
125 /* done, complete */ 124 /* done, complete */
126 cppi41_channel->channel.actual_len = 125 cppi41_channel->channel.actual_len =
@@ -150,13 +149,11 @@ static void cppi41_dma_callback(void *private_data)
150 remain_bytes, 149 remain_bytes,
151 direction, 150 direction,
152 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 151 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
153 if (WARN_ON(!dma_desc)) { 152 if (WARN_ON(!dma_desc))
154 spin_unlock_irqrestore(&musb->lock, flags);
155 return; 153 return;
156 }
157 154
158 dma_desc->callback = cppi41_dma_callback; 155 dma_desc->callback = cppi41_dma_callback;
159 dma_desc->callback_param = channel; 156 dma_desc->callback_param = &cppi41_channel->channel;
160 cppi41_channel->cookie = dma_desc->tx_submit(dma_desc); 157 cppi41_channel->cookie = dma_desc->tx_submit(dma_desc);
161 dma_async_issue_pending(dc); 158 dma_async_issue_pending(dc);
162 159
@@ -166,6 +163,117 @@ static void cppi41_dma_callback(void *private_data)
166 musb_writew(epio, MUSB_RXCSR, csr); 163 musb_writew(epio, MUSB_RXCSR, csr);
167 } 164 }
168 } 165 }
166}
167
168static enum hrtimer_restart cppi41_recheck_tx_req(struct hrtimer *timer)
169{
170 struct cppi41_dma_controller *controller;
171 struct cppi41_dma_channel *cppi41_channel, *n;
172 struct musb *musb;
173 unsigned long flags;
174 enum hrtimer_restart ret = HRTIMER_NORESTART;
175
176 controller = container_of(timer, struct cppi41_dma_controller,
177 early_tx);
178 musb = controller->musb;
179
180 spin_lock_irqsave(&musb->lock, flags);
181 list_for_each_entry_safe(cppi41_channel, n, &controller->early_tx_list,
182 tx_check) {
183 bool empty;
184 struct musb_hw_ep *hw_ep = cppi41_channel->hw_ep;
185
186 empty = musb_is_tx_fifo_empty(hw_ep);
187 if (empty) {
188 list_del_init(&cppi41_channel->tx_check);
189 cppi41_trans_done(cppi41_channel);
190 }
191 }
192
193 if (!list_empty(&controller->early_tx_list)) {
194 ret = HRTIMER_RESTART;
195 hrtimer_forward_now(&controller->early_tx,
196 ktime_set(0, 150 * NSEC_PER_USEC));
197 }
198
199 spin_unlock_irqrestore(&musb->lock, flags);
200 return ret;
201}
202
203static void cppi41_dma_callback(void *private_data)
204{
205 struct dma_channel *channel = private_data;
206 struct cppi41_dma_channel *cppi41_channel = channel->private_data;
207 struct musb_hw_ep *hw_ep = cppi41_channel->hw_ep;
208 struct musb *musb = hw_ep->musb;
209 unsigned long flags;
210 struct dma_tx_state txstate;
211 u32 transferred;
212 bool empty;
213
214 spin_lock_irqsave(&musb->lock, flags);
215
216 dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie,
217 &txstate);
218 transferred = cppi41_channel->prog_len - txstate.residue;
219 cppi41_channel->transferred += transferred;
220
221 dev_dbg(musb->controller, "DMA transfer done on hw_ep=%d bytes=%d/%d\n",
222 hw_ep->epnum, cppi41_channel->transferred,
223 cppi41_channel->total_len);
224
225 update_rx_toggle(cppi41_channel);
226
227 if (cppi41_channel->transferred == cppi41_channel->total_len ||
228 transferred < cppi41_channel->packet_sz)
229 cppi41_channel->prog_len = 0;
230
231 empty = musb_is_tx_fifo_empty(hw_ep);
232 if (empty) {
233 cppi41_trans_done(cppi41_channel);
234 } else {
235 struct cppi41_dma_controller *controller;
236 /*
237 * On AM335x it has been observed that the TX interrupt fires
238 * too early that means the TXFIFO is not yet empty but the DMA
239 * engine says that it is done with the transfer. We don't
240 * receive a FIFO empty interrupt so the only thing we can do is
241 * to poll for the bit. On HS it usually takes 2us, on FS around
242 * 110us - 150us depending on the transfer size.
243 * We spin on HS (no longer than than 25us and setup a timer on
244 * FS to check for the bit and complete the transfer.
245 */
246 controller = cppi41_channel->controller;
247
248 if (musb->g.speed == USB_SPEED_HIGH) {
249 unsigned wait = 25;
250
251 do {
252 empty = musb_is_tx_fifo_empty(hw_ep);
253 if (empty)
254 break;
255 wait--;
256 if (!wait)
257 break;
258 udelay(1);
259 } while (1);
260
261 empty = musb_is_tx_fifo_empty(hw_ep);
262 if (empty) {
263 cppi41_trans_done(cppi41_channel);
264 goto out;
265 }
266 }
267 list_add_tail(&cppi41_channel->tx_check,
268 &controller->early_tx_list);
269 if (!hrtimer_active(&controller->early_tx)) {
270 hrtimer_start_range_ns(&controller->early_tx,
271 ktime_set(0, 140 * NSEC_PER_USEC),
272 40 * NSEC_PER_USEC,
273 HRTIMER_MODE_REL);
274 }
275 }
276out:
169 spin_unlock_irqrestore(&musb->lock, flags); 277 spin_unlock_irqrestore(&musb->lock, flags);
170} 278}
171 279
@@ -364,6 +472,8 @@ static int cppi41_is_compatible(struct dma_channel *channel, u16 maxpacket,
364 WARN_ON(1); 472 WARN_ON(1);
365 return 1; 473 return 1;
366 } 474 }
475 if (cppi41_channel->hw_ep->ep_in.type != USB_ENDPOINT_XFER_BULK)
476 return 0;
367 if (cppi41_channel->is_tx) 477 if (cppi41_channel->is_tx)
368 return 1; 478 return 1;
369 /* AM335x Advisory 1.0.13. No workaround for device RX mode */ 479 /* AM335x Advisory 1.0.13. No workaround for device RX mode */
@@ -388,6 +498,7 @@ static int cppi41_dma_channel_abort(struct dma_channel *channel)
388 if (cppi41_channel->channel.status == MUSB_DMA_STATUS_FREE) 498 if (cppi41_channel->channel.status == MUSB_DMA_STATUS_FREE)
389 return 0; 499 return 0;
390 500
501 list_del_init(&cppi41_channel->tx_check);
391 if (is_tx) { 502 if (is_tx) {
392 csr = musb_readw(epio, MUSB_TXCSR); 503 csr = musb_readw(epio, MUSB_TXCSR);
393 csr &= ~MUSB_TXCSR_DMAENAB; 504 csr &= ~MUSB_TXCSR_DMAENAB;
@@ -495,6 +606,7 @@ static int cppi41_dma_controller_start(struct cppi41_dma_controller *controller)
495 cppi41_channel->controller = controller; 606 cppi41_channel->controller = controller;
496 cppi41_channel->port_num = port; 607 cppi41_channel->port_num = port;
497 cppi41_channel->is_tx = is_tx; 608 cppi41_channel->is_tx = is_tx;
609 INIT_LIST_HEAD(&cppi41_channel->tx_check);
498 610
499 musb_dma = &cppi41_channel->channel; 611 musb_dma = &cppi41_channel->channel;
500 musb_dma->private_data = cppi41_channel; 612 musb_dma->private_data = cppi41_channel;
@@ -520,6 +632,7 @@ void dma_controller_destroy(struct dma_controller *c)
520 struct cppi41_dma_controller *controller = container_of(c, 632 struct cppi41_dma_controller *controller = container_of(c,
521 struct cppi41_dma_controller, controller); 633 struct cppi41_dma_controller, controller);
522 634
635 hrtimer_cancel(&controller->early_tx);
523 cppi41_dma_controller_stop(controller); 636 cppi41_dma_controller_stop(controller);
524 kfree(controller); 637 kfree(controller);
525} 638}
@@ -539,6 +652,9 @@ struct dma_controller *dma_controller_create(struct musb *musb,
539 if (!controller) 652 if (!controller)
540 goto kzalloc_fail; 653 goto kzalloc_fail;
541 654
655 hrtimer_init(&controller->early_tx, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
656 controller->early_tx.function = cppi41_recheck_tx_req;
657 INIT_LIST_HEAD(&controller->early_tx_list);
542 controller->musb = musb; 658 controller->musb = musb;
543 659
544 controller->controller.channel_alloc = cppi41_dma_channel_allocate; 660 controller->controller.channel_alloc = cppi41_dma_channel_allocate;
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index d2d3a173b315..32fb057c03f5 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1796,7 +1796,11 @@ int musb_gadget_setup(struct musb *musb)
1796 1796
1797 /* this "gadget" abstracts/virtualizes the controller */ 1797 /* this "gadget" abstracts/virtualizes the controller */
1798 musb->g.name = musb_driver_name; 1798 musb->g.name = musb_driver_name;
1799#if IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
1799 musb->g.is_otg = 1; 1800 musb->g.is_otg = 1;
1801#elif IS_ENABLED(CONFIG_USB_MUSB_GADGET)
1802 musb->g.is_otg = 0;
1803#endif
1800 1804
1801 musb_g_init_endpoints(musb); 1805 musb_g_init_endpoints(musb);
1802 1806
diff --git a/drivers/usb/phy/phy-am335x.c b/drivers/usb/phy/phy-am335x.c
index 6370e50649d7..0e3c60cb669a 100644
--- a/drivers/usb/phy/phy-am335x.c
+++ b/drivers/usb/phy/phy-am335x.c
@@ -52,8 +52,7 @@ static int am335x_phy_probe(struct platform_device *pdev)
52 return am_phy->id; 52 return am_phy->id;
53 } 53 }
54 54
55 ret = usb_phy_gen_create_phy(dev, &am_phy->usb_phy_gen, 55 ret = usb_phy_gen_create_phy(dev, &am_phy->usb_phy_gen, NULL);
56 USB_PHY_TYPE_USB2, 0, false);
57 if (ret) 56 if (ret)
58 return ret; 57 return ret;
59 58
@@ -66,8 +65,6 @@ static int am335x_phy_probe(struct platform_device *pdev)
66 platform_set_drvdata(pdev, am_phy); 65 platform_set_drvdata(pdev, am_phy);
67 66
68 return 0; 67 return 0;
69
70 return ret;
71} 68}
72 69
73static int am335x_phy_remove(struct platform_device *pdev) 70static int am335x_phy_remove(struct platform_device *pdev)
diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index fce3a9e9bb5d..aa6d37b3378a 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -48,8 +48,9 @@ void usb_nop_xceiv_register(void)
48 if (pd) 48 if (pd)
49 return; 49 return;
50 pd = platform_device_register_simple("usb_phy_gen_xceiv", -1, NULL, 0); 50 pd = platform_device_register_simple("usb_phy_gen_xceiv", -1, NULL, 0);
51 if (!pd) { 51 if (IS_ERR(pd)) {
52 pr_err("Unable to register generic usb transceiver\n"); 52 pr_err("Unable to register generic usb transceiver\n");
53 pd = NULL;
53 return; 54 return;
54 } 55 }
55} 56}
@@ -150,10 +151,40 @@ static int nop_set_host(struct usb_otg *otg, struct usb_bus *host)
150} 151}
151 152
152int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop, 153int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop,
153 enum usb_phy_type type, u32 clk_rate, bool needs_vcc) 154 struct usb_phy_gen_xceiv_platform_data *pdata)
154{ 155{
156 enum usb_phy_type type = USB_PHY_TYPE_USB2;
155 int err; 157 int err;
156 158
159 u32 clk_rate = 0;
160 bool needs_vcc = false;
161
162 nop->reset_active_low = true; /* default behaviour */
163
164 if (dev->of_node) {
165 struct device_node *node = dev->of_node;
166 enum of_gpio_flags flags = 0;
167
168 if (of_property_read_u32(node, "clock-frequency", &clk_rate))
169 clk_rate = 0;
170
171 needs_vcc = of_property_read_bool(node, "vcc-supply");
172 nop->gpio_reset = of_get_named_gpio_flags(node, "reset-gpios",
173 0, &flags);
174 if (nop->gpio_reset == -EPROBE_DEFER)
175 return -EPROBE_DEFER;
176
177 nop->reset_active_low = flags & OF_GPIO_ACTIVE_LOW;
178
179 } else if (pdata) {
180 type = pdata->type;
181 clk_rate = pdata->clk_rate;
182 needs_vcc = pdata->needs_vcc;
183 nop->gpio_reset = pdata->gpio_reset;
184 } else {
185 nop->gpio_reset = -1;
186 }
187
157 nop->phy.otg = devm_kzalloc(dev, sizeof(*nop->phy.otg), 188 nop->phy.otg = devm_kzalloc(dev, sizeof(*nop->phy.otg),
158 GFP_KERNEL); 189 GFP_KERNEL);
159 if (!nop->phy.otg) 190 if (!nop->phy.otg)
@@ -218,43 +249,14 @@ EXPORT_SYMBOL_GPL(usb_phy_gen_create_phy);
218static int usb_phy_gen_xceiv_probe(struct platform_device *pdev) 249static int usb_phy_gen_xceiv_probe(struct platform_device *pdev)
219{ 250{
220 struct device *dev = &pdev->dev; 251 struct device *dev = &pdev->dev;
221 struct usb_phy_gen_xceiv_platform_data *pdata =
222 dev_get_platdata(&pdev->dev);
223 struct usb_phy_gen_xceiv *nop; 252 struct usb_phy_gen_xceiv *nop;
224 enum usb_phy_type type = USB_PHY_TYPE_USB2;
225 int err; 253 int err;
226 u32 clk_rate = 0;
227 bool needs_vcc = false;
228 254
229 nop = devm_kzalloc(dev, sizeof(*nop), GFP_KERNEL); 255 nop = devm_kzalloc(dev, sizeof(*nop), GFP_KERNEL);
230 if (!nop) 256 if (!nop)
231 return -ENOMEM; 257 return -ENOMEM;
232 258
233 nop->reset_active_low = true; /* default behaviour */ 259 err = usb_phy_gen_create_phy(dev, nop, dev_get_platdata(&pdev->dev));
234
235 if (dev->of_node) {
236 struct device_node *node = dev->of_node;
237 enum of_gpio_flags flags;
238
239 if (of_property_read_u32(node, "clock-frequency", &clk_rate))
240 clk_rate = 0;
241
242 needs_vcc = of_property_read_bool(node, "vcc-supply");
243 nop->gpio_reset = of_get_named_gpio_flags(node, "reset-gpios",
244 0, &flags);
245 if (nop->gpio_reset == -EPROBE_DEFER)
246 return -EPROBE_DEFER;
247
248 nop->reset_active_low = flags & OF_GPIO_ACTIVE_LOW;
249
250 } else if (pdata) {
251 type = pdata->type;
252 clk_rate = pdata->clk_rate;
253 needs_vcc = pdata->needs_vcc;
254 nop->gpio_reset = pdata->gpio_reset;
255 }
256
257 err = usb_phy_gen_create_phy(dev, nop, type, clk_rate, needs_vcc);
258 if (err) 260 if (err)
259 return err; 261 return err;
260 262
@@ -271,8 +273,6 @@ static int usb_phy_gen_xceiv_probe(struct platform_device *pdev)
271 platform_set_drvdata(pdev, nop); 273 platform_set_drvdata(pdev, nop);
272 274
273 return 0; 275 return 0;
274
275 return err;
276} 276}
277 277
278static int usb_phy_gen_xceiv_remove(struct platform_device *pdev) 278static int usb_phy_gen_xceiv_remove(struct platform_device *pdev)
diff --git a/drivers/usb/phy/phy-generic.h b/drivers/usb/phy/phy-generic.h
index d2a220d81734..38a81f307b82 100644
--- a/drivers/usb/phy/phy-generic.h
+++ b/drivers/usb/phy/phy-generic.h
@@ -1,6 +1,8 @@
1#ifndef _PHY_GENERIC_H_ 1#ifndef _PHY_GENERIC_H_
2#define _PHY_GENERIC_H_ 2#define _PHY_GENERIC_H_
3 3
4#include <linux/usb/usb_phy_gen_xceiv.h>
5
4struct usb_phy_gen_xceiv { 6struct usb_phy_gen_xceiv {
5 struct usb_phy phy; 7 struct usb_phy phy;
6 struct device *dev; 8 struct device *dev;
@@ -14,6 +16,6 @@ int usb_gen_phy_init(struct usb_phy *phy);
14void usb_gen_phy_shutdown(struct usb_phy *phy); 16void usb_gen_phy_shutdown(struct usb_phy *phy);
15 17
16int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop, 18int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop,
17 enum usb_phy_type type, u32 clk_rate, bool needs_vcc); 19 struct usb_phy_gen_xceiv_platform_data *pdata);
18 20
19#endif 21#endif
diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index fdd33b44dbd3..545844b7e796 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -164,7 +164,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
164 164
165 mxs_phy->clk = clk; 165 mxs_phy->clk = clk;
166 166
167 platform_set_drvdata(pdev, &mxs_phy->phy); 167 platform_set_drvdata(pdev, mxs_phy);
168 168
169 ret = usb_add_phy_dev(&mxs_phy->phy); 169 ret = usb_add_phy_dev(&mxs_phy->phy);
170 if (ret) 170 if (ret)
diff --git a/drivers/usb/phy/phy-rcar-gen2-usb.c b/drivers/usb/phy/phy-rcar-gen2-usb.c
index a99a6953f11c..db3ab34cddb4 100644
--- a/drivers/usb/phy/phy-rcar-gen2-usb.c
+++ b/drivers/usb/phy/phy-rcar-gen2-usb.c
@@ -107,10 +107,10 @@ static void __rcar_gen2_usb_phy_init(struct rcar_gen2_usb_phy_priv *priv)
107 clk_prepare_enable(priv->clk); 107 clk_prepare_enable(priv->clk);
108 108
109 /* Set USB channels in the USBHS UGCTRL2 register */ 109 /* Set USB channels in the USBHS UGCTRL2 register */
110 val = ioread32(priv->base); 110 val = ioread32(priv->base + USBHS_UGCTRL2_REG);
111 val &= ~(USBHS_UGCTRL2_USB0_HS | USBHS_UGCTRL2_USB2_SS); 111 val &= ~(USBHS_UGCTRL2_USB0_HS | USBHS_UGCTRL2_USB2_SS);
112 val |= priv->ugctrl2; 112 val |= priv->ugctrl2;
113 iowrite32(val, priv->base); 113 iowrite32(val, priv->base + USBHS_UGCTRL2_REG);
114} 114}
115 115
116/* Shutdown USB channels */ 116/* Shutdown USB channels */
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 9ced8937a8f3..fb0d537435eb 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -2123,6 +2123,20 @@ static void ftdi_set_termios(struct tty_struct *tty,
2123 termios->c_cflag |= CRTSCTS; 2123 termios->c_cflag |= CRTSCTS;
2124 } 2124 }
2125 2125
2126 /*
2127 * All FTDI UART chips are limited to CS7/8. We won't pretend to
2128 * support CS5/6 and revert the CSIZE setting instead.
2129 */
2130 if ((C_CSIZE(tty) != CS8) && (C_CSIZE(tty) != CS7)) {
2131 dev_warn(ddev, "requested CSIZE setting not supported\n");
2132
2133 termios->c_cflag &= ~CSIZE;
2134 if (old_termios)
2135 termios->c_cflag |= old_termios->c_cflag & CSIZE;
2136 else
2137 termios->c_cflag |= CS8;
2138 }
2139
2126 cflag = termios->c_cflag; 2140 cflag = termios->c_cflag;
2127 2141
2128 if (!old_termios) 2142 if (!old_termios)
@@ -2159,19 +2173,16 @@ no_skip:
2159 } else { 2173 } else {
2160 urb_value |= FTDI_SIO_SET_DATA_PARITY_NONE; 2174 urb_value |= FTDI_SIO_SET_DATA_PARITY_NONE;
2161 } 2175 }
2162 if (cflag & CSIZE) { 2176 switch (cflag & CSIZE) {
2163 switch (cflag & CSIZE) { 2177 case CS7:
2164 case CS7: 2178 urb_value |= 7;
2165 urb_value |= 7; 2179 dev_dbg(ddev, "Setting CS7\n");
2166 dev_dbg(ddev, "Setting CS7\n"); 2180 break;
2167 break; 2181 default:
2168 case CS8: 2182 case CS8:
2169 urb_value |= 8; 2183 urb_value |= 8;
2170 dev_dbg(ddev, "Setting CS8\n"); 2184 dev_dbg(ddev, "Setting CS8\n");
2171 break; 2185 break;
2172 default:
2173 dev_err(ddev, "CSIZE was set but not CS7-CS8\n");
2174 }
2175 } 2186 }
2176 2187
2177 /* This is needed by the break command since it uses the same command 2188 /* This is needed by the break command since it uses the same command
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 2b01ec8651c2..b63ce023f96f 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -173,16 +173,8 @@ retry:
173 clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags); 173 clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags);
174 return result; 174 return result;
175 } 175 }
176 /*
177 * Try sending off another urb, unless called from completion handler
178 * (in which case there will be no free urb or no data).
179 */
180 if (mem_flags != GFP_ATOMIC)
181 goto retry;
182 176
183 clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags); 177 goto retry; /* try sending off another urb */
184
185 return 0;
186} 178}
187EXPORT_SYMBOL_GPL(usb_serial_generic_write_start); 179EXPORT_SYMBOL_GPL(usb_serial_generic_write_start);
188 180
@@ -208,7 +200,7 @@ int usb_serial_generic_write(struct tty_struct *tty,
208 return 0; 200 return 0;
209 201
210 count = kfifo_in_locked(&port->write_fifo, buf, count, &port->lock); 202 count = kfifo_in_locked(&port->write_fifo, buf, count, &port->lock);
211 result = usb_serial_generic_write_start(port, GFP_KERNEL); 203 result = usb_serial_generic_write_start(port, GFP_ATOMIC);
212 if (result) 204 if (result)
213 return result; 205 return result;
214 206
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index e5bdd987b9e8..a69da83604c0 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -1813,25 +1813,25 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
1813 iflag = tty->termios.c_iflag; 1813 iflag = tty->termios.c_iflag;
1814 1814
1815 /* Change the number of bits */ 1815 /* Change the number of bits */
1816 if (cflag & CSIZE) { 1816 switch (cflag & CSIZE) {
1817 switch (cflag & CSIZE) { 1817 case CS5:
1818 case CS5: 1818 lData = LCR_BITS_5;
1819 lData = LCR_BITS_5; 1819 break;
1820 break;
1821 1820
1822 case CS6: 1821 case CS6:
1823 lData = LCR_BITS_6; 1822 lData = LCR_BITS_6;
1824 break; 1823 break;
1825 1824
1826 case CS7: 1825 case CS7:
1827 lData = LCR_BITS_7; 1826 lData = LCR_BITS_7;
1828 break; 1827 break;
1829 default: 1828
1830 case CS8: 1829 default:
1831 lData = LCR_BITS_8; 1830 case CS8:
1832 break; 1831 lData = LCR_BITS_8;
1833 } 1832 break;
1834 } 1833 }
1834
1835 /* Change the Parity bit */ 1835 /* Change the Parity bit */
1836 if (cflag & PARENB) { 1836 if (cflag & PARENB) {
1837 if (cflag & PARODD) { 1837 if (cflag & PARODD) {
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index c3d94853b4ab..496b7e39d5be 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -85,6 +85,7 @@ static void option_instat_callback(struct urb *urb);
85#define HUAWEI_PRODUCT_K4505 0x1464 85#define HUAWEI_PRODUCT_K4505 0x1464
86#define HUAWEI_PRODUCT_K3765 0x1465 86#define HUAWEI_PRODUCT_K3765 0x1465
87#define HUAWEI_PRODUCT_K4605 0x14C6 87#define HUAWEI_PRODUCT_K4605 0x14C6
88#define HUAWEI_PRODUCT_E173S6 0x1C07
88 89
89#define QUANTA_VENDOR_ID 0x0408 90#define QUANTA_VENDOR_ID 0x0408
90#define QUANTA_PRODUCT_Q101 0xEA02 91#define QUANTA_PRODUCT_Q101 0xEA02
@@ -572,6 +573,8 @@ static const struct usb_device_id option_ids[] = {
572 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c23, USB_CLASS_COMM, 0x02, 0xff) }, 573 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c23, USB_CLASS_COMM, 0x02, 0xff) },
573 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173, 0xff, 0xff, 0xff), 574 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173, 0xff, 0xff, 0xff),
574 .driver_info = (kernel_ulong_t) &net_intf1_blacklist }, 575 .driver_info = (kernel_ulong_t) &net_intf1_blacklist },
576 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173S6, 0xff, 0xff, 0xff),
577 .driver_info = (kernel_ulong_t) &net_intf1_blacklist },
575 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1750, 0xff, 0xff, 0xff), 578 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1750, 0xff, 0xff, 0xff),
576 .driver_info = (kernel_ulong_t) &net_intf2_blacklist }, 579 .driver_info = (kernel_ulong_t) &net_intf2_blacklist },
577 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1441, USB_CLASS_COMM, 0x02, 0xff) }, 580 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1441, USB_CLASS_COMM, 0x02, 0xff) },
@@ -634,6 +637,10 @@ static const struct usb_device_id option_ids[] = {
634 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6D) }, 637 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6D) },
635 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6E) }, 638 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6E) },
636 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6F) }, 639 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6F) },
640 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x72) },
641 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x73) },
642 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x74) },
643 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x75) },
637 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x78) }, 644 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x78) },
638 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x79) }, 645 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x79) },
639 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x7A) }, 646 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x7A) },
@@ -688,6 +695,10 @@ static const struct usb_device_id option_ids[] = {
688 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6D) }, 695 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6D) },
689 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6E) }, 696 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6E) },
690 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6F) }, 697 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6F) },
698 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x72) },
699 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x73) },
700 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x74) },
701 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x75) },
691 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x78) }, 702 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x78) },
692 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x79) }, 703 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x79) },
693 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7A) }, 704 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7A) },
@@ -742,6 +753,10 @@ static const struct usb_device_id option_ids[] = {
742 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6D) }, 753 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6D) },
743 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6E) }, 754 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6E) },
744 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6F) }, 755 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6F) },
756 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x72) },
757 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x73) },
758 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x74) },
759 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x75) },
745 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x78) }, 760 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x78) },
746 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x79) }, 761 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x79) },
747 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7A) }, 762 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7A) },
@@ -796,6 +811,10 @@ static const struct usb_device_id option_ids[] = {
796 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6D) }, 811 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6D) },
797 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6E) }, 812 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6E) },
798 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6F) }, 813 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6F) },
814 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x72) },
815 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x73) },
816 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x74) },
817 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x75) },
799 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x78) }, 818 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x78) },
800 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x79) }, 819 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x79) },
801 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7A) }, 820 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7A) },
@@ -850,6 +869,10 @@ static const struct usb_device_id option_ids[] = {
850 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6D) }, 869 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6D) },
851 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6E) }, 870 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6E) },
852 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6F) }, 871 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6F) },
872 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x72) },
873 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x73) },
874 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x74) },
875 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x75) },
853 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x78) }, 876 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x78) },
854 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x79) }, 877 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x79) },
855 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7A) }, 878 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7A) },
@@ -904,6 +927,10 @@ static const struct usb_device_id option_ids[] = {
904 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6D) }, 927 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6D) },
905 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6E) }, 928 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6E) },
906 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6F) }, 929 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6F) },
930 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x72) },
931 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x73) },
932 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x74) },
933 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x75) },
907 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x78) }, 934 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x78) },
908 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x79) }, 935 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x79) },
909 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7A) }, 936 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7A) },
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 1e6de4cd079d..1e3318dfa1cb 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -361,23 +361,21 @@ static void pl2303_set_termios(struct tty_struct *tty,
361 0, 0, buf, 7, 100); 361 0, 0, buf, 7, 100);
362 dev_dbg(&port->dev, "0xa1:0x21:0:0 %d - %7ph\n", i, buf); 362 dev_dbg(&port->dev, "0xa1:0x21:0:0 %d - %7ph\n", i, buf);
363 363
364 if (C_CSIZE(tty)) { 364 switch (C_CSIZE(tty)) {
365 switch (C_CSIZE(tty)) { 365 case CS5:
366 case CS5: 366 buf[6] = 5;
367 buf[6] = 5; 367 break;
368 break; 368 case CS6:
369 case CS6: 369 buf[6] = 6;
370 buf[6] = 6; 370 break;
371 break; 371 case CS7:
372 case CS7: 372 buf[6] = 7;
373 buf[6] = 7; 373 break;
374 break; 374 default:
375 default: 375 case CS8:
376 case CS8: 376 buf[6] = 8;
377 buf[6] = 8;
378 }
379 dev_dbg(&port->dev, "data bits = %d\n", buf[6]);
380 } 377 }
378 dev_dbg(&port->dev, "data bits = %d\n", buf[6]);
381 379
382 /* For reference buf[0]:buf[3] baud rate value */ 380 /* For reference buf[0]:buf[3] baud rate value */
383 pl2303_encode_baudrate(tty, port, &buf[0]); 381 pl2303_encode_baudrate(tty, port, &buf[0]);
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index 4abac28b5992..5b793c352267 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -348,22 +348,20 @@ static void spcp8x5_set_termios(struct tty_struct *tty,
348 } 348 }
349 349
350 /* Set Data Length : 00:5bit, 01:6bit, 10:7bit, 11:8bit */ 350 /* Set Data Length : 00:5bit, 01:6bit, 10:7bit, 11:8bit */
351 if (cflag & CSIZE) { 351 switch (cflag & CSIZE) {
352 switch (cflag & CSIZE) { 352 case CS5:
353 case CS5: 353 buf[1] |= SET_UART_FORMAT_SIZE_5;
354 buf[1] |= SET_UART_FORMAT_SIZE_5; 354 break;
355 break; 355 case CS6:
356 case CS6: 356 buf[1] |= SET_UART_FORMAT_SIZE_6;
357 buf[1] |= SET_UART_FORMAT_SIZE_6; 357 break;
358 break; 358 case CS7:
359 case CS7: 359 buf[1] |= SET_UART_FORMAT_SIZE_7;
360 buf[1] |= SET_UART_FORMAT_SIZE_7; 360 break;
361 break; 361 default:
362 default: 362 case CS8:
363 case CS8: 363 buf[1] |= SET_UART_FORMAT_SIZE_8;
364 buf[1] |= SET_UART_FORMAT_SIZE_8; 364 break;
365 break;
366 }
367 } 365 }
368 366
369 /* Set Stop bit2 : 0:1bit 1:2bit */ 367 /* Set Stop bit2 : 0:1bit 1:2bit */
diff --git a/drivers/usb/wusbcore/devconnect.c b/drivers/usb/wusbcore/devconnect.c
index e538b72c4e3a..f14e7929ba22 100644
--- a/drivers/usb/wusbcore/devconnect.c
+++ b/drivers/usb/wusbcore/devconnect.c
@@ -97,18 +97,12 @@ static void wusbhc_devconnect_acked_work(struct work_struct *work);
97 97
98static void wusb_dev_free(struct wusb_dev *wusb_dev) 98static void wusb_dev_free(struct wusb_dev *wusb_dev)
99{ 99{
100 if (wusb_dev) { 100 kfree(wusb_dev);
101 kfree(wusb_dev->set_gtk_req);
102 usb_free_urb(wusb_dev->set_gtk_urb);
103 kfree(wusb_dev);
104 }
105} 101}
106 102
107static struct wusb_dev *wusb_dev_alloc(struct wusbhc *wusbhc) 103static struct wusb_dev *wusb_dev_alloc(struct wusbhc *wusbhc)
108{ 104{
109 struct wusb_dev *wusb_dev; 105 struct wusb_dev *wusb_dev;
110 struct urb *urb;
111 struct usb_ctrlrequest *req;
112 106
113 wusb_dev = kzalloc(sizeof(*wusb_dev), GFP_KERNEL); 107 wusb_dev = kzalloc(sizeof(*wusb_dev), GFP_KERNEL);
114 if (wusb_dev == NULL) 108 if (wusb_dev == NULL)
@@ -118,22 +112,6 @@ static struct wusb_dev *wusb_dev_alloc(struct wusbhc *wusbhc)
118 112
119 INIT_WORK(&wusb_dev->devconnect_acked_work, wusbhc_devconnect_acked_work); 113 INIT_WORK(&wusb_dev->devconnect_acked_work, wusbhc_devconnect_acked_work);
120 114
121 urb = usb_alloc_urb(0, GFP_KERNEL);
122 if (urb == NULL)
123 goto err;
124 wusb_dev->set_gtk_urb = urb;
125
126 req = kmalloc(sizeof(*req), GFP_KERNEL);
127 if (req == NULL)
128 goto err;
129 wusb_dev->set_gtk_req = req;
130
131 req->bRequestType = USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE;
132 req->bRequest = USB_REQ_SET_DESCRIPTOR;
133 req->wValue = cpu_to_le16(USB_DT_KEY << 8 | wusbhc->gtk_index);
134 req->wIndex = 0;
135 req->wLength = cpu_to_le16(wusbhc->gtk.descr.bLength);
136
137 return wusb_dev; 115 return wusb_dev;
138err: 116err:
139 wusb_dev_free(wusb_dev); 117 wusb_dev_free(wusb_dev);
@@ -411,9 +389,6 @@ static void __wusbhc_dev_disconnect(struct wusbhc *wusbhc,
411/* 389/*
412 * Refresh the list of keep alives to emit in the MMC 390 * Refresh the list of keep alives to emit in the MMC
413 * 391 *
414 * Some devices don't respond to keep alives unless they've been
415 * authenticated, so skip unauthenticated devices.
416 *
417 * We only publish the first four devices that have a coming timeout 392 * We only publish the first four devices that have a coming timeout
418 * condition. Then when we are done processing those, we go for the 393 * condition. Then when we are done processing those, we go for the
419 * next ones. We ignore the ones that have timed out already (they'll 394 * next ones. We ignore the ones that have timed out already (they'll
@@ -448,7 +423,7 @@ static void __wusbhc_keep_alive(struct wusbhc *wusbhc)
448 423
449 if (wusb_dev == NULL) 424 if (wusb_dev == NULL)
450 continue; 425 continue;
451 if (wusb_dev->usb_dev == NULL || !wusb_dev->usb_dev->authenticated) 426 if (wusb_dev->usb_dev == NULL)
452 continue; 427 continue;
453 428
454 if (time_after(jiffies, wusb_dev->entry_ts + tt)) { 429 if (time_after(jiffies, wusb_dev->entry_ts + tt)) {
@@ -524,11 +499,19 @@ static struct wusb_dev *wusbhc_find_dev_by_addr(struct wusbhc *wusbhc, u8 addr)
524 * 499 *
525 * @wusbhc shall be referenced and unlocked 500 * @wusbhc shall be referenced and unlocked
526 */ 501 */
527static void wusbhc_handle_dn_alive(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev) 502static void wusbhc_handle_dn_alive(struct wusbhc *wusbhc, u8 srcaddr)
528{ 503{
504 struct wusb_dev *wusb_dev;
505
529 mutex_lock(&wusbhc->mutex); 506 mutex_lock(&wusbhc->mutex);
530 wusb_dev->entry_ts = jiffies; 507 wusb_dev = wusbhc_find_dev_by_addr(wusbhc, srcaddr);
531 __wusbhc_keep_alive(wusbhc); 508 if (wusb_dev == NULL) {
509 dev_dbg(wusbhc->dev, "ignoring DN_Alive from unconnected device %02x\n",
510 srcaddr);
511 } else {
512 wusb_dev->entry_ts = jiffies;
513 __wusbhc_keep_alive(wusbhc);
514 }
532 mutex_unlock(&wusbhc->mutex); 515 mutex_unlock(&wusbhc->mutex);
533} 516}
534 517
@@ -582,14 +565,22 @@ static void wusbhc_handle_dn_connect(struct wusbhc *wusbhc,
582 * 565 *
583 * @wusbhc shall be referenced and unlocked 566 * @wusbhc shall be referenced and unlocked
584 */ 567 */
585static void wusbhc_handle_dn_disconnect(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev) 568static void wusbhc_handle_dn_disconnect(struct wusbhc *wusbhc, u8 srcaddr)
586{ 569{
587 struct device *dev = wusbhc->dev; 570 struct device *dev = wusbhc->dev;
588 571 struct wusb_dev *wusb_dev;
589 dev_info(dev, "DN DISCONNECT: device 0x%02x going down\n", wusb_dev->addr);
590 572
591 mutex_lock(&wusbhc->mutex); 573 mutex_lock(&wusbhc->mutex);
592 __wusbhc_dev_disconnect(wusbhc, wusb_port_by_idx(wusbhc, wusb_dev->port_idx)); 574 wusb_dev = wusbhc_find_dev_by_addr(wusbhc, srcaddr);
575 if (wusb_dev == NULL) {
576 dev_dbg(dev, "ignoring DN DISCONNECT from unconnected device %02x\n",
577 srcaddr);
578 } else {
579 dev_info(dev, "DN DISCONNECT: device 0x%02x going down\n",
580 wusb_dev->addr);
581 __wusbhc_dev_disconnect(wusbhc, wusb_port_by_idx(wusbhc,
582 wusb_dev->port_idx));
583 }
593 mutex_unlock(&wusbhc->mutex); 584 mutex_unlock(&wusbhc->mutex);
594} 585}
595 586
@@ -611,30 +602,21 @@ void wusbhc_handle_dn(struct wusbhc *wusbhc, u8 srcaddr,
611 struct wusb_dn_hdr *dn_hdr, size_t size) 602 struct wusb_dn_hdr *dn_hdr, size_t size)
612{ 603{
613 struct device *dev = wusbhc->dev; 604 struct device *dev = wusbhc->dev;
614 struct wusb_dev *wusb_dev;
615 605
616 if (size < sizeof(struct wusb_dn_hdr)) { 606 if (size < sizeof(struct wusb_dn_hdr)) {
617 dev_err(dev, "DN data shorter than DN header (%d < %d)\n", 607 dev_err(dev, "DN data shorter than DN header (%d < %d)\n",
618 (int)size, (int)sizeof(struct wusb_dn_hdr)); 608 (int)size, (int)sizeof(struct wusb_dn_hdr));
619 return; 609 return;
620 } 610 }
621
622 wusb_dev = wusbhc_find_dev_by_addr(wusbhc, srcaddr);
623 if (wusb_dev == NULL && dn_hdr->bType != WUSB_DN_CONNECT) {
624 dev_dbg(dev, "ignoring DN %d from unconnected device %02x\n",
625 dn_hdr->bType, srcaddr);
626 return;
627 }
628
629 switch (dn_hdr->bType) { 611 switch (dn_hdr->bType) {
630 case WUSB_DN_CONNECT: 612 case WUSB_DN_CONNECT:
631 wusbhc_handle_dn_connect(wusbhc, dn_hdr, size); 613 wusbhc_handle_dn_connect(wusbhc, dn_hdr, size);
632 break; 614 break;
633 case WUSB_DN_ALIVE: 615 case WUSB_DN_ALIVE:
634 wusbhc_handle_dn_alive(wusbhc, wusb_dev); 616 wusbhc_handle_dn_alive(wusbhc, srcaddr);
635 break; 617 break;
636 case WUSB_DN_DISCONNECT: 618 case WUSB_DN_DISCONNECT:
637 wusbhc_handle_dn_disconnect(wusbhc, wusb_dev); 619 wusbhc_handle_dn_disconnect(wusbhc, srcaddr);
638 break; 620 break;
639 case WUSB_DN_MASAVAILCHANGED: 621 case WUSB_DN_MASAVAILCHANGED:
640 case WUSB_DN_RWAKE: 622 case WUSB_DN_RWAKE:
diff --git a/drivers/usb/wusbcore/security.c b/drivers/usb/wusbcore/security.c
index dd88441c8f78..4c40d0dbf53d 100644
--- a/drivers/usb/wusbcore/security.c
+++ b/drivers/usb/wusbcore/security.c
@@ -29,19 +29,16 @@
29#include <linux/export.h> 29#include <linux/export.h>
30#include "wusbhc.h" 30#include "wusbhc.h"
31 31
32static void wusbhc_set_gtk_callback(struct urb *urb); 32static void wusbhc_gtk_rekey_work(struct work_struct *work);
33static void wusbhc_gtk_rekey_done_work(struct work_struct *work);
34 33
35int wusbhc_sec_create(struct wusbhc *wusbhc) 34int wusbhc_sec_create(struct wusbhc *wusbhc)
36{ 35{
37 wusbhc->gtk.descr.bLength = sizeof(wusbhc->gtk.descr) + sizeof(wusbhc->gtk.data); 36 wusbhc->gtk.descr.bLength = sizeof(wusbhc->gtk.descr) + sizeof(wusbhc->gtk.data);
38 wusbhc->gtk.descr.bDescriptorType = USB_DT_KEY; 37 wusbhc->gtk.descr.bDescriptorType = USB_DT_KEY;
39 wusbhc->gtk.descr.bReserved = 0; 38 wusbhc->gtk.descr.bReserved = 0;
39 wusbhc->gtk_index = 0;
40 40
41 wusbhc->gtk_index = wusb_key_index(0, WUSB_KEY_INDEX_TYPE_GTK, 41 INIT_WORK(&wusbhc->gtk_rekey_work, wusbhc_gtk_rekey_work);
42 WUSB_KEY_INDEX_ORIGINATOR_HOST);
43
44 INIT_WORK(&wusbhc->gtk_rekey_done_work, wusbhc_gtk_rekey_done_work);
45 42
46 return 0; 43 return 0;
47} 44}
@@ -113,7 +110,7 @@ int wusbhc_sec_start(struct wusbhc *wusbhc)
113 wusbhc_generate_gtk(wusbhc); 110 wusbhc_generate_gtk(wusbhc);
114 111
115 result = wusbhc->set_gtk(wusbhc, wusbhc->gtk_tkid, 112 result = wusbhc->set_gtk(wusbhc, wusbhc->gtk_tkid,
116 &wusbhc->gtk.descr.bKeyData, key_size); 113 &wusbhc->gtk.descr.bKeyData, key_size);
117 if (result < 0) 114 if (result < 0)
118 dev_err(wusbhc->dev, "cannot set GTK for the host: %d\n", 115 dev_err(wusbhc->dev, "cannot set GTK for the host: %d\n",
119 result); 116 result);
@@ -129,7 +126,7 @@ int wusbhc_sec_start(struct wusbhc *wusbhc)
129 */ 126 */
130void wusbhc_sec_stop(struct wusbhc *wusbhc) 127void wusbhc_sec_stop(struct wusbhc *wusbhc)
131{ 128{
132 cancel_work_sync(&wusbhc->gtk_rekey_done_work); 129 cancel_work_sync(&wusbhc->gtk_rekey_work);
133} 130}
134 131
135 132
@@ -185,12 +182,14 @@ static int wusb_dev_set_encryption(struct usb_device *usb_dev, int value)
185static int wusb_dev_set_gtk(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev) 182static int wusb_dev_set_gtk(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev)
186{ 183{
187 struct usb_device *usb_dev = wusb_dev->usb_dev; 184 struct usb_device *usb_dev = wusb_dev->usb_dev;
185 u8 key_index = wusb_key_index(wusbhc->gtk_index,
186 WUSB_KEY_INDEX_TYPE_GTK, WUSB_KEY_INDEX_ORIGINATOR_HOST);
188 187
189 return usb_control_msg( 188 return usb_control_msg(
190 usb_dev, usb_sndctrlpipe(usb_dev, 0), 189 usb_dev, usb_sndctrlpipe(usb_dev, 0),
191 USB_REQ_SET_DESCRIPTOR, 190 USB_REQ_SET_DESCRIPTOR,
192 USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE, 191 USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
193 USB_DT_KEY << 8 | wusbhc->gtk_index, 0, 192 USB_DT_KEY << 8 | key_index, 0,
194 &wusbhc->gtk.descr, wusbhc->gtk.descr.bLength, 193 &wusbhc->gtk.descr, wusbhc->gtk.descr.bLength,
195 1000); 194 1000);
196} 195}
@@ -520,24 +519,55 @@ error_kzalloc:
520 * Once all connected and authenticated devices have received the new 519 * Once all connected and authenticated devices have received the new
521 * GTK, switch the host to using it. 520 * GTK, switch the host to using it.
522 */ 521 */
523static void wusbhc_gtk_rekey_done_work(struct work_struct *work) 522static void wusbhc_gtk_rekey_work(struct work_struct *work)
524{ 523{
525 struct wusbhc *wusbhc = container_of(work, struct wusbhc, gtk_rekey_done_work); 524 struct wusbhc *wusbhc = container_of(work,
525 struct wusbhc, gtk_rekey_work);
526 size_t key_size = sizeof(wusbhc->gtk.data); 526 size_t key_size = sizeof(wusbhc->gtk.data);
527 int port_idx;
528 struct wusb_dev *wusb_dev, *wusb_dev_next;
529 LIST_HEAD(rekey_list);
527 530
528 mutex_lock(&wusbhc->mutex); 531 mutex_lock(&wusbhc->mutex);
532 /* generate the new key */
533 wusbhc_generate_gtk(wusbhc);
534 /* roll the gtk index. */
535 wusbhc->gtk_index = (wusbhc->gtk_index + 1) % (WUSB_KEY_INDEX_MAX + 1);
536 /*
537 * Save all connected devices on a list while holding wusbhc->mutex and
538 * take a reference to each one. Then submit the set key request to
539 * them after releasing the lock in order to avoid a deadlock.
540 */
541 for (port_idx = 0; port_idx < wusbhc->ports_max; port_idx++) {
542 wusb_dev = wusbhc->port[port_idx].wusb_dev;
543 if (!wusb_dev || !wusb_dev->usb_dev
544 || !wusb_dev->usb_dev->authenticated)
545 continue;
529 546
530 if (--wusbhc->pending_set_gtks == 0) 547 wusb_dev_get(wusb_dev);
531 wusbhc->set_gtk(wusbhc, wusbhc->gtk_tkid, &wusbhc->gtk.descr.bKeyData, key_size); 548 list_add_tail(&wusb_dev->rekey_node, &rekey_list);
532 549 }
533 mutex_unlock(&wusbhc->mutex); 550 mutex_unlock(&wusbhc->mutex);
534}
535 551
536static void wusbhc_set_gtk_callback(struct urb *urb) 552 /* Submit the rekey requests without holding wusbhc->mutex. */
537{ 553 list_for_each_entry_safe(wusb_dev, wusb_dev_next, &rekey_list,
538 struct wusbhc *wusbhc = urb->context; 554 rekey_node) {
555 list_del_init(&wusb_dev->rekey_node);
556 dev_dbg(&wusb_dev->usb_dev->dev, "%s: rekey device at port %d\n",
557 __func__, wusb_dev->port_idx);
558
559 if (wusb_dev_set_gtk(wusbhc, wusb_dev) < 0) {
560 dev_err(&wusb_dev->usb_dev->dev, "%s: rekey device at port %d failed\n",
561 __func__, wusb_dev->port_idx);
562 }
563 wusb_dev_put(wusb_dev);
564 }
539 565
540 queue_work(wusbd, &wusbhc->gtk_rekey_done_work); 566 /* Switch the host controller to use the new GTK. */
567 mutex_lock(&wusbhc->mutex);
568 wusbhc->set_gtk(wusbhc, wusbhc->gtk_tkid,
569 &wusbhc->gtk.descr.bKeyData, key_size);
570 mutex_unlock(&wusbhc->mutex);
541} 571}
542 572
543/** 573/**
@@ -553,26 +583,12 @@ static void wusbhc_set_gtk_callback(struct urb *urb)
553 */ 583 */
554void wusbhc_gtk_rekey(struct wusbhc *wusbhc) 584void wusbhc_gtk_rekey(struct wusbhc *wusbhc)
555{ 585{
556 static const size_t key_size = sizeof(wusbhc->gtk.data); 586 /*
557 int p; 587 * We need to submit a URB to the downstream WUSB devices in order to
558 588 * change the group key. This can't be done while holding the
559 wusbhc_generate_gtk(wusbhc); 589 * wusbhc->mutex since that is also taken in the urb_enqueue routine
560 590 * and will cause a deadlock. Instead, queue a work item to do
561 for (p = 0; p < wusbhc->ports_max; p++) { 591 * it when the lock is not held
562 struct wusb_dev *wusb_dev; 592 */
563 593 queue_work(wusbd, &wusbhc->gtk_rekey_work);
564 wusb_dev = wusbhc->port[p].wusb_dev;
565 if (!wusb_dev || !wusb_dev->usb_dev || !wusb_dev->usb_dev->authenticated)
566 continue;
567
568 usb_fill_control_urb(wusb_dev->set_gtk_urb, wusb_dev->usb_dev,
569 usb_sndctrlpipe(wusb_dev->usb_dev, 0),
570 (void *)wusb_dev->set_gtk_req,
571 &wusbhc->gtk.descr, wusbhc->gtk.descr.bLength,
572 wusbhc_set_gtk_callback, wusbhc);
573 if (usb_submit_urb(wusb_dev->set_gtk_urb, GFP_KERNEL) == 0)
574 wusbhc->pending_set_gtks++;
575 }
576 if (wusbhc->pending_set_gtks == 0)
577 wusbhc->set_gtk(wusbhc, wusbhc->gtk_tkid, &wusbhc->gtk.descr.bKeyData, key_size);
578} 594}
diff --git a/drivers/usb/wusbcore/wusbhc.h b/drivers/usb/wusbcore/wusbhc.h
index 711b1952b114..6bd3b819a6b5 100644
--- a/drivers/usb/wusbcore/wusbhc.h
+++ b/drivers/usb/wusbcore/wusbhc.h
@@ -97,6 +97,7 @@ struct wusb_dev {
97 struct kref refcnt; 97 struct kref refcnt;
98 struct wusbhc *wusbhc; 98 struct wusbhc *wusbhc;
99 struct list_head cack_node; /* Connect-Ack list */ 99 struct list_head cack_node; /* Connect-Ack list */
100 struct list_head rekey_node; /* GTK rekey list */
100 u8 port_idx; 101 u8 port_idx;
101 u8 addr; 102 u8 addr;
102 u8 beacon_type:4; 103 u8 beacon_type:4;
@@ -107,8 +108,6 @@ struct wusb_dev {
107 struct usb_wireless_cap_descriptor *wusb_cap_descr; 108 struct usb_wireless_cap_descriptor *wusb_cap_descr;
108 struct uwb_mas_bm availability; 109 struct uwb_mas_bm availability;
109 struct work_struct devconnect_acked_work; 110 struct work_struct devconnect_acked_work;
110 struct urb *set_gtk_urb;
111 struct usb_ctrlrequest *set_gtk_req;
112 struct usb_device *usb_dev; 111 struct usb_device *usb_dev;
113}; 112};
114 113
@@ -296,8 +295,7 @@ struct wusbhc {
296 } __attribute__((packed)) gtk; 295 } __attribute__((packed)) gtk;
297 u8 gtk_index; 296 u8 gtk_index;
298 u32 gtk_tkid; 297 u32 gtk_tkid;
299 struct work_struct gtk_rekey_done_work; 298 struct work_struct gtk_rekey_work;
300 int pending_set_gtks;
301 299
302 struct usb_encryption_descriptor *ccm1_etd; 300 struct usb_encryption_descriptor *ccm1_etd;
303}; 301};