Merge tag 'usb-3.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
"Here are a number of USB driver fixes for 3.12-rc3.

These are all for host controller issues that have been reported, and
there's a fix for an annoying error message that gets printed every
time you remove a USB 3 device from the system that's been bugging me
for a while"

* tag 'usb-3.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
usb: dwc3: add support for Merrifield
USB: fsl/ehci: fix failure of checking PHY_CLK_VALID during reinitialization
USB: Fix breakage in ffs_fs_mount()
fsl/usb: Resolve PHY_CLK_VLD instability issue for ULPI phy
usb/core/devio.c: Don't reject control message to endpoint with wrong direction bit
usb: chipidea: USB_CHIPIDEA should depend on HAS_DMA
usb: chipidea: udc: free pending TD at removal procedure
usb: chipidea: imx: Add usb_phy_shutdown at probe's error path
usb: chipidea: Fix memleak for ci->hw_bank.regmap when removal
usb: chipidea: udc: fix the oops after rmmod gadget
USB: fix PM config symbol in uhci-hcd, ehci-hcd, and xhci-hcd
USB: OHCI: accept very late isochronous URBs
USB: UHCI: accept very late isochronous URBs
USB: iMX21: accept very late isochronous URBs
usbcore: check usb device's state before sending a Set SEL control transfer
xhci: Fix race between ep halt and URB cancellation
usb: Fix xHCI host issues on remote wakeup.
xhci: Ensure a command structure points to the correct trb on the command ring
xhci: Fix oops happening after address device timeout

