aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/class/cdc-acm.c3
-rw-r--r--drivers/usb/core/hub.c18
-rw-r--r--drivers/usb/core/quirks.c14
-rw-r--r--drivers/usb/dwc2/pci.c1
-rw-r--r--drivers/usb/dwc3/core.c1
-rw-r--r--drivers/usb/dwc3/dwc3-pci.c4
-rw-r--r--drivers/usb/dwc3/gadget.c8
-rw-r--r--drivers/usb/gadget/function/f_fs.c26
-rw-r--r--drivers/usb/host/xhci-histb.c6
-rw-r--r--drivers/usb/host/xhci-hub.c66
-rw-r--r--drivers/usb/host/xhci-mtk.c6
-rw-r--r--drivers/usb/host/xhci-pci.c6
-rw-r--r--drivers/usb/host/xhci-plat.c6
-rw-r--r--drivers/usb/host/xhci-ring.c45
-rw-r--r--drivers/usb/host/xhci-tegra.c1
-rw-r--r--drivers/usb/host/xhci.c2
-rw-r--r--drivers/usb/host/xhci.h3
-rw-r--r--drivers/usb/misc/appledisplay.c1
18 files changed, 162 insertions, 55 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 47d75c20c211..1b68fed464cb 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1696,6 +1696,9 @@ static const struct usb_device_id acm_ids[] = {
1696 { USB_DEVICE(0x0572, 0x1328), /* Shiro / Aztech USB MODEM UM-3100 */ 1696 { USB_DEVICE(0x0572, 0x1328), /* Shiro / Aztech USB MODEM UM-3100 */
1697 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1697 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1698 }, 1698 },
1699 { USB_DEVICE(0x0572, 0x1349), /* Hiro (Conexant) USB MODEM H50228 */
1700 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1701 },
1699 { USB_DEVICE(0x20df, 0x0001), /* Simtec Electronics Entropy Key */ 1702 { USB_DEVICE(0x20df, 0x0001), /* Simtec Electronics Entropy Key */
1700 .driver_info = QUIRK_CONTROL_LINE_STATE, }, 1703 .driver_info = QUIRK_CONTROL_LINE_STATE, },
1701 { USB_DEVICE(0x2184, 0x001c) }, /* GW Instek AFG-2225 */ 1704 { USB_DEVICE(0x2184, 0x001c) }, /* GW Instek AFG-2225 */
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index c6077d582d29..0f9381b69a3b 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2794,6 +2794,7 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
2794 int i, status; 2794 int i, status;
2795 u16 portchange, portstatus; 2795 u16 portchange, portstatus;
2796 struct usb_port *port_dev = hub->ports[port1 - 1]; 2796 struct usb_port *port_dev = hub->ports[port1 - 1];
2797 int reset_recovery_time;
2797 2798
2798 if (!hub_is_superspeed(hub->hdev)) { 2799 if (!hub_is_superspeed(hub->hdev)) {
2799 if (warm) { 2800 if (warm) {
@@ -2849,7 +2850,9 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
2849 USB_PORT_FEAT_C_BH_PORT_RESET); 2850 USB_PORT_FEAT_C_BH_PORT_RESET);
2850 usb_clear_port_feature(hub->hdev, port1, 2851 usb_clear_port_feature(hub->hdev, port1,
2851 USB_PORT_FEAT_C_PORT_LINK_STATE); 2852 USB_PORT_FEAT_C_PORT_LINK_STATE);
2852 usb_clear_port_feature(hub->hdev, port1, 2853
2854 if (udev)
2855 usb_clear_port_feature(hub->hdev, port1,
2853 USB_PORT_FEAT_C_CONNECTION); 2856 USB_PORT_FEAT_C_CONNECTION);
2854 2857
2855 /* 2858 /*
@@ -2885,11 +2888,18 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
2885 2888
2886done: 2889done:
2887 if (status == 0) { 2890 if (status == 0) {
2888 /* TRSTRCY = 10 ms; plus some extra */
2889 if (port_dev->quirks & USB_PORT_QUIRK_FAST_ENUM) 2891 if (port_dev->quirks & USB_PORT_QUIRK_FAST_ENUM)
2890 usleep_range(10000, 12000); 2892 usleep_range(10000, 12000);
2891 else 2893 else {
2892 msleep(10 + 40); 2894 /* TRSTRCY = 10 ms; plus some extra */
2895 reset_recovery_time = 10 + 40;
2896
2897 /* Hub needs extra delay after resetting its port. */
2898 if (hub->hdev->quirks & USB_QUIRK_HUB_SLOW_RESET)
2899 reset_recovery_time += 100;
2900
2901 msleep(reset_recovery_time);
2902 }
2893 2903
2894 if (udev) { 2904 if (udev) {
2895 struct usb_hcd *hcd = bus_to_hcd(udev->bus); 2905 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 178d6c6063c0..f9ff03e6af93 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -128,6 +128,9 @@ static int quirks_param_set(const char *val, const struct kernel_param *kp)
128 case 'n': 128 case 'n':
129 flags |= USB_QUIRK_DELAY_CTRL_MSG; 129 flags |= USB_QUIRK_DELAY_CTRL_MSG;
130 break; 130 break;
131 case 'o':
132 flags |= USB_QUIRK_HUB_SLOW_RESET;
133 break;
131 /* Ignore unrecognized flag characters */ 134 /* Ignore unrecognized flag characters */
132 } 135 }
133 } 136 }
@@ -380,6 +383,9 @@ static const struct usb_device_id usb_quirk_list[] = {
380 { USB_DEVICE(0x1a0a, 0x0200), .driver_info = 383 { USB_DEVICE(0x1a0a, 0x0200), .driver_info =
381 USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, 384 USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
382 385
386 /* Terminus Technology Inc. Hub */
387 { USB_DEVICE(0x1a40, 0x0101), .driver_info = USB_QUIRK_HUB_SLOW_RESET },
388
383 /* Corsair K70 RGB */ 389 /* Corsair K70 RGB */
384 { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT }, 390 { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT },
385 391
@@ -391,6 +397,9 @@ static const struct usb_device_id usb_quirk_list[] = {
391 { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT | 397 { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT |
392 USB_QUIRK_DELAY_CTRL_MSG }, 398 USB_QUIRK_DELAY_CTRL_MSG },
393 399
400 /* Corsair K70 LUX RGB */
401 { USB_DEVICE(0x1b1c, 0x1b33), .driver_info = USB_QUIRK_DELAY_INIT },
402
394 /* Corsair K70 LUX */ 403 /* Corsair K70 LUX */
395 { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT }, 404 { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT },
396 405
@@ -411,6 +420,11 @@ static const struct usb_device_id usb_quirk_list[] = {
411 { USB_DEVICE(0x2040, 0x7200), .driver_info = 420 { USB_DEVICE(0x2040, 0x7200), .driver_info =
412 USB_QUIRK_CONFIG_INTF_STRINGS }, 421 USB_QUIRK_CONFIG_INTF_STRINGS },
413 422
423 /* Raydium Touchscreen */
424 { USB_DEVICE(0x2386, 0x3114), .driver_info = USB_QUIRK_NO_LPM },
425
426 { USB_DEVICE(0x2386, 0x3119), .driver_info = USB_QUIRK_NO_LPM },
427
414 /* DJI CineSSD */ 428 /* DJI CineSSD */
415 { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM }, 429 { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },
416 430
diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c
index d257c541e51b..7afc10872f1f 100644
--- a/drivers/usb/dwc2/pci.c
+++ b/drivers/usb/dwc2/pci.c
@@ -120,6 +120,7 @@ static int dwc2_pci_probe(struct pci_dev *pci,
120 dwc2 = platform_device_alloc("dwc2", PLATFORM_DEVID_AUTO); 120 dwc2 = platform_device_alloc("dwc2", PLATFORM_DEVID_AUTO);
121 if (!dwc2) { 121 if (!dwc2) {
122 dev_err(dev, "couldn't allocate dwc2 device\n"); 122 dev_err(dev, "couldn't allocate dwc2 device\n");
123 ret = -ENOMEM;
123 goto err; 124 goto err;
124 } 125 }
125 126
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index becfbb87f791..2f2048aa5fde 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1499,6 +1499,7 @@ static int dwc3_probe(struct platform_device *pdev)
1499 1499
1500err5: 1500err5:
1501 dwc3_event_buffers_cleanup(dwc); 1501 dwc3_event_buffers_cleanup(dwc);
1502 dwc3_ulpi_exit(dwc);
1502 1503
1503err4: 1504err4:
1504 dwc3_free_scratch_buffers(dwc); 1505 dwc3_free_scratch_buffers(dwc);
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 1286076a8890..842795856bf4 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -283,8 +283,10 @@ err:
283static void dwc3_pci_remove(struct pci_dev *pci) 283static void dwc3_pci_remove(struct pci_dev *pci)
284{ 284{
285 struct dwc3_pci *dwc = pci_get_drvdata(pci); 285 struct dwc3_pci *dwc = pci_get_drvdata(pci);
286 struct pci_dev *pdev = dwc->pci;
286 287
287 gpiod_remove_lookup_table(&platform_bytcr_gpios); 288 if (pdev->device == PCI_DEVICE_ID_INTEL_BYT)
289 gpiod_remove_lookup_table(&platform_bytcr_gpios);
288#ifdef CONFIG_PM 290#ifdef CONFIG_PM
289 cancel_work_sync(&dwc->wakeup_work); 291 cancel_work_sync(&dwc->wakeup_work);
290#endif 292#endif
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 679c12e14522..9faad896b3a1 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1081,7 +1081,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
1081 /* Now prepare one extra TRB to align transfer size */ 1081 /* Now prepare one extra TRB to align transfer size */
1082 trb = &dep->trb_pool[dep->trb_enqueue]; 1082 trb = &dep->trb_pool[dep->trb_enqueue];
1083 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 1083 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr,
1084 maxp - rem, false, 0, 1084 maxp - rem, false, 1,
1085 req->request.stream_id, 1085 req->request.stream_id,
1086 req->request.short_not_ok, 1086 req->request.short_not_ok,
1087 req->request.no_interrupt); 1087 req->request.no_interrupt);
@@ -1125,7 +1125,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
1125 /* Now prepare one extra TRB to align transfer size */ 1125 /* Now prepare one extra TRB to align transfer size */
1126 trb = &dep->trb_pool[dep->trb_enqueue]; 1126 trb = &dep->trb_pool[dep->trb_enqueue];
1127 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp - rem, 1127 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp - rem,
1128 false, 0, req->request.stream_id, 1128 false, 1, req->request.stream_id,
1129 req->request.short_not_ok, 1129 req->request.short_not_ok,
1130 req->request.no_interrupt); 1130 req->request.no_interrupt);
1131 } else if (req->request.zero && req->request.length && 1131 } else if (req->request.zero && req->request.length &&
@@ -1141,7 +1141,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
1141 /* Now prepare one extra TRB to handle ZLP */ 1141 /* Now prepare one extra TRB to handle ZLP */
1142 trb = &dep->trb_pool[dep->trb_enqueue]; 1142 trb = &dep->trb_pool[dep->trb_enqueue];
1143 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0, 1143 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0,
1144 false, 0, req->request.stream_id, 1144 false, 1, req->request.stream_id,
1145 req->request.short_not_ok, 1145 req->request.short_not_ok,
1146 req->request.no_interrupt); 1146 req->request.no_interrupt);
1147 } else { 1147 } else {
@@ -2259,7 +2259,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
2259 * with one TRB pending in the ring. We need to manually clear HWO bit 2259 * with one TRB pending in the ring. We need to manually clear HWO bit
2260 * from that TRB. 2260 * from that TRB.
2261 */ 2261 */
2262 if ((req->zero || req->unaligned) && (trb->ctrl & DWC3_TRB_CTRL_HWO)) { 2262 if ((req->zero || req->unaligned) && !(trb->ctrl & DWC3_TRB_CTRL_CHN)) {
2263 trb->ctrl &= ~DWC3_TRB_CTRL_HWO; 2263 trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
2264 return 1; 2264 return 1;
2265 } 2265 }
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 3ada83d81bda..31e8bf3578c8 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -215,7 +215,6 @@ struct ffs_io_data {
215 215
216 struct mm_struct *mm; 216 struct mm_struct *mm;
217 struct work_struct work; 217 struct work_struct work;
218 struct work_struct cancellation_work;
219 218
220 struct usb_ep *ep; 219 struct usb_ep *ep;
221 struct usb_request *req; 220 struct usb_request *req;
@@ -1073,31 +1072,22 @@ ffs_epfile_open(struct inode *inode, struct file *file)
1073 return 0; 1072 return 0;
1074} 1073}
1075 1074
1076static void ffs_aio_cancel_worker(struct work_struct *work)
1077{
1078 struct ffs_io_data *io_data = container_of(work, struct ffs_io_data,
1079 cancellation_work);
1080
1081 ENTER();
1082
1083 usb_ep_dequeue(io_data->ep, io_data->req);
1084}
1085
1086static int ffs_aio_cancel(struct kiocb *kiocb) 1075static int ffs_aio_cancel(struct kiocb *kiocb)
1087{ 1076{
1088 struct ffs_io_data *io_data = kiocb->private; 1077 struct ffs_io_data *io_data = kiocb->private;
1089 struct ffs_data *ffs = io_data->ffs; 1078 struct ffs_epfile *epfile = kiocb->ki_filp->private_data;
1090 int value; 1079 int value;
1091 1080
1092 ENTER(); 1081 ENTER();
1093 1082
1094 if (likely(io_data && io_data->ep && io_data->req)) { 1083 spin_lock_irq(&epfile->ffs->eps_lock);
1095 INIT_WORK(&io_data->cancellation_work, ffs_aio_cancel_worker); 1084
1096 queue_work(ffs->io_completion_wq, &io_data->cancellation_work); 1085 if (likely(io_data && io_data->ep && io_data->req))
1097 value = -EINPROGRESS; 1086 value = usb_ep_dequeue(io_data->ep, io_data->req);
1098 } else { 1087 else
1099 value = -EINVAL; 1088 value = -EINVAL;
1100 } 1089
1090 spin_unlock_irq(&epfile->ffs->eps_lock);
1101 1091
1102 return value; 1092 return value;
1103} 1093}
diff --git a/drivers/usb/host/xhci-histb.c b/drivers/usb/host/xhci-histb.c
index 27f00160332e..3c4abb5a1c3f 100644
--- a/drivers/usb/host/xhci-histb.c
+++ b/drivers/usb/host/xhci-histb.c
@@ -325,14 +325,16 @@ static int xhci_histb_remove(struct platform_device *dev)
325 struct xhci_hcd_histb *histb = platform_get_drvdata(dev); 325 struct xhci_hcd_histb *histb = platform_get_drvdata(dev);
326 struct usb_hcd *hcd = histb->hcd; 326 struct usb_hcd *hcd = histb->hcd;
327 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 327 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
328 struct usb_hcd *shared_hcd = xhci->shared_hcd;
328 329
329 xhci->xhc_state |= XHCI_STATE_REMOVING; 330 xhci->xhc_state |= XHCI_STATE_REMOVING;
330 331
331 usb_remove_hcd(xhci->shared_hcd); 332 usb_remove_hcd(shared_hcd);
333 xhci->shared_hcd = NULL;
332 device_wakeup_disable(&dev->dev); 334 device_wakeup_disable(&dev->dev);
333 335
334 usb_remove_hcd(hcd); 336 usb_remove_hcd(hcd);
335 usb_put_hcd(xhci->shared_hcd); 337 usb_put_hcd(shared_hcd);
336 338
337 xhci_histb_host_disable(histb); 339 xhci_histb_host_disable(histb);
338 usb_put_hcd(hcd); 340 usb_put_hcd(hcd);
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 12eea73d9f20..94aca1b5ac8a 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -876,7 +876,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
876 status |= USB_PORT_STAT_SUSPEND; 876 status |= USB_PORT_STAT_SUSPEND;
877 } 877 }
878 if ((raw_port_status & PORT_PLS_MASK) == XDEV_RESUME && 878 if ((raw_port_status & PORT_PLS_MASK) == XDEV_RESUME &&
879 !DEV_SUPERSPEED_ANY(raw_port_status)) { 879 !DEV_SUPERSPEED_ANY(raw_port_status) && hcd->speed < HCD_USB3) {
880 if ((raw_port_status & PORT_RESET) || 880 if ((raw_port_status & PORT_RESET) ||
881 !(raw_port_status & PORT_PE)) 881 !(raw_port_status & PORT_PE))
882 return 0xffffffff; 882 return 0xffffffff;
@@ -921,7 +921,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
921 time_left = wait_for_completion_timeout( 921 time_left = wait_for_completion_timeout(
922 &bus_state->rexit_done[wIndex], 922 &bus_state->rexit_done[wIndex],
923 msecs_to_jiffies( 923 msecs_to_jiffies(
924 XHCI_MAX_REXIT_TIMEOUT)); 924 XHCI_MAX_REXIT_TIMEOUT_MS));
925 spin_lock_irqsave(&xhci->lock, flags); 925 spin_lock_irqsave(&xhci->lock, flags);
926 926
927 if (time_left) { 927 if (time_left) {
@@ -935,7 +935,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
935 } else { 935 } else {
936 int port_status = readl(port->addr); 936 int port_status = readl(port->addr);
937 xhci_warn(xhci, "Port resume took longer than %i msec, port status = 0x%x\n", 937 xhci_warn(xhci, "Port resume took longer than %i msec, port status = 0x%x\n",
938 XHCI_MAX_REXIT_TIMEOUT, 938 XHCI_MAX_REXIT_TIMEOUT_MS,
939 port_status); 939 port_status);
940 status |= USB_PORT_STAT_SUSPEND; 940 status |= USB_PORT_STAT_SUSPEND;
941 clear_bit(wIndex, &bus_state->rexit_ports); 941 clear_bit(wIndex, &bus_state->rexit_ports);
@@ -1474,15 +1474,18 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
1474 unsigned long flags; 1474 unsigned long flags;
1475 struct xhci_hub *rhub; 1475 struct xhci_hub *rhub;
1476 struct xhci_port **ports; 1476 struct xhci_port **ports;
1477 u32 portsc_buf[USB_MAXCHILDREN];
1478 bool wake_enabled;
1477 1479
1478 rhub = xhci_get_rhub(hcd); 1480 rhub = xhci_get_rhub(hcd);
1479 ports = rhub->ports; 1481 ports = rhub->ports;
1480 max_ports = rhub->num_ports; 1482 max_ports = rhub->num_ports;
1481 bus_state = &xhci->bus_state[hcd_index(hcd)]; 1483 bus_state = &xhci->bus_state[hcd_index(hcd)];
1484 wake_enabled = hcd->self.root_hub->do_remote_wakeup;
1482 1485
1483 spin_lock_irqsave(&xhci->lock, flags); 1486 spin_lock_irqsave(&xhci->lock, flags);
1484 1487
1485 if (hcd->self.root_hub->do_remote_wakeup) { 1488 if (wake_enabled) {
1486 if (bus_state->resuming_ports || /* USB2 */ 1489 if (bus_state->resuming_ports || /* USB2 */
1487 bus_state->port_remote_wakeup) { /* USB3 */ 1490 bus_state->port_remote_wakeup) { /* USB3 */
1488 spin_unlock_irqrestore(&xhci->lock, flags); 1491 spin_unlock_irqrestore(&xhci->lock, flags);
@@ -1490,26 +1493,36 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
1490 return -EBUSY; 1493 return -EBUSY;
1491 } 1494 }
1492 } 1495 }
1493 1496 /*
1494 port_index = max_ports; 1497 * Prepare ports for suspend, but don't write anything before all ports
1498 * are checked and we know bus suspend can proceed
1499 */
1495 bus_state->bus_suspended = 0; 1500 bus_state->bus_suspended = 0;
1501 port_index = max_ports;
1496 while (port_index--) { 1502 while (port_index--) {
1497 /* suspend the port if the port is not suspended */
1498 u32 t1, t2; 1503 u32 t1, t2;
1499 int slot_id;
1500 1504
1501 t1 = readl(ports[port_index]->addr); 1505 t1 = readl(ports[port_index]->addr);
1502 t2 = xhci_port_state_to_neutral(t1); 1506 t2 = xhci_port_state_to_neutral(t1);
1507 portsc_buf[port_index] = 0;
1503 1508
1504 if ((t1 & PORT_PE) && !(t1 & PORT_PLS_MASK)) { 1509 /* Bail out if a USB3 port has a new device in link training */
1505 xhci_dbg(xhci, "port %d not suspended\n", port_index); 1510 if ((t1 & PORT_PLS_MASK) == XDEV_POLLING) {
1506 slot_id = xhci_find_slot_id_by_port(hcd, xhci, 1511 bus_state->bus_suspended = 0;
1507 port_index + 1); 1512 spin_unlock_irqrestore(&xhci->lock, flags);
1508 if (slot_id) { 1513 xhci_dbg(xhci, "Bus suspend bailout, port in polling\n");
1514 return -EBUSY;
1515 }
1516
1517 /* suspend ports in U0, or bail out for new connect changes */
1518 if ((t1 & PORT_PE) && (t1 & PORT_PLS_MASK) == XDEV_U0) {
1519 if ((t1 & PORT_CSC) && wake_enabled) {
1520 bus_state->bus_suspended = 0;
1509 spin_unlock_irqrestore(&xhci->lock, flags); 1521 spin_unlock_irqrestore(&xhci->lock, flags);
1510 xhci_stop_device(xhci, slot_id, 1); 1522 xhci_dbg(xhci, "Bus suspend bailout, port connect change\n");
1511 spin_lock_irqsave(&xhci->lock, flags); 1523 return -EBUSY;
1512 } 1524 }
1525 xhci_dbg(xhci, "port %d not suspended\n", port_index);
1513 t2 &= ~PORT_PLS_MASK; 1526 t2 &= ~PORT_PLS_MASK;
1514 t2 |= PORT_LINK_STROBE | XDEV_U3; 1527 t2 |= PORT_LINK_STROBE | XDEV_U3;
1515 set_bit(port_index, &bus_state->bus_suspended); 1528 set_bit(port_index, &bus_state->bus_suspended);
@@ -1518,7 +1531,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
1518 * including the USB 3.0 roothub, but only if CONFIG_PM 1531 * including the USB 3.0 roothub, but only if CONFIG_PM
1519 * is enabled, so also enable remote wake here. 1532 * is enabled, so also enable remote wake here.
1520 */ 1533 */
1521 if (hcd->self.root_hub->do_remote_wakeup) { 1534 if (wake_enabled) {
1522 if (t1 & PORT_CONNECT) { 1535 if (t1 & PORT_CONNECT) {
1523 t2 |= PORT_WKOC_E | PORT_WKDISC_E; 1536 t2 |= PORT_WKOC_E | PORT_WKDISC_E;
1524 t2 &= ~PORT_WKCONN_E; 1537 t2 &= ~PORT_WKCONN_E;
@@ -1538,7 +1551,26 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
1538 1551
1539 t1 = xhci_port_state_to_neutral(t1); 1552 t1 = xhci_port_state_to_neutral(t1);
1540 if (t1 != t2) 1553 if (t1 != t2)
1541 writel(t2, ports[port_index]->addr); 1554 portsc_buf[port_index] = t2;
1555 }
1556
1557 /* write port settings, stopping and suspending ports if needed */
1558 port_index = max_ports;
1559 while (port_index--) {
1560 if (!portsc_buf[port_index])
1561 continue;
1562 if (test_bit(port_index, &bus_state->bus_suspended)) {
1563 int slot_id;
1564
1565 slot_id = xhci_find_slot_id_by_port(hcd, xhci,
1566 port_index + 1);
1567 if (slot_id) {
1568 spin_unlock_irqrestore(&xhci->lock, flags);
1569 xhci_stop_device(xhci, slot_id, 1);
1570 spin_lock_irqsave(&xhci->lock, flags);
1571 }
1572 }
1573 writel(portsc_buf[port_index], ports[port_index]->addr);
1542 } 1574 }
1543 hcd->state = HC_STATE_SUSPENDED; 1575 hcd->state = HC_STATE_SUSPENDED;
1544 bus_state->next_statechange = jiffies + msecs_to_jiffies(10); 1576 bus_state->next_statechange = jiffies + msecs_to_jiffies(10);
diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 71d0d33c3286..60987c787e44 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -590,12 +590,14 @@ static int xhci_mtk_remove(struct platform_device *dev)
590 struct xhci_hcd_mtk *mtk = platform_get_drvdata(dev); 590 struct xhci_hcd_mtk *mtk = platform_get_drvdata(dev);
591 struct usb_hcd *hcd = mtk->hcd; 591 struct usb_hcd *hcd = mtk->hcd;
592 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 592 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
593 struct usb_hcd *shared_hcd = xhci->shared_hcd;
593 594
594 usb_remove_hcd(xhci->shared_hcd); 595 usb_remove_hcd(shared_hcd);
596 xhci->shared_hcd = NULL;
595 device_init_wakeup(&dev->dev, false); 597 device_init_wakeup(&dev->dev, false);
596 598
597 usb_remove_hcd(hcd); 599 usb_remove_hcd(hcd);
598 usb_put_hcd(xhci->shared_hcd); 600 usb_put_hcd(shared_hcd);
599 usb_put_hcd(hcd); 601 usb_put_hcd(hcd);
600 xhci_mtk_sch_exit(mtk); 602 xhci_mtk_sch_exit(mtk);
601 xhci_mtk_clks_disable(mtk); 603 xhci_mtk_clks_disable(mtk);
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 01c57055c0c5..a9515265db4d 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -248,6 +248,11 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
248 if (pdev->vendor == PCI_VENDOR_ID_TI && pdev->device == 0x8241) 248 if (pdev->vendor == PCI_VENDOR_ID_TI && pdev->device == 0x8241)
249 xhci->quirks |= XHCI_LIMIT_ENDPOINT_INTERVAL_7; 249 xhci->quirks |= XHCI_LIMIT_ENDPOINT_INTERVAL_7;
250 250
251 if ((pdev->vendor == PCI_VENDOR_ID_BROADCOM ||
252 pdev->vendor == PCI_VENDOR_ID_CAVIUM) &&
253 pdev->device == 0x9026)
254 xhci->quirks |= XHCI_RESET_PLL_ON_DISCONNECT;
255
251 if (xhci->quirks & XHCI_RESET_ON_RESUME) 256 if (xhci->quirks & XHCI_RESET_ON_RESUME)
252 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, 257 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
253 "QUIRK: Resetting on resume"); 258 "QUIRK: Resetting on resume");
@@ -380,6 +385,7 @@ static void xhci_pci_remove(struct pci_dev *dev)
380 if (xhci->shared_hcd) { 385 if (xhci->shared_hcd) {
381 usb_remove_hcd(xhci->shared_hcd); 386 usb_remove_hcd(xhci->shared_hcd);
382 usb_put_hcd(xhci->shared_hcd); 387 usb_put_hcd(xhci->shared_hcd);
388 xhci->shared_hcd = NULL;
383 } 389 }
384 390
385 /* Workaround for spurious wakeups at shutdown with HSW */ 391 /* Workaround for spurious wakeups at shutdown with HSW */
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 32b5574ad5c5..ef09cb06212f 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -362,14 +362,16 @@ static int xhci_plat_remove(struct platform_device *dev)
362 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 362 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
363 struct clk *clk = xhci->clk; 363 struct clk *clk = xhci->clk;
364 struct clk *reg_clk = xhci->reg_clk; 364 struct clk *reg_clk = xhci->reg_clk;
365 struct usb_hcd *shared_hcd = xhci->shared_hcd;
365 366
366 xhci->xhc_state |= XHCI_STATE_REMOVING; 367 xhci->xhc_state |= XHCI_STATE_REMOVING;
367 368
368 usb_remove_hcd(xhci->shared_hcd); 369 usb_remove_hcd(shared_hcd);
370 xhci->shared_hcd = NULL;
369 usb_phy_shutdown(hcd->usb_phy); 371 usb_phy_shutdown(hcd->usb_phy);
370 372
371 usb_remove_hcd(hcd); 373 usb_remove_hcd(hcd);
372 usb_put_hcd(xhci->shared_hcd); 374 usb_put_hcd(shared_hcd);
373 375
374 clk_disable_unprepare(clk); 376 clk_disable_unprepare(clk);
375 clk_disable_unprepare(reg_clk); 377 clk_disable_unprepare(reg_clk);
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index a8d92c90fb58..65750582133f 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1521,6 +1521,35 @@ static void handle_device_notification(struct xhci_hcd *xhci,
1521 usb_wakeup_notification(udev->parent, udev->portnum); 1521 usb_wakeup_notification(udev->parent, udev->portnum);
1522} 1522}
1523 1523
1524/*
1525 * Quirk hanlder for errata seen on Cavium ThunderX2 processor XHCI
1526 * Controller.
1527 * As per ThunderX2errata-129 USB 2 device may come up as USB 1
1528 * If a connection to a USB 1 device is followed by another connection
1529 * to a USB 2 device.
1530 *
1531 * Reset the PHY after the USB device is disconnected if device speed
1532 * is less than HCD_USB3.
1533 * Retry the reset sequence max of 4 times checking the PLL lock status.
1534 *
1535 */
1536static void xhci_cavium_reset_phy_quirk(struct xhci_hcd *xhci)
1537{
1538 struct usb_hcd *hcd = xhci_to_hcd(xhci);
1539 u32 pll_lock_check;
1540 u32 retry_count = 4;
1541
1542 do {
1543 /* Assert PHY reset */
1544 writel(0x6F, hcd->regs + 0x1048);
1545 udelay(10);
1546 /* De-assert the PHY reset */
1547 writel(0x7F, hcd->regs + 0x1048);
1548 udelay(200);
1549 pll_lock_check = readl(hcd->regs + 0x1070);
1550 } while (!(pll_lock_check & 0x1) && --retry_count);
1551}
1552
1524static void handle_port_status(struct xhci_hcd *xhci, 1553static void handle_port_status(struct xhci_hcd *xhci,
1525 union xhci_trb *event) 1554 union xhci_trb *event)
1526{ 1555{
@@ -1556,6 +1585,13 @@ static void handle_port_status(struct xhci_hcd *xhci,
1556 goto cleanup; 1585 goto cleanup;
1557 } 1586 }
1558 1587
1588 /* We might get interrupts after shared_hcd is removed */
1589 if (port->rhub == &xhci->usb3_rhub && xhci->shared_hcd == NULL) {
1590 xhci_dbg(xhci, "ignore port event for removed USB3 hcd\n");
1591 bogus_port_status = true;
1592 goto cleanup;
1593 }
1594
1559 hcd = port->rhub->hcd; 1595 hcd = port->rhub->hcd;
1560 bus_state = &xhci->bus_state[hcd_index(hcd)]; 1596 bus_state = &xhci->bus_state[hcd_index(hcd)];
1561 hcd_portnum = port->hcd_portnum; 1597 hcd_portnum = port->hcd_portnum;
@@ -1639,7 +1675,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
1639 * RExit to a disconnect state). If so, let the the driver know it's 1675 * RExit to a disconnect state). If so, let the the driver know it's
1640 * out of the RExit state. 1676 * out of the RExit state.
1641 */ 1677 */
1642 if (!DEV_SUPERSPEED_ANY(portsc) && 1678 if (!DEV_SUPERSPEED_ANY(portsc) && hcd->speed < HCD_USB3 &&
1643 test_and_clear_bit(hcd_portnum, 1679 test_and_clear_bit(hcd_portnum,
1644 &bus_state->rexit_ports)) { 1680 &bus_state->rexit_ports)) {
1645 complete(&bus_state->rexit_done[hcd_portnum]); 1681 complete(&bus_state->rexit_done[hcd_portnum]);
@@ -1647,8 +1683,12 @@ static void handle_port_status(struct xhci_hcd *xhci,
1647 goto cleanup; 1683 goto cleanup;
1648 } 1684 }
1649 1685
1650 if (hcd->speed < HCD_USB3) 1686 if (hcd->speed < HCD_USB3) {
1651 xhci_test_and_clear_bit(xhci, port, PORT_PLC); 1687 xhci_test_and_clear_bit(xhci, port, PORT_PLC);
1688 if ((xhci->quirks & XHCI_RESET_PLL_ON_DISCONNECT) &&
1689 (portsc & PORT_CSC) && !(portsc & PORT_CONNECT))
1690 xhci_cavium_reset_phy_quirk(xhci);
1691 }
1652 1692
1653cleanup: 1693cleanup:
1654 /* Update event ring dequeue pointer before dropping the lock */ 1694 /* Update event ring dequeue pointer before dropping the lock */
@@ -2266,6 +2306,7 @@ static int handle_tx_event(struct xhci_hcd *xhci,
2266 goto cleanup; 2306 goto cleanup;
2267 case COMP_RING_UNDERRUN: 2307 case COMP_RING_UNDERRUN:
2268 case COMP_RING_OVERRUN: 2308 case COMP_RING_OVERRUN:
2309 case COMP_STOPPED_LENGTH_INVALID:
2269 goto cleanup; 2310 goto cleanup;
2270 default: 2311 default:
2271 xhci_err(xhci, "ERROR Transfer event for unknown stream ring slot %u ep %u\n", 2312 xhci_err(xhci, "ERROR Transfer event for unknown stream ring slot %u ep %u\n",
diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
index 6b5db344de30..938ff06c0349 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -1303,6 +1303,7 @@ static int tegra_xusb_remove(struct platform_device *pdev)
1303 1303
1304 usb_remove_hcd(xhci->shared_hcd); 1304 usb_remove_hcd(xhci->shared_hcd);
1305 usb_put_hcd(xhci->shared_hcd); 1305 usb_put_hcd(xhci->shared_hcd);
1306 xhci->shared_hcd = NULL;
1306 usb_remove_hcd(tegra->hcd); 1307 usb_remove_hcd(tegra->hcd);
1307 usb_put_hcd(tegra->hcd); 1308 usb_put_hcd(tegra->hcd);
1308 1309
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 0420eefa647a..c928dbbff881 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -719,8 +719,6 @@ static void xhci_stop(struct usb_hcd *hcd)
719 719
720 /* Only halt host and free memory after both hcds are removed */ 720 /* Only halt host and free memory after both hcds are removed */
721 if (!usb_hcd_is_primary_hcd(hcd)) { 721 if (!usb_hcd_is_primary_hcd(hcd)) {
722 /* usb core will free this hcd shortly, unset pointer */
723 xhci->shared_hcd = NULL;
724 mutex_unlock(&xhci->mutex); 722 mutex_unlock(&xhci->mutex);
725 return; 723 return;
726 } 724 }
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index bf0b3692dc9a..260b259b72bc 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1680,7 +1680,7 @@ struct xhci_bus_state {
1680 * It can take up to 20 ms to transition from RExit to U0 on the 1680 * It can take up to 20 ms to transition from RExit to U0 on the
1681 * Intel Lynx Point LP xHCI host. 1681 * Intel Lynx Point LP xHCI host.
1682 */ 1682 */
1683#define XHCI_MAX_REXIT_TIMEOUT (20 * 1000) 1683#define XHCI_MAX_REXIT_TIMEOUT_MS 20
1684 1684
1685static inline unsigned int hcd_index(struct usb_hcd *hcd) 1685static inline unsigned int hcd_index(struct usb_hcd *hcd)
1686{ 1686{
@@ -1849,6 +1849,7 @@ struct xhci_hcd {
1849#define XHCI_INTEL_USB_ROLE_SW BIT_ULL(31) 1849#define XHCI_INTEL_USB_ROLE_SW BIT_ULL(31)
1850#define XHCI_ZERO_64B_REGS BIT_ULL(32) 1850#define XHCI_ZERO_64B_REGS BIT_ULL(32)
1851#define XHCI_DEFAULT_PM_RUNTIME_ALLOW BIT_ULL(33) 1851#define XHCI_DEFAULT_PM_RUNTIME_ALLOW BIT_ULL(33)
1852#define XHCI_RESET_PLL_ON_DISCONNECT BIT_ULL(34)
1852 1853
1853 unsigned int num_active_eps; 1854 unsigned int num_active_eps;
1854 unsigned int limit_active_eps; 1855 unsigned int limit_active_eps;
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index bd539f3058bc..85b48c6ddc7e 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -50,6 +50,7 @@ static const struct usb_device_id appledisplay_table[] = {
50 { APPLEDISPLAY_DEVICE(0x9219) }, 50 { APPLEDISPLAY_DEVICE(0x9219) },
51 { APPLEDISPLAY_DEVICE(0x921c) }, 51 { APPLEDISPLAY_DEVICE(0x921c) },
52 { APPLEDISPLAY_DEVICE(0x921d) }, 52 { APPLEDISPLAY_DEVICE(0x921d) },
53 { APPLEDISPLAY_DEVICE(0x9222) },
53 { APPLEDISPLAY_DEVICE(0x9236) }, 54 { APPLEDISPLAY_DEVICE(0x9236) },
54 55
55 /* Terminating entry */ 56 /* Terminating entry */