Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

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

The usual suspects of gadget, xhci, and dwc2/3 are in here, along with
some reverts of reported problem changes, and a number of build
documentation warning fixes. Full details are in the shortlog.

All of these have been in linux-next with no reported issues"

* tag 'usb-4.19-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (28 commits)
Revert "cdc-acm: implement put_char() and flush_chars()"
usb: Change usb_of_get_companion_dev() place to usb/common
usb: xhci: fix interrupt transfer error happened on MTK platforms
usb: cdc-wdm: Fix a sleep-in-atomic-context bug in service_outstanding_interrupt()
usb: misc: uss720: Fix two sleep-in-atomic-context bugs
usb: host: u132-hcd: Fix a sleep-in-atomic-context bug in u132_get_frame()
usb: Avoid use-after-free by flushing endpoints early in usb_set_interface()
linux/mod_devicetable.h: fix kernel-doc missing notation for typec_device_id
usb/typec: fix kernel-doc notation warning for typec_match_altmode
usb: Don't die twice if PCI xhci host is not responding in resume
usb: mtu3: fix error of xhci port id when enable U3 dual role
usb: uas: add support for more quirk flags
USB: Add quirk to support DJI CineSSD
usb: typec: fix kernel-doc parameter warning
usb/dwc3/gadget: fix kernel-doc parameter warning
USB: yurex: Check for truncation in yurex_read()
USB: yurex: Fix buffer over-read in yurex_write()
usb: host: xhci-plat: Iterate over parent nodes for finding quirks
xhci: Fix use after free for URB cancellation on a reallocated endpoint
USB: add quirk for WORLDE Controller KS49 or Prodipe MIDI 49C USB controller
...