+1 -1
drivers/usb/chipidea/Kconfig
··· 1 1 config USB_CHIPIDEA 2 2 tristate "ChipIdea Highspeed Dual Role Controller" 3 - depends on (USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && !USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET) 3 + depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && !USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA 4 4 help 5 5 Say Y here if your system has a dual role high speed USB 6 6 controller based on ChipIdea silicon IP. Currently, only the
+5 -2
drivers/usb/chipidea/ci_hdrc_imx.c
··· 131 131 if (ret) { 132 132 dev_err(&pdev->dev, "usbmisc init failed, ret=%d\n", 133 133 ret); 134 - goto err_clk; 134 + goto err_phy; 135 135 } 136 136 } 137 137 ··· 143 143 dev_err(&pdev->dev, 144 144 "Can't register ci_hdrc platform device, err=%d\n", 145 145 ret); 146 - goto err_clk; 146 + goto err_phy; 147 147 } 148 148 149 149 if (data->usbmisc_data) { ··· 164 164 165 165 disable_device: 166 166 ci_hdrc_remove_device(data->ci_pdev); 167 + err_phy: 168 + if (data->phy) 169 + usb_phy_shutdown(data->phy); 167 170 err_clk: 168 171 clk_disable_unprepare(data->clk); 169 172 return ret;
+1
drivers/usb/chipidea/core.c
··· 605 605 dbg_remove_files(ci); 606 606 free_irq(ci->irq, ci); 607 607 ci_role_destroy(ci); 608 + kfree(ci->hw_bank.regmap); 608 609 609 610 return 0; 610 611 }
+3 -1
drivers/usb/chipidea/udc.c
··· 1600 1600 for (i = 0; i < ci->hw_ep_max; i++) { 1601 1601 struct ci_hw_ep *hwep = &ci->ci_hw_ep[i]; 1602 1602 1603 + if (hwep->pending_td) 1604 + free_pending_td(hwep); 1603 1605 dma_pool_free(ci->qh_pool, hwep->qh.ptr, hwep->qh.dma); 1604 1606 } 1605 1607 } ··· 1669 1667 if (ci->platdata->notify_event) 1670 1668 ci->platdata->notify_event(ci, 1671 1669 CI_HDRC_CONTROLLER_STOPPED_EVENT); 1672 - ci->driver = NULL; 1673 1670 spin_unlock_irqrestore(&ci->lock, flags); 1674 1671 _gadget_stop_activity(&ci->gadget); 1675 1672 spin_lock_irqsave(&ci->lock, flags); 1676 1673 pm_runtime_put(&ci->gadget.dev); 1677 1674 } 1678 1675 1676 + ci->driver = NULL; 1679 1677 spin_unlock_irqrestore(&ci->lock, flags); 1680 1678 1681 1679 return 0;
+16
drivers/usb/core/devio.c
··· 742 742 if ((index & ~USB_DIR_IN) == 0) 743 743 return 0; 744 744 ret = findintfep(ps->dev, index); 745 + if (ret < 0) { 746 + /* 747 + * Some not fully compliant Win apps seem to get 748 + * index wrong and have the endpoint number here 749 + * rather than the endpoint address (with the 750 + * correct direction). Win does let this through, 751 + * so we'll not reject it here but leave it to 752 + * the device to not break KVM. But we warn. 753 + */ 754 + ret = findintfep(ps->dev, index ^ 0x80); 755 + if (ret >= 0) 756 + dev_info(&ps->dev->dev, 757 + "%s: process %i (%s) requesting ep %02x but needs %02x\n", 758 + __func__, task_pid_nr(current), 759 + current->comm, index, index ^ 0x80); 760 + } 745 761 if (ret >= 0) 746 762 ret = checkintf(ps, ret); 747 763 break;
+3
drivers/usb/core/hub.c
··· 3426 3426 unsigned long long u2_pel; 3427 3427 int ret; 3428 3428 3429 + if (udev->state != USB_STATE_CONFIGURED) 3430 + return 0; 3431 + 3429 3432 /* Convert SEL and PEL stored in ns to us */ 3430 3433 u1_sel = DIV_ROUND_UP(udev->u1_params.sel, 1000); 3431 3434 u1_pel = DIV_ROUND_UP(udev->u1_params.pel, 1000);
+2
drivers/usb/dwc3/dwc3-pci.c
··· 29 29 #define PCI_VENDOR_ID_SYNOPSYS 0x16c3 30 30 #define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 0xabcd 31 31 #define PCI_DEVICE_ID_INTEL_BYT 0x0f37 32 + #define PCI_DEVICE_ID_INTEL_MRFLD 0x119e 32 33 33 34 struct dwc3_pci { 34 35 struct device *dev; ··· 190 189 PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3), 191 190 }, 192 191 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT), }, 192 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MRFLD), }, 193 193 { } /* Terminating Entry */ 194 194 }; 195 195 MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table);
+26 -34
drivers/usb/gadget/f_fs.c
··· 1034 1034 struct ffs_file_perms perms; 1035 1035 umode_t root_mode; 1036 1036 const char *dev_name; 1037 - union { 1038 - /* set by ffs_fs_mount(), read by ffs_sb_fill() */ 1039 - void *private_data; 1040 - /* set by ffs_sb_fill(), read by ffs_fs_mount */ 1041 - struct ffs_data *ffs_data; 1042 - }; 1037 + struct ffs_data *ffs_data; 1043 1038 }; 1044 1039 1045 1040 static int ffs_sb_fill(struct super_block *sb, void *_data, int silent) 1046 1041 { 1047 1042 struct ffs_sb_fill_data *data = _data; 1048 1043 struct inode *inode; 1049 - struct ffs_data *ffs; 1044 + struct ffs_data *ffs = data->ffs_data; 1050 1045 1051 1046 ENTER(); 1052 1047 1053 - /* Initialise data */ 1054 - ffs = ffs_data_new(); 1055 - if (unlikely(!ffs)) 1056 - goto Enomem; 1057 - 1058 1048 ffs->sb = sb; 1059 - ffs->dev_name = kstrdup(data->dev_name, GFP_KERNEL); 1060 - if (unlikely(!ffs->dev_name)) 1061 - goto Enomem; 1062 - ffs->file_perms = data->perms; 1063 - ffs->private_data = data->private_data; 1064 - 1065 - /* used by the caller of this function */ 1066 - data->ffs_data = ffs; 1067 - 1049 + data->ffs_data = NULL; 1068 1050 sb->s_fs_info = ffs; 1069 1051 sb->s_blocksize = PAGE_CACHE_SIZE; 1070 1052 sb->s_blocksize_bits = PAGE_CACHE_SHIFT; ··· 1062 1080 &data->perms); 1063 1081 sb->s_root = d_make_root(inode); 1064 1082 if (unlikely(!sb->s_root)) 1065 - goto Enomem; 1083 + return -ENOMEM; 1066 1084 1067 1085 /* EP0 file */ 1068 1086 if (unlikely(!ffs_sb_create_file(sb, "ep0", ffs, 1069 1087 &ffs_ep0_operations, NULL))) 1070 - goto Enomem; 1088 + return -ENOMEM; 1071 1089 1072 1090 return 0; 1073 - 1074 - Enomem: 1075 - return -ENOMEM; 1076 1091 } 1077 1092 1078 1093 static int ffs_fs_parse_opts(struct ffs_sb_fill_data *data, char *opts) ··· 1172 1193 struct dentry *rv; 1173 1194 int ret; 1174 1195 void *ffs_dev; 1196 + struct ffs_data *ffs; 1175 1197 1176 1198 ENTER(); 1177 1199 ··· 1180 1200 if (unlikely(ret < 0)) 1181 1201 return ERR_PTR(ret); 1182 1202 1203 + ffs = ffs_data_new(); 1204 + if (unlikely(!ffs)) 1205 + return ERR_PTR(-ENOMEM); 1206 + ffs->file_perms = data.perms; 1207 + 1208 + ffs->dev_name = kstrdup(dev_name, GFP_KERNEL); 1209 + if (unlikely(!ffs->dev_name)) { 1210 + ffs_data_put(ffs); 1211 + return ERR_PTR(-ENOMEM); 1212 + } 1213 + 1183 1214 ffs_dev = functionfs_acquire_dev_callback(dev_name); 1184 - if (IS_ERR(ffs_dev)) 1185 - return ffs_dev; 1215 + if (IS_ERR(ffs_dev)) { 1216 + ffs_data_put(ffs); 1217 + return ERR_CAST(ffs_dev); 1218 + } 1219 + ffs->private_data = ffs_dev; 1220 + data.ffs_data = ffs; 1186 1221 1187 - data.dev_name = dev_name; 1188 - data.private_data = ffs_dev; 1189 1222 rv = mount_nodev(t, flags, &data, ffs_sb_fill); 1190 - 1191 - /* data.ffs_data is set by ffs_sb_fill */ 1192 - if (IS_ERR(rv)) 1223 + if (IS_ERR(rv) && data.ffs_data) { 1193 1224 functionfs_release_dev_callback(data.ffs_data); 1194 - 1225 + ffs_data_put(data.ffs_data); 1226 + } 1195 1227 return rv; 1196 1228 } 1197 1229
+6 -11
drivers/usb/host/ehci-fsl.c
··· 130 130 } 131 131 132 132 /* Enable USB controller, 83xx or 8536 */ 133 - if (pdata->have_sysif_regs) 133 + if (pdata->have_sysif_regs && pdata->controller_ver < FSL_USB_VER_1_6) 134 134 setbits32(hcd->regs + FSL_SOC_USB_CTRL, 0x4); 135 135 136 136 /* Don't need to set host mode here. It will be done by tdi_reset() */ ··· 232 232 case FSL_USB2_PHY_ULPI: 233 233 if (pdata->have_sysif_regs && pdata->controller_ver) { 234 234 /* controller version 1.6 or above */ 235 + clrbits32(non_ehci + FSL_SOC_USB_CTRL, UTMI_PHY_EN); 235 236 setbits32(non_ehci + FSL_SOC_USB_CTRL, 236 - ULPI_PHY_CLK_SEL); 237 - /* 238 - * Due to controller issue of PHY_CLK_VALID in ULPI 239 - * mode, we set USB_CTRL_USB_EN before checking 240 - * PHY_CLK_VALID, otherwise PHY_CLK_VALID doesn't work. 241 - */ 242 - clrsetbits_be32(non_ehci + FSL_SOC_USB_CTRL, 243 - UTMI_PHY_EN, USB_CTRL_USB_EN); 237 + ULPI_PHY_CLK_SEL | USB_CTRL_USB_EN); 244 238 } 245 239 portsc |= PORT_PTS_ULPI; 246 240 break; ··· 264 270 if (pdata->have_sysif_regs && pdata->controller_ver && 265 271 (phy_mode == FSL_USB2_PHY_ULPI)) { 266 272 /* check PHY_CLK_VALID to get phy clk valid */ 267 - if (!spin_event_timeout(in_be32(non_ehci + FSL_SOC_USB_CTRL) & 268 - PHY_CLK_VALID, FSL_USB_PHY_CLK_TIMEOUT, 0)) { 273 + if (!(spin_event_timeout(in_be32(non_ehci + FSL_SOC_USB_CTRL) & 274 + PHY_CLK_VALID, FSL_USB_PHY_CLK_TIMEOUT, 0) || 275 + in_be32(non_ehci + FSL_SOC_USB_PRICTRL))) { 269 276 printk(KERN_WARNING "fsl-ehci: USB PHY clock invalid\n"); 270 277 return -EINVAL; 271 278 }
+1 -1
drivers/usb/host/ehci-pci.c
··· 361 361 .remove = usb_hcd_pci_remove, 362 362 .shutdown = usb_hcd_pci_shutdown, 363 363 364 - #ifdef CONFIG_PM_SLEEP 364 + #ifdef CONFIG_PM 365 365 .driver = { 366 366 .pm = &usb_hcd_pci_pm_ops 367 367 },
+4 -4
drivers/usb/host/imx21-hcd.c
··· 824 824 i = DIV_ROUND_UP(wrap_frame( 825 825 cur_frame - urb->start_frame), 826 826 urb->interval); 827 - if (urb->transfer_flags & URB_ISO_ASAP) { 827 + 828 + /* Treat underruns as if URB_ISO_ASAP was set */ 829 + if ((urb->transfer_flags & URB_ISO_ASAP) || 830 + i >= urb->number_of_packets) { 828 831 urb->start_frame = wrap_frame(urb->start_frame 829 832 + i * urb->interval); 830 833 i = 0; 831 - } else if (i >= urb->number_of_packets) { 832 - ret = -EXDEV; 833 - goto alloc_dmem_failed; 834 834 } 835 835 } 836 836 }
+12 -10
drivers/usb/host/ohci-hcd.c
··· 216 216 frame &= ~(ed->interval - 1); 217 217 frame |= ed->branch; 218 218 urb->start_frame = frame; 219 + ed->last_iso = frame + ed->interval * (size - 1); 219 220 } 220 221 } else if (ed->type == PIPE_ISOCHRONOUS) { 221 222 u16 next = ohci_frame_no(ohci) + 1; 222 223 u16 frame = ed->last_iso + ed->interval; 224 + u16 length = ed->interval * (size - 1); 223 225 224 226 /* Behind the scheduling threshold? */ 225 227 if (unlikely(tick_before(frame, next))) { 226 228 227 - /* USB_ISO_ASAP: Round up to the first available slot */ 229 + /* URB_ISO_ASAP: Round up to the first available slot */ 228 230 if (urb->transfer_flags & URB_ISO_ASAP) { 229 231 frame += (next - frame + ed->interval - 1) & 230 232 -ed->interval; 231 233 232 234 /* 233 - * Not ASAP: Use the next slot in the stream. If 234 - * the entire URB falls before the threshold, fail. 235 + * Not ASAP: Use the next slot in the stream, 236 + * no matter what. 235 237 */ 236 238 } else { 237 - if (tick_before(frame + ed->interval * 238 - (urb->number_of_packets - 1), next)) { 239 - retval = -EXDEV; 240 - usb_hcd_unlink_urb_from_ep(hcd, urb); 241 - goto fail; 242 - } 243 - 244 239 /* 245 240 * Some OHCI hardware doesn't handle late TDs 246 241 * correctly. After retiring them it proceeds ··· 246 251 urb_priv->td_cnt = DIV_ROUND_UP( 247 252 (u16) (next - frame), 248 253 ed->interval); 254 + if (urb_priv->td_cnt >= urb_priv->length) { 255 + ++urb_priv->td_cnt; /* Mark it */ 256 + ohci_dbg(ohci, "iso underrun %p (%u+%u < %u)\n", 257 + urb, frame, length, 258 + next); 259 + } 249 260 } 250 261 } 251 262 urb->start_frame = frame; 263 + ed->last_iso = frame + length; 252 264 } 253 265 254 266 /* fill the TDs and link them to the ed; and
+22 -4
drivers/usb/host/ohci-q.c
··· 41 41 __releases(ohci->lock) 42 42 __acquires(ohci->lock) 43 43 { 44 - struct device *dev = ohci_to_hcd(ohci)->self.controller; 44 + struct device *dev = ohci_to_hcd(ohci)->self.controller; 45 + struct usb_host_endpoint *ep = urb->ep; 46 + struct urb_priv *urb_priv; 47 + 45 48 // ASSERT (urb->hcpriv != 0); 46 49 50 + restart: 47 51 urb_free_priv (ohci, urb->hcpriv); 48 52 urb->hcpriv = NULL; 49 53 if (likely(status == -EINPROGRESS)) ··· 83 79 && ohci_to_hcd(ohci)->self.bandwidth_int_reqs == 0) { 84 80 ohci->hc_control &= ~(OHCI_CTRL_PLE|OHCI_CTRL_IE); 85 81 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); 82 + } 83 + 84 + /* 85 + * An isochronous URB that is sumitted too late won't have any TDs 86 + * (marked by the fact that the td_cnt value is larger than the 87 + * actual number of TDs). If the next URB on this endpoint is like 88 + * that, give it back now. 89 + */ 90 + if (!list_empty(&ep->urb_list)) { 91 + urb = list_first_entry(&ep->urb_list, struct urb, urb_list); 92 + urb_priv = urb->hcpriv; 93 + if (urb_priv->td_cnt > urb_priv->length) { 94 + status = 0; 95 + goto restart; 96 + } 86 97 } 87 98 } 88 99 ··· 565 546 td->hwCBP = cpu_to_hc32 (ohci, data & 0xFFFFF000); 566 547 *ohci_hwPSWp(ohci, td, 0) = cpu_to_hc16 (ohci, 567 548 (data & 0x0FFF) | 0xE000); 568 - td->ed->last_iso = info & 0xffff; 569 549 } else { 570 550 td->hwCBP = cpu_to_hc32 (ohci, data); 571 551 } ··· 1014 996 urb_priv->td_cnt++; 1015 997 1016 998 /* if URB is done, clean up */ 1017 - if (urb_priv->td_cnt == urb_priv->length) { 999 + if (urb_priv->td_cnt >= urb_priv->length) { 1018 1000 modified = completed = 1; 1019 1001 finish_urb(ohci, urb, 0); 1020 1002 } ··· 1104 1086 urb_priv->td_cnt++; 1105 1087 1106 1088 /* If all this urb's TDs are done, call complete() */ 1107 - if (urb_priv->td_cnt == urb_priv->length) 1089 + if (urb_priv->td_cnt >= urb_priv->length) 1108 1090 finish_urb(ohci, urb, status); 1109 1091 1110 1092 /* clean schedule: unlink EDs that are no longer busy */
+1 -1
drivers/usb/host/uhci-pci.c
··· 293 293 .remove = usb_hcd_pci_remove, 294 294 .shutdown = uhci_shutdown, 295 295 296 - #ifdef CONFIG_PM_SLEEP 296 + #ifdef CONFIG_PM 297 297 .driver = { 298 298 .pm = &usb_hcd_pci_pm_ops 299 299 },
+8 -4
drivers/usb/host/uhci-q.c
··· 1303 1303 } 1304 1304 1305 1305 /* Fell behind? */ 1306 - if (uhci_frame_before_eq(frame, next)) { 1306 + if (!uhci_frame_before_eq(next, frame)) { 1307 1307 1308 1308 /* USB_ISO_ASAP: Round up to the first available slot */ 1309 1309 if (urb->transfer_flags & URB_ISO_ASAP) ··· 1311 1311 -qh->period; 1312 1312 1313 1313 /* 1314 - * Not ASAP: Use the next slot in the stream. If 1315 - * the entire URB falls before the threshold, fail. 1314 + * Not ASAP: Use the next slot in the stream, 1315 + * no matter what. 1316 1316 */ 1317 1317 else if (!uhci_frame_before_eq(next, 1318 1318 frame + (urb->number_of_packets - 1) * 1319 1319 qh->period)) 1320 - return -EXDEV; 1320 + dev_dbg(uhci_dev(uhci), "iso underrun %p (%u+%u < %u)\n", 1321 + urb, frame, 1322 + (urb->number_of_packets - 1) * 1323 + qh->period, 1324 + next); 1321 1325 } 1322 1326 } 1323 1327
+36 -11
drivers/usb/host/xhci-hub.c
··· 287 287 if (virt_dev->eps[i].ring && virt_dev->eps[i].ring->dequeue) 288 288 xhci_queue_stop_endpoint(xhci, slot_id, i, suspend); 289 289 } 290 - cmd->command_trb = xhci->cmd_ring->enqueue; 290 + cmd->command_trb = xhci_find_next_enqueue(xhci->cmd_ring); 291 291 list_add_tail(&cmd->cmd_list, &virt_dev->cmd_list); 292 292 xhci_queue_stop_endpoint(xhci, slot_id, 0, suspend); 293 293 xhci_ring_cmd_db(xhci); ··· 552 552 * - Mark a port as being done with device resume, 553 553 * and ring the endpoint doorbells. 554 554 * - Stop the Synopsys redriver Compliance Mode polling. 555 + * - Drop and reacquire the xHCI lock, in order to wait for port resume. 555 556 */ 556 557 static u32 xhci_get_port_status(struct usb_hcd *hcd, 557 558 struct xhci_bus_state *bus_state, 558 559 __le32 __iomem **port_array, 559 - u16 wIndex, u32 raw_port_status) 560 + u16 wIndex, u32 raw_port_status, 561 + unsigned long flags) 562 + __releases(&xhci->lock) 563 + __acquires(&xhci->lock) 560 564 { 561 565 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 562 566 u32 status = 0; ··· 595 591 return 0xffffffff; 596 592 if (time_after_eq(jiffies, 597 593 bus_state->resume_done[wIndex])) { 594 + int time_left; 595 + 598 596 xhci_dbg(xhci, "Resume USB2 port %d\n", 599 597 wIndex + 1); 600 598 bus_state->resume_done[wIndex] = 0; 601 599 clear_bit(wIndex, &bus_state->resuming_ports); 600 + 601 + set_bit(wIndex, &bus_state->rexit_ports); 602 602 xhci_set_link_state(xhci, port_array, wIndex, 603 603 XDEV_U0); 604 - xhci_dbg(xhci, "set port %d resume\n", 605 - wIndex + 1); 606 - slot_id = xhci_find_slot_id_by_port(hcd, xhci, 607 - wIndex + 1); 608 - if (!slot_id) { 609 - xhci_dbg(xhci, "slot_id is zero\n"); 610 - return 0xffffffff; 604 + 605 + spin_unlock_irqrestore(&xhci->lock, flags); 606 + time_left = wait_for_completion_timeout( 607 + &bus_state->rexit_done[wIndex], 608 + msecs_to_jiffies( 609 + XHCI_MAX_REXIT_TIMEOUT)); 610 + spin_lock_irqsave(&xhci->lock, flags); 611 + 612 + if (time_left) { 613 + slot_id = xhci_find_slot_id_by_port(hcd, 614 + xhci, wIndex + 1); 615 + if (!slot_id) { 616 + xhci_dbg(xhci, "slot_id is zero\n"); 617 + return 0xffffffff; 618 + } 619 + xhci_ring_device(xhci, slot_id); 620 + } else { 621 + int port_status = xhci_readl(xhci, 622 + port_array[wIndex]); 623 + xhci_warn(xhci, "Port resume took longer than %i msec, port status = 0x%x\n", 624 + XHCI_MAX_REXIT_TIMEOUT, 625 + port_status); 626 + status |= USB_PORT_STAT_SUSPEND; 627 + clear_bit(wIndex, &bus_state->rexit_ports); 611 628 } 612 - xhci_ring_device(xhci, slot_id); 629 + 613 630 bus_state->port_c_suspend |= 1 << wIndex; 614 631 bus_state->suspended_ports &= ~(1 << wIndex); 615 632 } else { ··· 753 728 break; 754 729 } 755 730 status = xhci_get_port_status(hcd, bus_state, port_array, 756 - wIndex, temp); 731 + wIndex, temp, flags); 757 732 if (status == 0xffffffff) 758 733 goto error; 759 734
+2
drivers/usb/host/xhci-mem.c
··· 2428 2428 for (i = 0; i < USB_MAXCHILDREN; ++i) { 2429 2429 xhci->bus_state[0].resume_done[i] = 0; 2430 2430 xhci->bus_state[1].resume_done[i] = 0; 2431 + /* Only the USB 2.0 completions will ever be used. */ 2432 + init_completion(&xhci->bus_state[1].rexit_done[i]); 2431 2433 } 2432 2434 2433 2435 if (scratchpad_alloc(xhci, flags))
+1 -1
drivers/usb/host/xhci-pci.c
··· 351 351 /* suspend and resume implemented later */ 352 352 353 353 .shutdown = usb_hcd_pci_shutdown, 354 - #ifdef CONFIG_PM_SLEEP 354 + #ifdef CONFIG_PM 355 355 .driver = { 356 356 .pm = &usb_hcd_pci_pm_ops 357 357 },
+35 -2
drivers/usb/host/xhci-ring.c
··· 123 123 return TRB_TYPE_LINK_LE32(link->control); 124 124 } 125 125 126 + union xhci_trb *xhci_find_next_enqueue(struct xhci_ring *ring) 127 + { 128 + /* Enqueue pointer can be left pointing to the link TRB, 129 + * we must handle that 130 + */ 131 + if (TRB_TYPE_LINK_LE32(ring->enqueue->link.control)) 132 + return ring->enq_seg->next->trbs; 133 + return ring->enqueue; 134 + } 135 + 126 136 /* Updates trb to point to the next TRB in the ring, and updates seg if the next 127 137 * TRB is in a new segment. This does not skip over link TRBs, and it does not 128 138 * effect the ring dequeue or enqueue pointers. ··· 869 859 /* Otherwise ring the doorbell(s) to restart queued transfers */ 870 860 ring_doorbell_for_active_rings(xhci, slot_id, ep_index); 871 861 } 872 - ep->stopped_td = NULL; 873 - ep->stopped_trb = NULL; 862 + 863 + /* Clear stopped_td and stopped_trb if endpoint is not halted */ 864 + if (!(ep->ep_state & EP_HALTED)) { 865 + ep->stopped_td = NULL; 866 + ep->stopped_trb = NULL; 867 + } 874 868 875 869 /* 876 870 * Drop the lock and complete the URBs in the cancelled TD list. ··· 1428 1414 inc_deq(xhci, xhci->cmd_ring); 1429 1415 return; 1430 1416 } 1417 + /* There is no command to handle if we get a stop event when the 1418 + * command ring is empty, event->cmd_trb points to the next 1419 + * unset command 1420 + */ 1421 + if (xhci->cmd_ring->dequeue == xhci->cmd_ring->enqueue) 1422 + return; 1431 1423 } 1432 1424 1433 1425 switch (le32_to_cpu(xhci->cmd_ring->dequeue->generic.field[3]) ··· 1761 1741 bogus_port_status = true; 1762 1742 goto cleanup; 1763 1743 } 1744 + } 1745 + 1746 + /* 1747 + * Check to see if xhci-hub.c is waiting on RExit to U0 transition (or 1748 + * RExit to a disconnect state). If so, let the the driver know it's 1749 + * out of the RExit state. 1750 + */ 1751 + if (!DEV_SUPERSPEED(temp) && 1752 + test_and_clear_bit(faked_port_index, 1753 + &bus_state->rexit_ports)) { 1754 + complete(&bus_state->rexit_done[faked_port_index]); 1755 + bogus_port_status = true; 1756 + goto cleanup; 1764 1757 } 1765 1758 1766 1759 if (hcd->speed != HCD_USB3)
+5 -20
drivers/usb/host/xhci.c
··· 2598 2598 if (command) { 2599 2599 cmd_completion = command->completion; 2600 2600 cmd_status = &command->status; 2601 - command->command_trb = xhci->cmd_ring->enqueue; 2602 - 2603 - /* Enqueue pointer can be left pointing to the link TRB, 2604 - * we must handle that 2605 - */ 2606 - if (TRB_TYPE_LINK_LE32(command->command_trb->link.control)) 2607 - command->command_trb = 2608 - xhci->cmd_ring->enq_seg->next->trbs; 2609 - 2601 + command->command_trb = xhci_find_next_enqueue(xhci->cmd_ring); 2610 2602 list_add_tail(&command->cmd_list, &virt_dev->cmd_list); 2611 2603 } else { 2612 2604 cmd_completion = &virt_dev->cmd_completion; ··· 2606 2614 } 2607 2615 init_completion(cmd_completion); 2608 2616 2609 - cmd_trb = xhci->cmd_ring->dequeue; 2617 + cmd_trb = xhci_find_next_enqueue(xhci->cmd_ring); 2610 2618 if (!ctx_change) 2611 2619 ret = xhci_queue_configure_endpoint(xhci, in_ctx->dma, 2612 2620 udev->slot_id, must_succeed); ··· 3431 3439 3432 3440 /* Attempt to submit the Reset Device command to the command ring */ 3433 3441 spin_lock_irqsave(&xhci->lock, flags); 3434 - reset_device_cmd->command_trb = xhci->cmd_ring->enqueue; 3435 - 3436 - /* Enqueue pointer can be left pointing to the link TRB, 3437 - * we must handle that 3438 - */ 3439 - if (TRB_TYPE_LINK_LE32(reset_device_cmd->command_trb->link.control)) 3440 - reset_device_cmd->command_trb = 3441 - xhci->cmd_ring->enq_seg->next->trbs; 3442 + reset_device_cmd->command_trb = xhci_find_next_enqueue(xhci->cmd_ring); 3442 3443 3443 3444 list_add_tail(&reset_device_cmd->cmd_list, &virt_dev->cmd_list); 3444 3445 ret = xhci_queue_reset_device(xhci, slot_id); ··· 3635 3650 union xhci_trb *cmd_trb; 3636 3651 3637 3652 spin_lock_irqsave(&xhci->lock, flags); 3638 - cmd_trb = xhci->cmd_ring->dequeue; 3653 + cmd_trb = xhci_find_next_enqueue(xhci->cmd_ring); 3639 3654 ret = xhci_queue_slot_control(xhci, TRB_ENABLE_SLOT, 0); 3640 3655 if (ret) { 3641 3656 spin_unlock_irqrestore(&xhci->lock, flags); ··· 3770 3785 slot_ctx->dev_info >> 27); 3771 3786 3772 3787 spin_lock_irqsave(&xhci->lock, flags); 3773 - cmd_trb = xhci->cmd_ring->dequeue; 3788 + cmd_trb = xhci_find_next_enqueue(xhci->cmd_ring); 3774 3789 ret = xhci_queue_address_device(xhci, virt_dev->in_ctx->dma, 3775 3790 udev->slot_id); 3776 3791 if (ret) {
+11
drivers/usb/host/xhci.h
··· 1412 1412 unsigned long resume_done[USB_MAXCHILDREN]; 1413 1413 /* which ports have started to resume */ 1414 1414 unsigned long resuming_ports; 1415 + /* Which ports are waiting on RExit to U0 transition. */ 1416 + unsigned long rexit_ports; 1417 + struct completion rexit_done[USB_MAXCHILDREN]; 1415 1418 }; 1419 + 1420 + 1421 + /* 1422 + * It can take up to 20 ms to transition from RExit to U0 on the 1423 + * Intel Lynx Point LP xHCI host. 1424 + */ 1425 + #define XHCI_MAX_REXIT_TIMEOUT (20 * 1000) 1416 1426 1417 1427 static inline unsigned int hcd_index(struct usb_hcd *hcd) 1418 1428 { ··· 1850 1840 union xhci_trb *cmd_trb); 1851 1841 void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id, 1852 1842 unsigned int ep_index, unsigned int stream_id); 1843 + union xhci_trb *xhci_find_next_enqueue(struct xhci_ring *ring); 1853 1844 1854 1845 /* xHCI roothub code */ 1855 1846 void xhci_set_link_state(struct xhci_hcd *xhci, __le32 __iomem **port_array,