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-6.18-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB/Thunderbolt fixes from Greg KH:
"Here are some last-minutes USB and Thunderbolt driver fixes and new
device ids for 6.18-rc8. Included in here are:

- usb storage quirk fixup

- xhci driver fixes for reported issues

- usb gadget driver fixes

- dwc3 driver fixes

- UAS driver fixup

- thunderbolt new device ids

- usb-serial driver new ids

All of these have been in linux-next with no reported issues, many for
many weeks"

* tag 'usb-6.18-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (21 commits)
usb: gadget: renesas_usbf: Handle devm_pm_runtime_enable() errors
USB: storage: Remove subclass and protocol overrides from Novatek quirk
usb: uas: fix urb unmapping issue when the uas device is remove during ongoing data transfer
usb: dwc3: Fix race condition between concurrent dwc3_remove_requests() call paths
xhci: dbgtty: fix device unregister
usb: storage: sddr55: Reject out-of-bound new_pba
USB: serial: option: add support for Rolling RW101R-GL
usb: typec: ucsi: psy: Set max current to zero when disconnected
usb: gadget: f_eem: Fix memory leak in eem_unwrap
usb: dwc3: pci: Sort out the Intel device IDs
usb: dwc3: pci: add support for the Intel Nova Lake -S
drivers/usb/dwc3: fix PCI parent check
usb: storage: Fix memory leak in USB bulk transport
xhci: sideband: Fix race condition in sideband unregister
xhci: dbgtty: Fix data corruption when transmitting data form DbC to host
xhci: fix stale flag preventig URBs after link state error is cleared
USB: serial: ftdi_sio: add support for u-blox EVK-M101
usb: cdns3: Fix double resource release in cdns3_pci_probe
usb: gadget: udc: fix use-after-free in usb_gadget_state_work
usb: renesas_usbhs: Fix synchronous external abort on unbind
...