+190 -146
-73
drivers/usb/class/cdc-acm.c
··· 780 780 } 781 781 782 782 if (acm->susp_count) { 783 - if (acm->putbuffer) { 784 - /* now to preserve order */ 785 - usb_anchor_urb(acm->putbuffer->urb, &acm->delayed); 786 - acm->putbuffer = NULL; 787 - } 788 783 usb_anchor_urb(wb->urb, &acm->delayed); 789 784 spin_unlock_irqrestore(&acm->write_lock, flags); 790 785 return count; 791 - } else { 792 - if (acm->putbuffer) { 793 - /* at this point there is no good way to handle errors */ 794 - acm_start_wb(acm, acm->putbuffer); 795 - acm->putbuffer = NULL; 796 - } 797 786 } 798 787 799 788 stat = acm_start_wb(acm, wb); ··· 791 802 if (stat < 0) 792 803 return stat; 793 804 return count; 794 - } 795 - 796 - static void acm_tty_flush_chars(struct tty_struct *tty) 797 - { 798 - struct acm *acm = tty->driver_data; 799 - struct acm_wb *cur; 800 - int err; 801 - unsigned long flags; 802 - 803 - spin_lock_irqsave(&acm->write_lock, flags); 804 - 805 - cur = acm->putbuffer; 806 - if (!cur) /* nothing to do */ 807 - goto out; 808 - 809 - acm->putbuffer = NULL; 810 - err = usb_autopm_get_interface_async(acm->control); 811 - if (err < 0) { 812 - cur->use = 0; 813 - acm->putbuffer = cur; 814 - goto out; 815 - } 816 - 817 - if (acm->susp_count) 818 - usb_anchor_urb(cur->urb, &acm->delayed); 819 - else 820 - acm_start_wb(acm, cur); 821 - out: 822 - spin_unlock_irqrestore(&acm->write_lock, flags); 823 - return; 824 - } 825 - 826 - static int acm_tty_put_char(struct tty_struct *tty, unsigned char ch) 827 - { 828 - struct acm *acm = tty->driver_data; 829 - struct acm_wb *cur; 830 - int wbn; 831 - unsigned long flags; 832 - 833 - overflow: 834 - cur = acm->putbuffer; 835 - if (!cur) { 836 - spin_lock_irqsave(&acm->write_lock, flags); 837 - wbn = acm_wb_alloc(acm); 838 - if (wbn >= 0) { 839 - cur = &acm->wb[wbn]; 840 - acm->putbuffer = cur; 841 - } 842 - spin_unlock_irqrestore(&acm->write_lock, flags); 843 - if (!cur) 844 - return 0; 845 - } 846 - 847 - if (cur->len == acm->writesize) { 848 - acm_tty_flush_chars(tty); 849 - goto overflow; 850 - } 851 - 852 - cur->buf[cur->len++] = ch; 853 - return 1; 854 805 } 855 806 856 807 static int acm_tty_write_room(struct tty_struct *tty) ··· 1916 1987 .cleanup = acm_tty_cleanup, 1917 1988 .hangup = acm_tty_hangup, 1918 1989 .write = acm_tty_write, 1919 - .put_char = acm_tty_put_char, 1920 - .flush_chars = acm_tty_flush_chars, 1921 1990 .write_room = acm_tty_write_room, 1922 1991 .ioctl = acm_tty_ioctl, 1923 1992 .throttle = acm_tty_throttle,
-1
drivers/usb/class/cdc-acm.h
··· 96 96 unsigned long read_urbs_free; 97 97 struct urb *read_urbs[ACM_NR]; 98 98 struct acm_rb read_buffers[ACM_NR]; 99 - struct acm_wb *putbuffer; /* for acm_tty_put_char() */ 100 99 int rx_buflimit; 101 100 spinlock_t read_lock; 102 101 u8 *notification_buffer; /* to reassemble fragmented notifications */
+1 -1
drivers/usb/class/cdc-wdm.c
··· 460 460 461 461 set_bit(WDM_RESPONDING, &desc->flags); 462 462 spin_unlock_irq(&desc->iuspin); 463 - rv = usb_submit_urb(desc->response, GFP_KERNEL); 463 + rv = usb_submit_urb(desc->response, GFP_ATOMIC); 464 464 spin_lock_irq(&desc->iuspin); 465 465 if (rv) { 466 466 dev_err(&desc->intf->dev,
+25
drivers/usb/common/common.c
··· 246 246 } 247 247 EXPORT_SYMBOL_GPL(of_usb_update_otg_caps); 248 248 249 + /** 250 + * usb_of_get_companion_dev - Find the companion device 251 + * @dev: the device pointer to find a companion 252 + * 253 + * Find the companion device from platform bus. 254 + * 255 + * Takes a reference to the returned struct device which needs to be dropped 256 + * after use. 257 + * 258 + * Return: On success, a pointer to the companion device, %NULL on failure. 259 + */ 260 + struct device *usb_of_get_companion_dev(struct device *dev) 261 + { 262 + struct device_node *node; 263 + struct platform_device *pdev = NULL; 264 + 265 + node = of_parse_phandle(dev->of_node, "companion", 0); 266 + if (node) 267 + pdev = of_find_device_by_node(node); 268 + 269 + of_node_put(node); 270 + 271 + return pdev ? &pdev->dev : NULL; 272 + } 273 + EXPORT_SYMBOL_GPL(usb_of_get_companion_dev); 249 274 #endif 250 275 251 276 MODULE_LICENSE("GPL");
-2
drivers/usb/core/hcd-pci.c
··· 515 515 event == PM_EVENT_RESTORE); 516 516 if (retval) { 517 517 dev_err(dev, "PCI post-resume error %d!\n", retval); 518 - if (hcd->shared_hcd) 519 - usb_hc_died(hcd->shared_hcd); 520 518 usb_hc_died(hcd); 521 519 } 522 520 }
+11
drivers/usb/core/message.c
··· 1341 1341 * is submitted that needs that bandwidth. Some other operating systems 1342 1342 * allocate bandwidth early, when a configuration is chosen. 1343 1343 * 1344 + * xHCI reserves bandwidth and configures the alternate setting in 1345 + * usb_hcd_alloc_bandwidth(). If it fails the original interface altsetting 1346 + * may be disabled. Drivers cannot rely on any particular alternate 1347 + * setting being in effect after a failure. 1348 + * 1344 1349 * This call is synchronous, and may not be used in an interrupt context. 1345 1350 * Also, drivers must not change altsettings while urbs are scheduled for 1346 1351 * endpoints in that interface; all such urbs must first be completed ··· 1381 1376 alternate); 1382 1377 return -EINVAL; 1383 1378 } 1379 + /* 1380 + * usb3 hosts configure the interface in usb_hcd_alloc_bandwidth, 1381 + * including freeing dropped endpoint ring buffers. 1382 + * Make sure the interface endpoints are flushed before that 1383 + */ 1384 + usb_disable_interface(dev, iface, false); 1384 1385 1385 1386 /* Make sure we have enough bandwidth for this alternate interface. 1386 1387 * Remove the current alt setting and add the new alt setting.
-26
drivers/usb/core/of.c
··· 105 105 return NULL; 106 106 } 107 107 EXPORT_SYMBOL_GPL(usb_of_get_interface_node); 108 - 109 - /** 110 - * usb_of_get_companion_dev - Find the companion device 111 - * @dev: the device pointer to find a companion 112 - * 113 - * Find the companion device from platform bus. 114 - * 115 - * Takes a reference to the returned struct device which needs to be dropped 116 - * after use. 117 - * 118 - * Return: On success, a pointer to the companion device, %NULL on failure. 119 - */ 120 - struct device *usb_of_get_companion_dev(struct device *dev) 121 - { 122 - struct device_node *node; 123 - struct platform_device *pdev = NULL; 124 - 125 - node = of_parse_phandle(dev->of_node, "companion", 0); 126 - if (node) 127 - pdev = of_find_device_by_node(node); 128 - 129 - of_node_put(node); 130 - 131 - return pdev ? &pdev->dev : NULL; 132 - } 133 - EXPORT_SYMBOL_GPL(usb_of_get_companion_dev);
+7
drivers/usb/core/quirks.c
··· 178 178 /* CBM - Flash disk */ 179 179 { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME }, 180 180 181 + /* WORLDE Controller KS49 or Prodipe MIDI 49C USB controller */ 182 + { USB_DEVICE(0x0218, 0x0201), .driver_info = 183 + USB_QUIRK_CONFIG_INTF_STRINGS }, 184 + 181 185 /* WORLDE easy key (easykey.25) MIDI controller */ 182 186 { USB_DEVICE(0x0218, 0x0401), .driver_info = 183 187 USB_QUIRK_CONFIG_INTF_STRINGS }, ··· 409 405 /* Hauppauge HVR-950q */ 410 406 { USB_DEVICE(0x2040, 0x7200), .driver_info = 411 407 USB_QUIRK_CONFIG_INTF_STRINGS }, 408 + 409 + /* DJI CineSSD */ 410 + { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM }, 412 411 413 412 /* INTEL VALUE SSD */ 414 413 { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME },
+2 -2
drivers/usb/dwc2/platform.c
··· 412 412 dev_dbg(&dev->dev, "mapped PA %08lx to VA %p\n", 413 413 (unsigned long)res->start, hsotg->regs); 414 414 415 - hsotg->needs_byte_swap = dwc2_check_core_endianness(hsotg); 416 - 417 415 retval = dwc2_lowlevel_hw_init(hsotg); 418 416 if (retval) 419 417 return retval; ··· 435 437 retval = dwc2_lowlevel_hw_enable(hsotg); 436 438 if (retval) 437 439 return retval; 440 + 441 + hsotg->needs_byte_swap = dwc2_check_core_endianness(hsotg); 438 442 439 443 retval = dwc2_get_dr_mode(hsotg); 440 444 if (retval)
+4 -6
drivers/usb/dwc3/dwc3-of-simple.c
··· 180 180 return 0; 181 181 } 182 182 183 - #ifdef CONFIG_PM 184 - static int dwc3_of_simple_runtime_suspend(struct device *dev) 183 + static int __maybe_unused dwc3_of_simple_runtime_suspend(struct device *dev) 185 184 { 186 185 struct dwc3_of_simple *simple = dev_get_drvdata(dev); 187 186 int i; ··· 191 192 return 0; 192 193 } 193 194 194 - static int dwc3_of_simple_runtime_resume(struct device *dev) 195 + static int __maybe_unused dwc3_of_simple_runtime_resume(struct device *dev) 195 196 { 196 197 struct dwc3_of_simple *simple = dev_get_drvdata(dev); 197 198 int ret; ··· 209 210 return 0; 210 211 } 211 212 212 - static int dwc3_of_simple_suspend(struct device *dev) 213 + static int __maybe_unused dwc3_of_simple_suspend(struct device *dev) 213 214 { 214 215 struct dwc3_of_simple *simple = dev_get_drvdata(dev); 215 216 ··· 219 220 return 0; 220 221 } 221 222 222 - static int dwc3_of_simple_resume(struct device *dev) 223 + static int __maybe_unused dwc3_of_simple_resume(struct device *dev) 223 224 { 224 225 struct dwc3_of_simple *simple = dev_get_drvdata(dev); 225 226 ··· 228 229 229 230 return 0; 230 231 } 231 - #endif 232 232 233 233 static const struct dev_pm_ops dwc3_of_simple_dev_pm_ops = { 234 234 SET_SYSTEM_SLEEP_PM_OPS(dwc3_of_simple_suspend, dwc3_of_simple_resume)
+2 -2
drivers/usb/dwc3/dwc3-pci.c
··· 85 85 u32 value; 86 86 87 87 reg = pcim_iomap(pci, GP_RWBAR, 0); 88 - if (IS_ERR(reg)) 89 - return PTR_ERR(reg); 88 + if (!reg) 89 + return -ENOMEM; 90 90 91 91 value = readl(reg + GP_RWREG1); 92 92 if (!(value & GP_RWREG1_ULPI_REFCLK_DISABLE))
-1
drivers/usb/dwc3/gadget.c
··· 473 473 474 474 /** 475 475 * dwc3_gadget_start_config - configure ep resources 476 - * @dwc: pointer to our controller context structure 477 476 * @dep: endpoint that is being enabled 478 477 * 479 478 * Issue a %DWC3_DEPCMD_DEPSTARTCFG command to @dep. After the command's
+10 -5
drivers/usb/gadget/udc/fotg210-udc.c
··· 1063 1063 static int fotg210_udc_remove(struct platform_device *pdev) 1064 1064 { 1065 1065 struct fotg210_udc *fotg210 = platform_get_drvdata(pdev); 1066 + int i; 1066 1067 1067 1068 usb_del_gadget_udc(&fotg210->gadget); 1068 1069 iounmap(fotg210->reg); 1069 1070 free_irq(platform_get_irq(pdev, 0), fotg210); 1070 1071 1071 1072 fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req); 1073 + for (i = 0; i < FOTG210_MAX_NUM_EP; i++) 1074 + kfree(fotg210->ep[i]); 1072 1075 kfree(fotg210); 1073 1076 1074 1077 return 0; ··· 1102 1099 /* initialize udc */ 1103 1100 fotg210 = kzalloc(sizeof(struct fotg210_udc), GFP_KERNEL); 1104 1101 if (fotg210 == NULL) 1105 - goto err_alloc; 1102 + goto err; 1106 1103 1107 1104 for (i = 0; i < FOTG210_MAX_NUM_EP; i++) { 1108 1105 _ep[i] = kzalloc(sizeof(struct fotg210_ep), GFP_KERNEL); ··· 1114 1111 fotg210->reg = ioremap(res->start, resource_size(res)); 1115 1112 if (fotg210->reg == NULL) { 1116 1113 pr_err("ioremap error.\n"); 1117 - goto err_map; 1114 + goto err_alloc; 1118 1115 } 1119 1116 1120 1117 spin_lock_init(&fotg210->lock); ··· 1162 1159 fotg210->ep0_req = fotg210_ep_alloc_request(&fotg210->ep[0]->ep, 1163 1160 GFP_KERNEL); 1164 1161 if (fotg210->ep0_req == NULL) 1165 - goto err_req; 1162 + goto err_map; 1166 1163 1167 1164 fotg210_init(fotg210); 1168 1165 ··· 1190 1187 fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req); 1191 1188 1192 1189 err_map: 1193 - if (fotg210->reg) 1194 - iounmap(fotg210->reg); 1190 + iounmap(fotg210->reg); 1195 1191 1196 1192 err_alloc: 1193 + for (i = 0; i < FOTG210_MAX_NUM_EP; i++) 1194 + kfree(fotg210->ep[i]); 1197 1195 kfree(fotg210); 1198 1196 1197 + err: 1199 1198 return ret; 1200 1199 } 1201 1200
+14 -2
drivers/usb/gadget/udc/net2280.c
··· 1545 1545 writel(tmp | BIT(USB_DETECT_ENABLE), &dev->usb->usbctl); 1546 1546 } else { 1547 1547 writel(tmp & ~BIT(USB_DETECT_ENABLE), &dev->usb->usbctl); 1548 - stop_activity(dev, dev->driver); 1548 + stop_activity(dev, NULL); 1549 1549 } 1550 1550 1551 1551 spin_unlock_irqrestore(&dev->lock, flags); 1552 + 1553 + if (!is_on && dev->driver) 1554 + dev->driver->disconnect(&dev->gadget); 1552 1555 1553 1556 return 0; 1554 1557 } ··· 2469 2466 nuke(&dev->ep[i]); 2470 2467 2471 2468 /* report disconnect; the driver is already quiesced */ 2472 - if (driver) 2469 + if (driver) { 2470 + spin_unlock(&dev->lock); 2473 2471 driver->disconnect(&dev->gadget); 2472 + spin_lock(&dev->lock); 2473 + } 2474 2474 2475 2475 usb_reinit(dev); 2476 2476 } ··· 3347 3341 BIT(PCI_RETRY_ABORT_INTERRUPT)) 3348 3342 3349 3343 static void handle_stat1_irqs(struct net2280 *dev, u32 stat) 3344 + __releases(dev->lock) 3345 + __acquires(dev->lock) 3350 3346 { 3351 3347 struct net2280_ep *ep; 3352 3348 u32 tmp, num, mask, scratch; ··· 3389 3381 if (disconnect || reset) { 3390 3382 stop_activity(dev, dev->driver); 3391 3383 ep0_start(dev); 3384 + spin_unlock(&dev->lock); 3392 3385 if (reset) 3393 3386 usb_gadget_udc_reset 3394 3387 (&dev->gadget, dev->driver); 3395 3388 else 3396 3389 (dev->driver->disconnect) 3397 3390 (&dev->gadget); 3391 + spin_lock(&dev->lock); 3398 3392 return; 3399 3393 } 3400 3394 } ··· 3415 3405 tmp = BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT); 3416 3406 if (stat & tmp) { 3417 3407 writel(tmp, &dev->regs->irqstat1); 3408 + spin_unlock(&dev->lock); 3418 3409 if (stat & BIT(SUSPEND_REQUEST_INTERRUPT)) { 3419 3410 if (dev->driver->suspend) 3420 3411 dev->driver->suspend(&dev->gadget); ··· 3426 3415 dev->driver->resume(&dev->gadget); 3427 3416 /* at high speed, note erratum 0133 */ 3428 3417 } 3418 + spin_lock(&dev->lock); 3429 3419 stat &= ~tmp; 3430 3420 } 3431 3421
+4 -1
drivers/usb/gadget/udc/renesas_usb3.c
··· 812 812 switch (speed) { 813 813 case USB_STA_SPEED_SS: 814 814 usb3->gadget.speed = USB_SPEED_SUPER; 815 + usb3->gadget.ep0->maxpacket = USB3_EP0_SS_MAX_PACKET_SIZE; 815 816 break; 816 817 case USB_STA_SPEED_HS: 817 818 usb3->gadget.speed = USB_SPEED_HIGH; 819 + usb3->gadget.ep0->maxpacket = USB3_EP0_HSFS_MAX_PACKET_SIZE; 818 820 break; 819 821 case USB_STA_SPEED_FS: 820 822 usb3->gadget.speed = USB_SPEED_FULL; 823 + usb3->gadget.ep0->maxpacket = USB3_EP0_HSFS_MAX_PACKET_SIZE; 821 824 break; 822 825 default: 823 826 usb3->gadget.speed = USB_SPEED_UNKNOWN; ··· 2516 2513 /* for control pipe */ 2517 2514 usb3->gadget.ep0 = &usb3_ep->ep; 2518 2515 usb_ep_set_maxpacket_limit(&usb3_ep->ep, 2519 - USB3_EP0_HSFS_MAX_PACKET_SIZE); 2516 + USB3_EP0_SS_MAX_PACKET_SIZE); 2520 2517 usb3_ep->ep.caps.type_control = true; 2521 2518 usb3_ep->ep.caps.dir_in = true; 2522 2519 usb3_ep->ep.caps.dir_out = true;
+1 -1
drivers/usb/host/u132-hcd.c
··· 2555 2555 } else { 2556 2556 int frame = 0; 2557 2557 dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n"); 2558 - msleep(100); 2558 + mdelay(100); 2559 2559 return frame; 2560 2560 } 2561 2561 }
+4
drivers/usb/host/xhci-mem.c
··· 1613 1613 in_ep_ctx->ep_info2 = out_ep_ctx->ep_info2; 1614 1614 in_ep_ctx->deq = out_ep_ctx->deq; 1615 1615 in_ep_ctx->tx_info = out_ep_ctx->tx_info; 1616 + if (xhci->quirks & XHCI_MTK_HOST) { 1617 + in_ep_ctx->reserved[0] = out_ep_ctx->reserved[0]; 1618 + in_ep_ctx->reserved[1] = out_ep_ctx->reserved[1]; 1619 + } 1616 1620 } 1617 1621 1618 1622 /* Copy output xhci_slot_ctx to the input xhci_slot_ctx.
+17 -12
drivers/usb/host/xhci-plat.c
··· 153 153 { 154 154 const struct xhci_plat_priv *priv_match; 155 155 const struct hc_driver *driver; 156 - struct device *sysdev; 156 + struct device *sysdev, *tmpdev; 157 157 struct xhci_hcd *xhci; 158 158 struct resource *res; 159 159 struct usb_hcd *hcd; ··· 273 273 goto disable_clk; 274 274 } 275 275 276 - if (device_property_read_bool(sysdev, "usb2-lpm-disable")) 277 - xhci->quirks |= XHCI_HW_LPM_DISABLE; 278 - 279 - if (device_property_read_bool(sysdev, "usb3-lpm-capable")) 280 - xhci->quirks |= XHCI_LPM_SUPPORT; 281 - 282 - if (device_property_read_bool(&pdev->dev, "quirk-broken-port-ped")) 283 - xhci->quirks |= XHCI_BROKEN_PORT_PED; 284 - 285 276 /* imod_interval is the interrupt moderation value in nanoseconds. */ 286 277 xhci->imod_interval = 40000; 287 - device_property_read_u32(sysdev, "imod-interval-ns", 288 - &xhci->imod_interval); 278 + 279 + /* Iterate over all parent nodes for finding quirks */ 280 + for (tmpdev = &pdev->dev; tmpdev; tmpdev = tmpdev->parent) { 281 + 282 + if (device_property_read_bool(tmpdev, "usb2-lpm-disable")) 283 + xhci->quirks |= XHCI_HW_LPM_DISABLE; 284 + 285 + if (device_property_read_bool(tmpdev, "usb3-lpm-capable")) 286 + xhci->quirks |= XHCI_LPM_SUPPORT; 287 + 288 + if (device_property_read_bool(tmpdev, "quirk-broken-port-ped")) 289 + xhci->quirks |= XHCI_BROKEN_PORT_PED; 290 + 291 + device_property_read_u32(tmpdev, "imod-interval-ns", 292 + &xhci->imod_interval); 293 + } 289 294 290 295 hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0); 291 296 if (IS_ERR(hcd->usb_phy)) {
+30
drivers/usb/host/xhci.c
··· 37 37 module_param(quirks, ullong, S_IRUGO); 38 38 MODULE_PARM_DESC(quirks, "Bit flags for quirks to be enabled as default"); 39 39 40 + static bool td_on_ring(struct xhci_td *td, struct xhci_ring *ring) 41 + { 42 + struct xhci_segment *seg = ring->first_seg; 43 + 44 + if (!td || !td->start_seg) 45 + return false; 46 + do { 47 + if (seg == td->start_seg) 48 + return true; 49 + seg = seg->next; 50 + } while (seg && seg != ring->first_seg); 51 + 52 + return false; 53 + } 54 + 40 55 /* TODO: copied from ehci-hcd.c - can this be refactored? */ 41 56 /* 42 57 * xhci_handshake - spin reading hc until handshake completes or fails ··· 1584 1569 if (temp == ~(u32)0 || xhci->xhc_state & XHCI_STATE_DYING) { 1585 1570 xhci_hc_died(xhci); 1586 1571 goto done; 1572 + } 1573 + 1574 + /* 1575 + * check ring is not re-allocated since URB was enqueued. If it is, then 1576 + * make sure none of the ring related pointers in this URB private data 1577 + * are touched, such as td_list, otherwise we overwrite freed data 1578 + */ 1579 + if (!td_on_ring(&urb_priv->td[0], ep_ring)) { 1580 + xhci_err(xhci, "Canceled URB td not found on endpoint ring"); 1581 + for (i = urb_priv->num_tds_done; i < urb_priv->num_tds; i++) { 1582 + td = &urb_priv->td[i]; 1583 + if (!list_empty(&td->cancelled_td_list)) 1584 + list_del_init(&td->cancelled_td_list); 1585 + } 1586 + goto err_giveback; 1587 1587 } 1588 1588 1589 1589 if (xhci->xhc_state & XHCI_STATE_HALTED) {
+2 -2
drivers/usb/misc/uss720.c
··· 369 369 mask &= 0x0f; 370 370 val &= 0x0f; 371 371 d = (priv->reg[1] & (~mask)) ^ val; 372 - if (set_1284_register(pp, 2, d, GFP_KERNEL)) 372 + if (set_1284_register(pp, 2, d, GFP_ATOMIC)) 373 373 return 0; 374 374 priv->reg[1] = d; 375 375 return d & 0xf; ··· 379 379 { 380 380 unsigned char ret; 381 381 382 - if (get_1284_register(pp, 1, &ret, GFP_KERNEL)) 382 + if (get_1284_register(pp, 1, &ret, GFP_ATOMIC)) 383 383 return 0; 384 384 return ret & 0xf8; 385 385 }
+6 -2
drivers/usb/misc/yurex.c
··· 413 413 spin_unlock_irqrestore(&dev->lock, flags); 414 414 mutex_unlock(&dev->io_mutex); 415 415 416 + if (WARN_ON_ONCE(len >= sizeof(in_buffer))) 417 + return -EIO; 418 + 416 419 return simple_read_from_buffer(buffer, count, ppos, in_buffer, len); 417 420 } 418 421 ··· 424 421 { 425 422 struct usb_yurex *dev; 426 423 int i, set = 0, retval = 0; 427 - char buffer[16]; 424 + char buffer[16 + 1]; 428 425 char *data = buffer; 429 426 unsigned long long c, c2 = 0; 430 427 signed long timeout = 0; 431 428 DEFINE_WAIT(wait); 432 429 433 - count = min(sizeof(buffer), count); 430 + count = min(sizeof(buffer) - 1, count); 434 431 dev = file->private_data; 435 432 436 433 /* verify that we actually have some data to write */ ··· 449 446 retval = -EFAULT; 450 447 goto error; 451 448 } 449 + buffer[count] = 0; 452 450 memset(dev->cntl_buffer, CMD_PADDING, YUREX_BUF_SIZE); 453 451 454 452 switch (buffer[0]) {
+5 -1
drivers/usb/mtu3/mtu3_core.c
··· 107 107 (SSUSB_U2_PORT_DIS | SSUSB_U2_PORT_PDN | 108 108 SSUSB_U2_PORT_HOST_SEL)); 109 109 110 - if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG) 110 + if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG) { 111 111 mtu3_setbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL); 112 + if (mtu->is_u3_ip) 113 + mtu3_setbits(ibase, SSUSB_U3_CTRL(0), 114 + SSUSB_U3_PORT_DUAL_MODE); 115 + } 112 116 113 117 return ssusb_check_clocks(mtu->ssusb, check_clk); 114 118 }
+1
drivers/usb/mtu3/mtu3_hw_regs.h
··· 459 459 460 460 /* U3D_SSUSB_U3_CTRL_0P */ 461 461 #define SSUSB_U3_PORT_SSP_SPEED BIT(9) 462 + #define SSUSB_U3_PORT_DUAL_MODE BIT(7) 462 463 #define SSUSB_U3_PORT_HOST_SEL BIT(2) 463 464 #define SSUSB_U3_PORT_PDN BIT(1) 464 465 #define SSUSB_U3_PORT_DIS BIT(0)
+1 -1
drivers/usb/serial/io_ti.h
··· 173 173 } __attribute__((packed)); 174 174 175 175 176 - #define TIUMP_GET_PORT_FROM_CODE(c) (((c) >> 4) - 3) 176 + #define TIUMP_GET_PORT_FROM_CODE(c) (((c) >> 6) & 0x01) 177 177 #define TIUMP_GET_FUNC_FROM_CODE(c) ((c) & 0x0f) 178 178 #define TIUMP_INTERRUPT_CODE_LSR 0x03 179 179 #define TIUMP_INTERRUPT_CODE_MSR 0x04
+1 -1
drivers/usb/serial/ti_usb_3410_5052.c
··· 1119 1119 1120 1120 static int ti_get_port_from_code(unsigned char code) 1121 1121 { 1122 - return (code >> 4) - 3; 1122 + return (code >> 6) & 0x01; 1123 1123 } 1124 1124 1125 1125 static int ti_get_func_from_code(unsigned char code)
+9
drivers/usb/storage/scsiglue.c
··· 376 376 return 0; 377 377 } 378 378 379 + if ((us->fflags & US_FL_NO_ATA_1X) && 380 + (srb->cmnd[0] == ATA_12 || srb->cmnd[0] == ATA_16)) { 381 + memcpy(srb->sense_buffer, usb_stor_sense_invalidCDB, 382 + sizeof(usb_stor_sense_invalidCDB)); 383 + srb->result = SAM_STAT_CHECK_CONDITION; 384 + done(srb); 385 + return 0; 386 + } 387 + 379 388 /* enqueue the command and wake up the control thread */ 380 389 srb->scsi_done = done; 381 390 us->srb = srb;
+21
drivers/usb/storage/uas.c
··· 842 842 sdev->skip_ms_page_8 = 1; 843 843 sdev->wce_default_on = 1; 844 844 } 845 + 846 + /* 847 + * Some disks return the total number of blocks in response 848 + * to READ CAPACITY rather than the highest block number. 849 + * If this device makes that mistake, tell the sd driver. 850 + */ 851 + if (devinfo->flags & US_FL_FIX_CAPACITY) 852 + sdev->fix_capacity = 1; 853 + 854 + /* 855 + * Some devices don't like MODE SENSE with page=0x3f, 856 + * which is the command used for checking if a device 857 + * is write-protected. Now that we tell the sd driver 858 + * to do a 192-byte transfer with this command the 859 + * majority of devices work fine, but a few still can't 860 + * handle it. The sd driver will simply assume those 861 + * devices are write-enabled. 862 + */ 863 + if (devinfo->flags & US_FL_NO_WP_DETECT) 864 + sdev->skip_ms_page_3f = 1; 865 + 845 866 scsi_change_queue_depth(sdev, devinfo->qdepth - 2); 846 867 return 0; 847 868 }
+7
drivers/usb/storage/unusual_devs.h
··· 2288 2288 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 2289 2289 US_FL_GO_SLOW ), 2290 2290 2291 + /* Reported-by: Tim Anderson <tsa@biglakesoftware.com> */ 2292 + UNUSUAL_DEV( 0x2ca3, 0x0031, 0x0000, 0x9999, 2293 + "DJI", 2294 + "CineSSD", 2295 + USB_SC_DEVICE, USB_PR_DEVICE, NULL, 2296 + US_FL_NO_ATA_1X), 2297 + 2291 2298 /* 2292 2299 * Reported by Frederic Marchal <frederic.marchal@wowcompany.com> 2293 2300 * Mio Moov 330
+4 -3
drivers/usb/typec/bus.c
··· 255 255 /* API for the port drivers */ 256 256 257 257 /** 258 - * typec_match_altmode - Match SVID to an array of alternate modes 258 + * typec_match_altmode - Match SVID and mode to an array of alternate modes 259 259 * @altmodes: Array of alternate modes 260 - * @n: Number of elements in the array, or -1 for NULL termiated arrays 260 + * @n: Number of elements in the array, or -1 for NULL terminated arrays 261 261 * @svid: Standard or Vendor ID to match with 262 + * @mode: Mode to match with 262 263 * 263 - * Return pointer to an alternate mode with SVID mathing @svid, or NULL when no 264 + * Return pointer to an alternate mode with SVID matching @svid, or NULL when no 264 265 * match is found. 265 266 */ 266 267 struct typec_altmode *typec_match_altmode(struct typec_altmode **altmodes,
-1
drivers/usb/typec/class.c
··· 1484 1484 * typec_port_register_altmode - Register USB Type-C Port Alternate Mode 1485 1485 * @port: USB Type-C Port that supports the alternate mode 1486 1486 * @desc: Description of the alternate mode 1487 - * @drvdata: Private pointer to driver specific info 1488 1487 * 1489 1488 * This routine is used to register an alternate mode that @port is capable of 1490 1489 * supporting.
+1
include/linux/mod_devicetable.h
··· 754 754 * struct typec_device_id - USB Type-C alternate mode identifiers 755 755 * @svid: Standard or Vendor ID 756 756 * @mode: Mode index 757 + * @driver_data: Driver specific data 757 758 */ 758 759 struct typec_device_id { 759 760 __u16 svid;