+228 -108
+2
drivers/thunderbolt/nhi.c
··· 1538 1538 .driver_data = (kernel_ulong_t)&icl_nhi_ops }, 1539 1539 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_PTL_P_NHI1), 1540 1540 .driver_data = (kernel_ulong_t)&icl_nhi_ops }, 1541 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_WCL_NHI0), 1542 + .driver_data = (kernel_ulong_t)&icl_nhi_ops }, 1541 1543 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_80G_NHI) }, 1542 1544 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_40G_NHI) }, 1543 1545
+1
drivers/thunderbolt/nhi.h
··· 75 75 #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_BRIDGE 0x15ef 76 76 #define PCI_DEVICE_ID_INTEL_ADL_NHI0 0x463e 77 77 #define PCI_DEVICE_ID_INTEL_ADL_NHI1 0x466d 78 + #define PCI_DEVICE_ID_INTEL_WCL_NHI0 0x4d33 78 79 #define PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_80G_NHI 0x5781 79 80 #define PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_40G_NHI 0x5784 80 81 #define PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HUB_80G_BRIDGE 0x5786
+1 -4
drivers/usb/cdns3/cdns3-pci-wrap.c
··· 98 98 wrap = pci_get_drvdata(func); 99 99 } else { 100 100 wrap = kzalloc(sizeof(*wrap), GFP_KERNEL); 101 - if (!wrap) { 102 - pci_disable_device(pdev); 101 + if (!wrap) 103 102 return -ENOMEM; 104 - } 105 103 } 106 104 107 105 res = wrap->dev_res; ··· 158 160 /* register platform device */ 159 161 wrap->plat_dev = platform_device_register_full(&plat_info); 160 162 if (IS_ERR(wrap->plat_dev)) { 161 - pci_disable_device(pdev); 162 163 err = PTR_ERR(wrap->plat_dev); 163 164 kfree(wrap); 164 165 return err;
+2 -1
drivers/usb/dwc3/core.c
··· 25 25 #include <linux/of.h> 26 26 #include <linux/of_graph.h> 27 27 #include <linux/acpi.h> 28 + #include <linux/pci.h> 28 29 #include <linux/pinctrl/consumer.h> 29 30 #include <linux/pinctrl/devinfo.h> 30 31 #include <linux/reset.h> ··· 2242 2241 dev_set_drvdata(dev, dwc); 2243 2242 dwc3_cache_hwparams(dwc); 2244 2243 2245 - if (!dwc->sysdev_is_parent && 2244 + if (!dev_is_pci(dwc->sysdev) && 2246 2245 DWC3_GHWPARAMS0_AWIDTH(dwc->hwparams.hwparams0) == 64) { 2247 2246 ret = dma_set_mask_and_coherent(dwc->sysdev, DMA_BIT_MASK(64)); 2248 2247 if (ret)
+42 -40
drivers/usb/dwc3/dwc3-pci.c
··· 21 21 #include <linux/acpi.h> 22 22 #include <linux/delay.h> 23 23 24 - #define PCI_DEVICE_ID_INTEL_BYT 0x0f37 25 - #define PCI_DEVICE_ID_INTEL_MRFLD 0x119e 26 - #define PCI_DEVICE_ID_INTEL_BSW 0x22b7 27 - #define PCI_DEVICE_ID_INTEL_SPTLP 0x9d30 28 - #define PCI_DEVICE_ID_INTEL_SPTH 0xa130 29 - #define PCI_DEVICE_ID_INTEL_BXT 0x0aaa 30 - #define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa 31 - #define PCI_DEVICE_ID_INTEL_APL 0x5aaa 32 - #define PCI_DEVICE_ID_INTEL_KBP 0xa2b0 33 24 #define PCI_DEVICE_ID_INTEL_CMLLP 0x02ee 34 25 #define PCI_DEVICE_ID_INTEL_CMLH 0x06ee 26 + #define PCI_DEVICE_ID_INTEL_BXT 0x0aaa 27 + #define PCI_DEVICE_ID_INTEL_BYT 0x0f37 28 + #define PCI_DEVICE_ID_INTEL_MRFLD 0x119e 29 + #define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa 30 + #define PCI_DEVICE_ID_INTEL_BSW 0x22b7 35 31 #define PCI_DEVICE_ID_INTEL_GLK 0x31aa 36 - #define PCI_DEVICE_ID_INTEL_CNPLP 0x9dee 37 - #define PCI_DEVICE_ID_INTEL_CNPH 0xa36e 38 - #define PCI_DEVICE_ID_INTEL_CNPV 0xa3b0 39 32 #define PCI_DEVICE_ID_INTEL_ICLLP 0x34ee 40 - #define PCI_DEVICE_ID_INTEL_EHL 0x4b7e 41 - #define PCI_DEVICE_ID_INTEL_TGPLP 0xa0ee 42 33 #define PCI_DEVICE_ID_INTEL_TGPH 0x43ee 43 - #define PCI_DEVICE_ID_INTEL_JSP 0x4dee 44 - #define PCI_DEVICE_ID_INTEL_WCL 0x4d7e 45 34 #define PCI_DEVICE_ID_INTEL_ADL 0x460e 46 - #define PCI_DEVICE_ID_INTEL_ADL_PCH 0x51ee 47 35 #define PCI_DEVICE_ID_INTEL_ADLN 0x465e 36 + #define PCI_DEVICE_ID_INTEL_EHL 0x4b7e 37 + #define PCI_DEVICE_ID_INTEL_WCL 0x4d7e 38 + #define PCI_DEVICE_ID_INTEL_JSP 0x4dee 39 + #define PCI_DEVICE_ID_INTEL_ADL_PCH 0x51ee 48 40 #define PCI_DEVICE_ID_INTEL_ADLN_PCH 0x54ee 49 - #define PCI_DEVICE_ID_INTEL_ADLS 0x7ae1 50 - #define PCI_DEVICE_ID_INTEL_RPL 0xa70e 41 + #define PCI_DEVICE_ID_INTEL_APL 0x5aaa 42 + #define PCI_DEVICE_ID_INTEL_NVLS_PCH 0x6e6f 43 + #define PCI_DEVICE_ID_INTEL_ARLH_PCH 0x777e 51 44 #define PCI_DEVICE_ID_INTEL_RPLS 0x7a61 45 + #define PCI_DEVICE_ID_INTEL_MTL 0x7e7e 46 + #define PCI_DEVICE_ID_INTEL_ADLS 0x7ae1 52 47 #define PCI_DEVICE_ID_INTEL_MTLM 0x7eb1 53 48 #define PCI_DEVICE_ID_INTEL_MTLP 0x7ec1 54 49 #define PCI_DEVICE_ID_INTEL_MTLS 0x7f6f 55 - #define PCI_DEVICE_ID_INTEL_MTL 0x7e7e 56 - #define PCI_DEVICE_ID_INTEL_ARLH_PCH 0x777e 57 50 #define PCI_DEVICE_ID_INTEL_TGL 0x9a15 51 + #define PCI_DEVICE_ID_INTEL_SPTLP 0x9d30 52 + #define PCI_DEVICE_ID_INTEL_CNPLP 0x9dee 53 + #define PCI_DEVICE_ID_INTEL_TGPLP 0xa0ee 54 + #define PCI_DEVICE_ID_INTEL_SPTH 0xa130 55 + #define PCI_DEVICE_ID_INTEL_KBP 0xa2b0 56 + #define PCI_DEVICE_ID_INTEL_CNPH 0xa36e 57 + #define PCI_DEVICE_ID_INTEL_CNPV 0xa3b0 58 + #define PCI_DEVICE_ID_INTEL_RPL 0xa70e 58 59 #define PCI_DEVICE_ID_INTEL_PTLH 0xe332 59 60 #define PCI_DEVICE_ID_INTEL_PTLH_PCH 0xe37e 60 61 #define PCI_DEVICE_ID_INTEL_PTLU 0xe432 ··· 413 412 } 414 413 415 414 static const struct pci_device_id dwc3_pci_id_table[] = { 416 - { PCI_DEVICE_DATA(INTEL, BSW, &dwc3_pci_intel_swnode) }, 417 - { PCI_DEVICE_DATA(INTEL, BYT, &dwc3_pci_intel_byt_swnode) }, 418 - { PCI_DEVICE_DATA(INTEL, MRFLD, &dwc3_pci_intel_mrfld_swnode) }, 419 415 { PCI_DEVICE_DATA(INTEL, CMLLP, &dwc3_pci_intel_swnode) }, 420 416 { PCI_DEVICE_DATA(INTEL, CMLH, &dwc3_pci_intel_swnode) }, 421 - { PCI_DEVICE_DATA(INTEL, SPTLP, &dwc3_pci_intel_swnode) }, 422 - { PCI_DEVICE_DATA(INTEL, SPTH, &dwc3_pci_intel_swnode) }, 423 417 { PCI_DEVICE_DATA(INTEL, BXT, &dwc3_pci_intel_swnode) }, 418 + { PCI_DEVICE_DATA(INTEL, BYT, &dwc3_pci_intel_byt_swnode) }, 419 + { PCI_DEVICE_DATA(INTEL, MRFLD, &dwc3_pci_intel_mrfld_swnode) }, 424 420 { PCI_DEVICE_DATA(INTEL, BXT_M, &dwc3_pci_intel_swnode) }, 425 - { PCI_DEVICE_DATA(INTEL, APL, &dwc3_pci_intel_swnode) }, 426 - { PCI_DEVICE_DATA(INTEL, KBP, &dwc3_pci_intel_swnode) }, 421 + { PCI_DEVICE_DATA(INTEL, BSW, &dwc3_pci_intel_swnode) }, 427 422 { PCI_DEVICE_DATA(INTEL, GLK, &dwc3_pci_intel_swnode) }, 428 - { PCI_DEVICE_DATA(INTEL, CNPLP, &dwc3_pci_intel_swnode) }, 429 - { PCI_DEVICE_DATA(INTEL, CNPH, &dwc3_pci_intel_swnode) }, 430 - { PCI_DEVICE_DATA(INTEL, CNPV, &dwc3_pci_intel_swnode) }, 431 423 { PCI_DEVICE_DATA(INTEL, ICLLP, &dwc3_pci_intel_swnode) }, 432 - { PCI_DEVICE_DATA(INTEL, EHL, &dwc3_pci_intel_swnode) }, 433 - { PCI_DEVICE_DATA(INTEL, TGPLP, &dwc3_pci_intel_swnode) }, 434 424 { PCI_DEVICE_DATA(INTEL, TGPH, &dwc3_pci_intel_swnode) }, 435 - { PCI_DEVICE_DATA(INTEL, JSP, &dwc3_pci_intel_swnode) }, 436 - { PCI_DEVICE_DATA(INTEL, WCL, &dwc3_pci_intel_swnode) }, 437 425 { PCI_DEVICE_DATA(INTEL, ADL, &dwc3_pci_intel_swnode) }, 438 - { PCI_DEVICE_DATA(INTEL, ADL_PCH, &dwc3_pci_intel_swnode) }, 439 426 { PCI_DEVICE_DATA(INTEL, ADLN, &dwc3_pci_intel_swnode) }, 427 + { PCI_DEVICE_DATA(INTEL, EHL, &dwc3_pci_intel_swnode) }, 428 + { PCI_DEVICE_DATA(INTEL, WCL, &dwc3_pci_intel_swnode) }, 429 + { PCI_DEVICE_DATA(INTEL, JSP, &dwc3_pci_intel_swnode) }, 430 + { PCI_DEVICE_DATA(INTEL, ADL_PCH, &dwc3_pci_intel_swnode) }, 440 431 { PCI_DEVICE_DATA(INTEL, ADLN_PCH, &dwc3_pci_intel_swnode) }, 441 - { PCI_DEVICE_DATA(INTEL, ADLS, &dwc3_pci_intel_swnode) }, 442 - { PCI_DEVICE_DATA(INTEL, RPL, &dwc3_pci_intel_swnode) }, 432 + { PCI_DEVICE_DATA(INTEL, APL, &dwc3_pci_intel_swnode) }, 433 + { PCI_DEVICE_DATA(INTEL, NVLS_PCH, &dwc3_pci_intel_swnode) }, 434 + { PCI_DEVICE_DATA(INTEL, ARLH_PCH, &dwc3_pci_intel_swnode) }, 443 435 { PCI_DEVICE_DATA(INTEL, RPLS, &dwc3_pci_intel_swnode) }, 436 + { PCI_DEVICE_DATA(INTEL, MTL, &dwc3_pci_intel_swnode) }, 437 + { PCI_DEVICE_DATA(INTEL, ADLS, &dwc3_pci_intel_swnode) }, 444 438 { PCI_DEVICE_DATA(INTEL, MTLM, &dwc3_pci_intel_swnode) }, 445 439 { PCI_DEVICE_DATA(INTEL, MTLP, &dwc3_pci_intel_swnode) }, 446 - { PCI_DEVICE_DATA(INTEL, MTL, &dwc3_pci_intel_swnode) }, 447 440 { PCI_DEVICE_DATA(INTEL, MTLS, &dwc3_pci_intel_swnode) }, 448 - { PCI_DEVICE_DATA(INTEL, ARLH_PCH, &dwc3_pci_intel_swnode) }, 449 441 { PCI_DEVICE_DATA(INTEL, TGL, &dwc3_pci_intel_swnode) }, 442 + { PCI_DEVICE_DATA(INTEL, SPTLP, &dwc3_pci_intel_swnode) }, 443 + { PCI_DEVICE_DATA(INTEL, CNPLP, &dwc3_pci_intel_swnode) }, 444 + { PCI_DEVICE_DATA(INTEL, TGPLP, &dwc3_pci_intel_swnode) }, 445 + { PCI_DEVICE_DATA(INTEL, SPTH, &dwc3_pci_intel_swnode) }, 446 + { PCI_DEVICE_DATA(INTEL, KBP, &dwc3_pci_intel_swnode) }, 447 + { PCI_DEVICE_DATA(INTEL, CNPH, &dwc3_pci_intel_swnode) }, 448 + { PCI_DEVICE_DATA(INTEL, CNPV, &dwc3_pci_intel_swnode) }, 449 + { PCI_DEVICE_DATA(INTEL, RPL, &dwc3_pci_intel_swnode) }, 450 450 { PCI_DEVICE_DATA(INTEL, PTLH, &dwc3_pci_intel_swnode) }, 451 451 { PCI_DEVICE_DATA(INTEL, PTLH_PCH, &dwc3_pci_intel_swnode) }, 452 452 { PCI_DEVICE_DATA(INTEL, PTLU, &dwc3_pci_intel_swnode) },
+1
drivers/usb/dwc3/ep0.c
··· 94 94 req->request.actual = 0; 95 95 req->request.status = -EINPROGRESS; 96 96 req->epnum = dep->number; 97 + req->status = DWC3_REQUEST_STATUS_QUEUED; 97 98 98 99 list_add_tail(&req->list, &dep->pending_list); 99 100
+7
drivers/usb/dwc3/gadget.c
··· 228 228 { 229 229 struct dwc3 *dwc = dep->dwc; 230 230 231 + /* 232 + * The request might have been processed and completed while the 233 + * spinlock was released. Skip processing if already completed. 234 + */ 235 + if (req->status == DWC3_REQUEST_STATUS_COMPLETED) 236 + return; 237 + 231 238 dwc3_gadget_del_and_unmap_request(dep, req, status); 232 239 req->status = DWC3_REQUEST_STATUS_COMPLETED; 233 240
+6 -1
drivers/usb/gadget/function/f_eem.c
··· 477 477 req->complete = eem_cmd_complete; 478 478 req->zero = 1; 479 479 req->context = ctx; 480 - if (usb_ep_queue(port->in_ep, req, GFP_ATOMIC)) 480 + if (usb_ep_queue(port->in_ep, req, GFP_ATOMIC)) { 481 481 DBG(cdev, "echo response queue fail\n"); 482 + kfree(ctx); 483 + kfree(req->buf); 484 + usb_ep_free_request(ep, req); 485 + dev_kfree_skb_any(skb2); 486 + } 482 487 break; 483 488 484 489 case 1: /* echo response */
+16 -1
drivers/usb/gadget/udc/core.c
··· 1126 1126 void usb_gadget_set_state(struct usb_gadget *gadget, 1127 1127 enum usb_device_state state) 1128 1128 { 1129 + unsigned long flags; 1130 + 1131 + spin_lock_irqsave(&gadget->state_lock, flags); 1129 1132 gadget->state = state; 1130 - schedule_work(&gadget->work); 1133 + if (!gadget->teardown) 1134 + schedule_work(&gadget->work); 1135 + spin_unlock_irqrestore(&gadget->state_lock, flags); 1131 1136 trace_usb_gadget_set_state(gadget, 0); 1132 1137 } 1133 1138 EXPORT_SYMBOL_GPL(usb_gadget_set_state); ··· 1366 1361 void usb_initialize_gadget(struct device *parent, struct usb_gadget *gadget, 1367 1362 void (*release)(struct device *dev)) 1368 1363 { 1364 + spin_lock_init(&gadget->state_lock); 1365 + gadget->teardown = false; 1369 1366 INIT_WORK(&gadget->work, usb_gadget_state_work); 1370 1367 gadget->dev.parent = parent; 1371 1368 ··· 1542 1535 void usb_del_gadget(struct usb_gadget *gadget) 1543 1536 { 1544 1537 struct usb_udc *udc = gadget->udc; 1538 + unsigned long flags; 1545 1539 1546 1540 if (!udc) 1547 1541 return; ··· 1556 1548 kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE); 1557 1549 sysfs_remove_link(&udc->dev.kobj, "gadget"); 1558 1550 device_del(&gadget->dev); 1551 + /* 1552 + * Set the teardown flag before flushing the work to prevent new work 1553 + * from being scheduled while we are cleaning up. 1554 + */ 1555 + spin_lock_irqsave(&gadget->state_lock, flags); 1556 + gadget->teardown = true; 1557 + spin_unlock_irqrestore(&gadget->state_lock, flags); 1559 1558 flush_work(&gadget->work); 1560 1559 ida_free(&gadget_id_numbers, gadget->id_number); 1561 1560 cancel_work_sync(&udc->vbus_work);
+3 -1
drivers/usb/gadget/udc/renesas_usbf.c
··· 3262 3262 if (IS_ERR(udc->regs)) 3263 3263 return PTR_ERR(udc->regs); 3264 3264 3265 - devm_pm_runtime_enable(&pdev->dev); 3265 + ret = devm_pm_runtime_enable(&pdev->dev); 3266 + if (ret) 3267 + return ret; 3266 3268 ret = pm_runtime_resume_and_get(&pdev->dev); 3267 3269 if (ret < 0) 3268 3270 return ret;
+1
drivers/usb/host/xhci-dbgcap.h
··· 114 114 unsigned int tx_boundary; 115 115 116 116 bool registered; 117 + bool tx_running; 117 118 }; 118 119 119 120 struct dbc_driver {
+22 -1
drivers/usb/host/xhci-dbgtty.c
··· 47 47 return len; 48 48 } 49 49 50 - static int dbc_start_tx(struct dbc_port *port) 50 + static int dbc_do_start_tx(struct dbc_port *port) 51 51 __releases(&port->port_lock) 52 52 __acquires(&port->port_lock) 53 53 { ··· 56 56 int status = 0; 57 57 bool do_tty_wake = false; 58 58 struct list_head *pool = &port->write_pool; 59 + 60 + port->tx_running = true; 59 61 60 62 while (!list_empty(pool)) { 61 63 req = list_entry(pool->next, struct dbc_request, list_pool); ··· 79 77 } 80 78 } 81 79 80 + port->tx_running = false; 81 + 82 82 if (do_tty_wake && port->port.tty) 83 83 tty_wakeup(port->port.tty); 84 84 85 85 return status; 86 + } 87 + 88 + /* must be called with port->port_lock held */ 89 + static int dbc_start_tx(struct dbc_port *port) 90 + { 91 + lockdep_assert_held(&port->port_lock); 92 + 93 + if (port->tx_running) 94 + return -EBUSY; 95 + 96 + return dbc_do_start_tx(port); 86 97 } 87 98 88 99 static void dbc_start_rx(struct dbc_port *port) ··· 550 535 551 536 if (!port->registered) 552 537 return; 538 + /* 539 + * Hang up the TTY. This wakes up any blocked 540 + * writers and causes subsequent writes to fail. 541 + */ 542 + tty_vhangup(port->port.tty); 543 + 553 544 tty_unregister_device(dbc_tty_driver, port->minor); 554 545 xhci_dbc_tty_exit_port(port); 555 546 port->registered = false;
+10 -5
drivers/usb/host/xhci-ring.c
··· 1985 1985 1986 1986 static void handle_port_status(struct xhci_hcd *xhci, union xhci_trb *event) 1987 1987 { 1988 + struct xhci_virt_device *vdev = NULL; 1988 1989 struct usb_hcd *hcd; 1989 1990 u32 port_id; 1990 1991 u32 portsc, cmd_reg; ··· 2017 2016 goto cleanup; 2018 2017 } 2019 2018 2019 + if (port->slot_id) 2020 + vdev = xhci->devs[port->slot_id]; 2021 + 2020 2022 /* We might get interrupts after shared_hcd is removed */ 2021 2023 if (port->rhub == &xhci->usb3_rhub && xhci->shared_hcd == NULL) { 2022 2024 xhci_dbg(xhci, "ignore port event for removed USB3 hcd\n"); ··· 2042 2038 usb_hcd_resume_root_hub(hcd); 2043 2039 } 2044 2040 2045 - if (hcd->speed >= HCD_USB3 && 2046 - (portsc & PORT_PLS_MASK) == XDEV_INACTIVE) { 2047 - if (port->slot_id && xhci->devs[port->slot_id]) 2048 - xhci->devs[port->slot_id]->flags |= VDEV_PORT_ERROR; 2041 + if (vdev && (portsc & PORT_PLS_MASK) == XDEV_INACTIVE) { 2042 + if (!(portsc & PORT_RESET)) 2043 + vdev->flags |= VDEV_PORT_ERROR; 2044 + } else if (vdev && portsc & PORT_RC) { 2045 + vdev->flags &= ~VDEV_PORT_ERROR; 2049 2046 } 2050 2047 2051 2048 if ((portsc & PORT_PLC) && (portsc & PORT_PLS_MASK) == XDEV_RESUME) { ··· 2104 2099 * so the roothub behavior is consistent with external 2105 2100 * USB 3.0 hub behavior. 2106 2101 */ 2107 - if (port->slot_id && xhci->devs[port->slot_id]) 2102 + if (vdev) 2108 2103 xhci_ring_device(xhci, port->slot_id); 2109 2104 if (bus_state->port_remote_wakeup & (1 << hcd_portnum)) { 2110 2105 xhci_test_and_clear_bit(xhci, port, PORT_PLC);
+58 -44
drivers/usb/host/xhci-sideband.c
··· 73 73 return NULL; 74 74 } 75 75 76 + /* Caller must hold sb->mutex */ 76 77 static void 77 78 __xhci_sideband_remove_endpoint(struct xhci_sideband *sb, struct xhci_virt_ep *ep) 78 79 { 80 + lockdep_assert_held(&sb->mutex); 81 + 79 82 /* 80 83 * Issue a stop endpoint command when an endpoint is removed. 81 84 * The stop ep cmd handler will handle the ring cleanup. ··· 87 84 88 85 ep->sideband = NULL; 89 86 sb->eps[ep->ep_index] = NULL; 87 + } 88 + 89 + /* Caller must hold sb->mutex */ 90 + static void 91 + __xhci_sideband_remove_interrupter(struct xhci_sideband *sb) 92 + { 93 + struct usb_device *udev; 94 + 95 + lockdep_assert_held(&sb->mutex); 96 + 97 + if (!sb->ir) 98 + return; 99 + 100 + xhci_remove_secondary_interrupter(xhci_to_hcd(sb->xhci), sb->ir); 101 + sb->ir = NULL; 102 + udev = sb->vdev->udev; 103 + 104 + if (udev->state != USB_STATE_NOTATTACHED) 105 + usb_offload_put(udev); 90 106 } 91 107 92 108 /* sideband api functions */ ··· 153 131 struct xhci_virt_ep *ep; 154 132 unsigned int ep_index; 155 133 156 - mutex_lock(&sb->mutex); 134 + guard(mutex)(&sb->mutex); 135 + 136 + if (!sb->vdev) 137 + return -ENODEV; 138 + 157 139 ep_index = xhci_get_endpoint_index(&host_ep->desc); 158 140 ep = &sb->vdev->eps[ep_index]; 159 141 160 - if (ep->ep_state & EP_HAS_STREAMS) { 161 - mutex_unlock(&sb->mutex); 142 + if (ep->ep_state & EP_HAS_STREAMS) 162 143 return -EINVAL; 163 - } 164 144 165 145 /* 166 146 * Note, we don't know the DMA mask of the audio DSP device, if its ··· 172 148 * and let this function add the endpoint and allocate the ring buffer 173 149 * with the smallest common DMA mask 174 150 */ 175 - if (sb->eps[ep_index] || ep->sideband) { 176 - mutex_unlock(&sb->mutex); 151 + if (sb->eps[ep_index] || ep->sideband) 177 152 return -EBUSY; 178 - } 179 153 180 154 ep->sideband = sb; 181 155 sb->eps[ep_index] = ep; 182 - mutex_unlock(&sb->mutex); 183 156 184 157 return 0; 185 158 } ··· 201 180 struct xhci_virt_ep *ep; 202 181 unsigned int ep_index; 203 182 204 - mutex_lock(&sb->mutex); 183 + guard(mutex)(&sb->mutex); 184 + 205 185 ep_index = xhci_get_endpoint_index(&host_ep->desc); 206 186 ep = sb->eps[ep_index]; 207 187 208 - if (!ep || !ep->sideband || ep->sideband != sb) { 209 - mutex_unlock(&sb->mutex); 188 + if (!ep || !ep->sideband || ep->sideband != sb) 210 189 return -ENODEV; 211 - } 212 190 213 191 __xhci_sideband_remove_endpoint(sb, ep); 214 192 xhci_initialize_ring_info(ep->ring); 215 - mutex_unlock(&sb->mutex); 216 193 217 194 return 0; 218 195 } ··· 335 316 if (!sb || !sb->xhci) 336 317 return -ENODEV; 337 318 338 - mutex_lock(&sb->mutex); 339 - if (sb->ir) { 340 - ret = -EBUSY; 341 - goto out; 342 - } 319 + guard(mutex)(&sb->mutex); 320 + 321 + if (!sb->vdev) 322 + return -ENODEV; 323 + 324 + if (sb->ir) 325 + return -EBUSY; 343 326 344 327 sb->ir = xhci_create_secondary_interrupter(xhci_to_hcd(sb->xhci), 345 328 num_seg, imod_interval, 346 329 intr_num); 347 - if (!sb->ir) { 348 - ret = -ENOMEM; 349 - goto out; 350 - } 330 + if (!sb->ir) 331 + return -ENOMEM; 351 332 352 333 udev = sb->vdev->udev; 353 334 ret = usb_offload_get(udev); 354 335 355 336 sb->ir->ip_autoclear = ip_autoclear; 356 - 357 - out: 358 - mutex_unlock(&sb->mutex); 359 337 360 338 return ret; 361 339 } ··· 368 352 void 369 353 xhci_sideband_remove_interrupter(struct xhci_sideband *sb) 370 354 { 371 - struct usb_device *udev; 372 - 373 - if (!sb || !sb->ir) 355 + if (!sb) 374 356 return; 375 357 376 - mutex_lock(&sb->mutex); 377 - xhci_remove_secondary_interrupter(xhci_to_hcd(sb->xhci), sb->ir); 358 + guard(mutex)(&sb->mutex); 378 359 379 - sb->ir = NULL; 380 - udev = sb->vdev->udev; 381 - 382 - if (udev->state != USB_STATE_NOTATTACHED) 383 - usb_offload_put(udev); 384 - 385 - mutex_unlock(&sb->mutex); 360 + __xhci_sideband_remove_interrupter(sb); 386 361 } 387 362 EXPORT_SYMBOL_GPL(xhci_sideband_remove_interrupter); 388 363 ··· 472 465 void 473 466 xhci_sideband_unregister(struct xhci_sideband *sb) 474 467 { 468 + struct xhci_virt_device *vdev; 475 469 struct xhci_hcd *xhci; 476 470 int i; 477 471 ··· 481 473 482 474 xhci = sb->xhci; 483 475 484 - mutex_lock(&sb->mutex); 485 - for (i = 0; i < EP_CTX_PER_DEV; i++) 486 - if (sb->eps[i]) 487 - __xhci_sideband_remove_endpoint(sb, sb->eps[i]); 488 - mutex_unlock(&sb->mutex); 476 + scoped_guard(mutex, &sb->mutex) { 477 + vdev = sb->vdev; 478 + if (!vdev) 479 + return; 489 480 490 - xhci_sideband_remove_interrupter(sb); 481 + for (i = 0; i < EP_CTX_PER_DEV; i++) 482 + if (sb->eps[i]) 483 + __xhci_sideband_remove_endpoint(sb, sb->eps[i]); 484 + 485 + __xhci_sideband_remove_interrupter(sb); 486 + 487 + sb->vdev = NULL; 488 + } 491 489 492 490 spin_lock_irq(&xhci->lock); 493 491 sb->xhci = NULL; 494 - sb->vdev->sideband = NULL; 492 + vdev->sideband = NULL; 495 493 spin_unlock_irq(&xhci->lock); 496 494 497 495 kfree(sb);
+1
drivers/usb/host/xhci.c
··· 4007 4007 xhci_get_slot_state(xhci, virt_dev->out_ctx)); 4008 4008 xhci_dbg(xhci, "Not freeing device rings.\n"); 4009 4009 /* Don't treat this as an error. May change my mind later. */ 4010 + virt_dev->flags = 0; 4010 4011 ret = 0; 4011 4012 goto command_cleanup; 4012 4013 case COMP_SUCCESS:
+7 -7
drivers/usb/renesas_usbhs/common.c
··· 813 813 814 814 flush_delayed_work(&priv->notify_hotplug_work); 815 815 816 - /* power off */ 817 - if (!usbhs_get_dparam(priv, runtime_pwctrl)) 818 - usbhsc_power_ctrl(priv, 0); 819 - 820 - pm_runtime_disable(&pdev->dev); 821 - 822 816 usbhs_platform_call(priv, hardware_exit, pdev); 823 - usbhsc_clk_put(priv); 824 817 reset_control_assert(priv->rsts); 825 818 usbhs_mod_remove(priv); 826 819 usbhs_fifo_remove(priv); 827 820 usbhs_pipe_remove(priv); 821 + 822 + /* power off */ 823 + if (!usbhs_get_dparam(priv, runtime_pwctrl)) 824 + usbhsc_power_ctrl(priv, 0); 825 + 826 + usbhsc_clk_put(priv); 827 + pm_runtime_disable(&pdev->dev); 828 828 } 829 829 830 830 static int usbhsc_suspend(struct device *dev)
+1
drivers/usb/serial/ftdi_sio.c
··· 1074 1074 /* U-Blox devices */ 1075 1075 { USB_DEVICE(UBLOX_VID, UBLOX_C099F9P_ZED_PID) }, 1076 1076 { USB_DEVICE(UBLOX_VID, UBLOX_C099F9P_ODIN_PID) }, 1077 + { USB_DEVICE_INTERFACE_NUMBER(UBLOX_VID, UBLOX_EVK_M101_PID, 2) }, 1077 1078 /* FreeCalypso USB adapters */ 1078 1079 { USB_DEVICE(FTDI_VID, FTDI_FALCONIA_JTAG_BUF_PID), 1079 1080 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
+1
drivers/usb/serial/ftdi_sio_ids.h
··· 1614 1614 #define UBLOX_VID 0x1546 1615 1615 #define UBLOX_C099F9P_ZED_PID 0x0502 1616 1616 #define UBLOX_C099F9P_ODIN_PID 0x0503 1617 + #define UBLOX_EVK_M101_PID 0x0506 1617 1618 1618 1619 /* 1619 1620 * GMC devices
+8 -2
drivers/usb/serial/option.c
··· 2424 2424 { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1406, 0xff) }, /* GosunCn GM500 ECM/NCM */ 2425 2425 { USB_DEVICE(0x33f8, 0x0104), /* Rolling RW101-GL (laptop RMNET) */ 2426 2426 .driver_info = RSVD(4) | RSVD(5) }, 2427 + { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x0115, 0xff), /* Rolling RW135-GL (laptop MBIM) */ 2428 + .driver_info = RSVD(5) }, 2427 2429 { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x01a2, 0xff) }, /* Rolling RW101-GL (laptop MBIM) */ 2428 2430 { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x01a3, 0xff) }, /* Rolling RW101-GL (laptop MBIM) */ 2429 2431 { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x01a4, 0xff), /* Rolling RW101-GL (laptop MBIM) */ 2430 2432 .driver_info = RSVD(4) }, 2431 - { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x0115, 0xff), /* Rolling RW135-GL (laptop MBIM) */ 2432 - .driver_info = RSVD(5) }, 2433 + { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x01a8, 0xff), /* Rolling RW101R-GL (laptop MBIM) */ 2434 + .driver_info = RSVD(4) }, 2435 + { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x01a9, 0xff), /* Rolling RW101R-GL (laptop MBIM) */ 2436 + .driver_info = RSVD(4) }, 2437 + { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x0301, 0xff) }, /* Rolling RW101R-GL (laptop MBIM) */ 2438 + { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x0302, 0xff) }, /* Rolling RW101R-GL (laptop MBIM) */ 2433 2439 { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x0802, 0xff), /* Rolling RW350-GL (laptop MBIM) */ 2434 2440 .driver_info = RSVD(5) }, 2435 2441 { USB_DEVICE_AND_INTERFACE_INFO(0x3731, 0x0100, 0xff, 0xff, 0x30) }, /* NetPrisma LCUK54-WWD for Global */
+6
drivers/usb/storage/sddr55.c
··· 469 469 new_pba = (status[3] + (status[4] << 8) + (status[5] << 16)) 470 470 >> info->blockshift; 471 471 472 + /* check if device-reported new_pba is out of range */ 473 + if (new_pba >= (info->capacity >> (info->blockshift + info->pageshift))) { 474 + result = USB_STOR_TRANSPORT_FAILED; 475 + goto leave; 476 + } 477 + 472 478 /* check status for error */ 473 479 if (status[0] == 0xff && status[1] == 0x4) { 474 480 info->pba_to_lba[new_pba] = BAD_BLOCK;
+16
drivers/usb/storage/transport.c
··· 1200 1200 US_BULK_CS_WRAP_LEN && 1201 1201 bcs->Signature == 1202 1202 cpu_to_le32(US_BULK_CS_SIGN)) { 1203 + unsigned char buf[US_BULK_CS_WRAP_LEN]; 1204 + 1203 1205 usb_stor_dbg(us, "Device skipped data phase\n"); 1206 + 1207 + /* 1208 + * Devices skipping data phase might leave CSW data in srb's 1209 + * transfer buffer. Zero it to prevent USB protocol leakage. 1210 + */ 1211 + sg = NULL; 1212 + offset = 0; 1213 + memset(buf, 0, sizeof(buf)); 1214 + if (usb_stor_access_xfer_buf(buf, 1215 + US_BULK_CS_WRAP_LEN, srb, &sg, 1216 + &offset, TO_XFER_BUF) != 1217 + US_BULK_CS_WRAP_LEN) 1218 + usb_stor_dbg(us, "Failed to clear CSW data\n"); 1219 + 1204 1220 scsi_set_resid(srb, transfer_length); 1205 1221 goto skipped_data_phase; 1206 1222 }
+5
drivers/usb/storage/uas.c
··· 698 698 * of queueing, no matter how fatal the error 699 699 */ 700 700 if (err == -ENODEV) { 701 + if (cmdinfo->state & (COMMAND_INFLIGHT | DATA_IN_URB_INFLIGHT | 702 + DATA_OUT_URB_INFLIGHT)) 703 + goto out; 704 + 701 705 set_host_byte(cmnd, DID_NO_CONNECT); 702 706 scsi_done(cmnd); 703 707 goto zombie; ··· 715 711 uas_add_work(cmnd); 716 712 } 717 713 714 + out: 718 715 devinfo->cmnd[idx] = cmnd; 719 716 zombie: 720 717 spin_unlock_irqrestore(&devinfo->lock, flags);
+1 -1
drivers/usb/storage/unusual_devs.h
··· 938 938 UNUSUAL_DEV( 0x0603, 0x8611, 0x0000, 0xffff, 939 939 "Novatek", 940 940 "NTK96550-based camera", 941 - USB_SC_SCSI, USB_PR_BULK, NULL, 941 + USB_SC_DEVICE, USB_PR_DEVICE, NULL, 942 942 US_FL_BULK_IGNORE_TAG ), 943 943 944 944 /*
+5
drivers/usb/typec/ucsi/psy.c
··· 145 145 { 146 146 u32 pdo; 147 147 148 + if (!UCSI_CONSTAT(con, CONNECTED)) { 149 + val->intval = 0; 150 + return 0; 151 + } 152 + 148 153 switch (UCSI_CONSTAT(con, PWR_OPMODE)) { 149 154 case UCSI_CONSTAT_PWR_OPMODE_PD: 150 155 if (con->num_pdos > 0) {
+5
include/linux/usb/gadget.h
··· 376 376 * can handle. The UDC must support this and all slower speeds and lower 377 377 * number of lanes. 378 378 * @state: the state we are now (attached, suspended, configured, etc) 379 + * @state_lock: Spinlock protecting the `state` and `teardown` members. 380 + * @teardown: True if the device is undergoing teardown, used to prevent 381 + * new work from being scheduled during cleanup. 379 382 * @name: Identifies the controller hardware type. Used in diagnostics 380 383 * and sometimes configuration. 381 384 * @dev: Driver model state for this abstract device. ··· 454 451 enum usb_ssp_rate max_ssp_rate; 455 452 456 453 enum usb_device_state state; 454 + spinlock_t state_lock; 455 + bool teardown; 457 456 const char *name; 458 457 struct device dev; 459 458 unsigned isoch_delay;