Pull USB driver fixes from Greg KH: "Here are some small USB driver fixes for 5.17-rc2 that resolve a number of reported problems. These include: - typec driver fixes - xhci platform driver fixes for suspending - ulpi core fix - role.h build fix - new device ids - syzbot-reported bugfixes - gadget driver fixes - dwc3 driver fixes - other small fixes All of these have been in linux-next this week with no reported issues" * tag 'usb-5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: cdnsp: Fix segmentation fault in cdns_lost_power function usb: dwc2: gadget: don't try to disable ep0 in dwc2_hsotg_suspend usb: gadget: at91_udc: fix incorrect print type usb: dwc3: xilinx: Fix error handling when getting USB3 PHY usb: dwc3: xilinx: Skip resets and USB3 register settings for USB2.0 mode usb: xhci-plat: fix crash when suspend if remote wake enable usb: common: ulpi: Fix crash in ulpi_match() usb: gadget: f_sourcesink: Fix isoc transfer for USB_SPEED_SUPER_PLUS ucsi_ccg: Check DEV_INT bit only when starting CCG4 USB: core: Fix hang in usb_kill_urb by adding memory barriers usb-storage: Add unusual-devs entry for VL817 USB-SATA bridge usb: typec: tcpm: Do not disconnect when receiving VSAFE0V usb: typec: tcpm: Do not disconnect while receiving VBUS off usb: typec: Don't try to register component master without components usb: typec: Only attempt to link USB ports if there is fwnode usb: typec: tcpci: don't touch CC line if it's Vconn source usb: roles: fix include/linux/usb/role.h compile issue
Unified · Split
| @@ -483,11 +483,11 @@ int cdns_drd_exit(struct cdns *cdns) · 482 unmodified lines | ||
| 483 | 483 | /* Indicate the cdns3 core was power lost before */ |
| 484 | 484 | bool cdns_power_is_lost(struct cdns *cdns) |
| 485 | 485 | { |
| 486 | − if (cdns->version == CDNS3_CONTROLLER_V1) { | |
| 487 | − if (!(readl(&cdns->otg_v1_regs->simulate) & BIT(0))) | |
| 486 | + if (cdns->version == CDNS3_CONTROLLER_V0) { | |
| 487 | + if (!(readl(&cdns->otg_v0_regs->simulate) & BIT(0))) | |
| 488 | 488 | return true; |
| 489 | 489 | } else { |
| 490 | − if (!(readl(&cdns->otg_v0_regs->simulate) & BIT(0))) | |
| 490 | + if (!(readl(&cdns->otg_v1_regs->simulate) & BIT(0))) | |
| 491 | 491 | return true; |
| 492 | 492 | } |
| 493 | 493 | return false; |
| @@ -39,8 +39,11 @@ static int ulpi_match(struct device *dev, struct device_driver *driver) · 38 unmodified lines | ||
| 39 | 39 | struct ulpi *ulpi = to_ulpi_dev(dev); |
| 40 | 40 | const struct ulpi_device_id *id; |
| 41 | 41 | |
| 42 | − /* Some ULPI devices don't have a vendor id so rely on OF match */ | |
| 43 | − if (ulpi->id.vendor == 0) | |
| 42 | + /* | |
| 43 | + * Some ULPI devices don't have a vendor id | |
| 44 | + * or provide an id_table so rely on OF match. | |
| 45 | + */ | |
| 46 | + if (ulpi->id.vendor == 0 || !drv->id_table) | |
| 44 | 47 | return of_driver_match_device(dev, driver); |
| 45 | 48 | |
| 46 | 49 | for (id = drv->id_table; id->vendor; id++) |
| @@ -1563,6 +1563,13 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags) · 1562 unmodified lines | ||
| 1563 | 1563 | urb->hcpriv = NULL; |
| 1564 | 1564 | INIT_LIST_HEAD(&urb->urb_list); |
| 1565 | 1565 | atomic_dec(&urb->use_count); |
| 1566 | + /* | |
| 1567 | + * Order the write of urb->use_count above before the read | |
| 1568 | + * of urb->reject below. Pairs with the memory barriers in | |
| 1569 | + * usb_kill_urb() and usb_poison_urb(). | |
| 1570 | + */ | |
| 1571 | + smp_mb__after_atomic(); | |
| 1572 | + | |
| 1566 | 1573 | atomic_dec(&urb->dev->urbnum); |
| 1567 | 1574 | if (atomic_read(&urb->reject)) |
| 1568 | 1575 | wake_up(&usb_kill_urb_queue); |
| @@ -1665,6 +1672,13 @@ static void __usb_hcd_giveback_urb(struct urb *urb) · 96 unmodified lines | ||
| 1665 | 1672 | |
| 1666 | 1673 | usb_anchor_resume_wakeups(anchor); |
| 1667 | 1674 | atomic_dec(&urb->use_count); |
| 1675 | + /* | |
| 1676 | + * Order the write of urb->use_count above before the read | |
| 1677 | + * of urb->reject below. Pairs with the memory barriers in | |
| 1678 | + * usb_kill_urb() and usb_poison_urb(). | |
| 1679 | + */ | |
| 1680 | + smp_mb__after_atomic(); | |
| 1681 | + | |
| 1668 | 1682 | if (unlikely(atomic_read(&urb->reject))) |
| 1669 | 1683 | wake_up(&usb_kill_urb_queue); |
| 1670 | 1684 | usb_put_urb(urb); |
| @@ -715,6 +715,12 @@ void usb_kill_urb(struct urb *urb) · 714 unmodified lines | ||
| 715 | 715 | if (!(urb && urb->dev && urb->ep)) |
| 716 | 716 | return; |
| 717 | 717 | atomic_inc(&urb->reject); |
| 718 | + /* | |
| 719 | + * Order the write of urb->reject above before the read | |
| 720 | + * of urb->use_count below. Pairs with the barriers in | |
| 721 | + * __usb_hcd_giveback_urb() and usb_hcd_submit_urb(). | |
| 722 | + */ | |
| 723 | + smp_mb__after_atomic(); | |
| 718 | 724 | |
| 719 | 725 | usb_hcd_unlink_urb(urb, -ENOENT); |
| 720 | 726 | wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); |
| @@ -756,6 +762,12 @@ void usb_poison_urb(struct urb *urb) · 35 unmodified lines | ||
| 756 | 762 | if (!urb) |
| 757 | 763 | return; |
| 758 | 764 | atomic_inc(&urb->reject); |
| 765 | + /* | |
| 766 | + * Order the write of urb->reject above before the read | |
| 767 | + * of urb->use_count below. Pairs with the barriers in | |
| 768 | + * __usb_hcd_giveback_urb() and usb_hcd_submit_urb(). | |
| 769 | + */ | |
| 770 | + smp_mb__after_atomic(); | |
| 759 | 771 | |
| 760 | 772 | if (!urb->dev || !urb->ep) |
| 761 | 773 | return; |
| @@ -5097,7 +5097,7 @@ int dwc2_hsotg_suspend(struct dwc2_hsotg *hsotg) · 5096 unmodified lines | ||
| 5097 | 5097 | hsotg->gadget.speed = USB_SPEED_UNKNOWN; |
| 5098 | 5098 | spin_unlock_irqrestore(&hsotg->lock, flags); |
| 5099 | 5099 | |
| 5100 | − for (ep = 0; ep < hsotg->num_of_eps; ep++) { | |
| 5100 | + for (ep = 1; ep < hsotg->num_of_eps; ep++) { | |
| 5101 | 5101 | if (hsotg->eps_in[ep]) |
| 5102 | 5102 | dwc2_hsotg_ep_disable_lock(&hsotg->eps_in[ep]->ep); |
| 5103 | 5103 | if (hsotg->eps_out[ep]) |
| @@ -102,14 +102,26 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data) · 101 unmodified lines | ||
| 102 | 102 | int ret; |
| 103 | 103 | u32 reg; |
| 104 | 104 | |
| 105 | − usb3_phy = devm_phy_get(dev, "usb3-phy"); | |
| 106 | − if (PTR_ERR(usb3_phy) == -EPROBE_DEFER) { | |
| 107 | − ret = -EPROBE_DEFER; | |
| 105 | + usb3_phy = devm_phy_optional_get(dev, "usb3-phy"); | |
| 106 | + if (IS_ERR(usb3_phy)) { | |
| 107 | + ret = PTR_ERR(usb3_phy); | |
| 108 | + dev_err_probe(dev, ret, | |
| 109 | + "failed to get USB3 PHY\n"); | |
| 108 | 110 | goto err; |
| 109 | − } else if (IS_ERR(usb3_phy)) { | |
| 110 | − usb3_phy = NULL; | |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | + /* | |
| 114 | + * The following core resets are not required unless a USB3 PHY | |
| 115 | + * is used, and the subsequent register settings are not required | |
| 116 | + * unless a core reset is performed (they should be set properly | |
| 117 | + * by the first-stage boot loader, but may be reverted by a core | |
| 118 | + * reset). They may also break the configuration if USB3 is actually | |
| 119 | + * in use but the usb3-phy entry is missing from the device tree. | |
| 120 | + * Therefore, skip these operations in this case. | |
| 121 | + */ | |
| 122 | + if (!usb3_phy) | |
| 123 | + goto skip_usb3_phy; | |
| 124 | + | |
| 113 | 125 | crst = devm_reset_control_get_exclusive(dev, "usb_crst"); |
| 114 | 126 | if (IS_ERR(crst)) { |
| 115 | 127 | ret = PTR_ERR(crst); |
| @@ -188,6 +200,7 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data) · 72 unmodified lines | ||
| 188 | 200 | goto err; |
| 189 | 201 | } |
| 190 | 202 | |
| 203 | +skip_usb3_phy: | |
| 191 | 204 | /* |
| 192 | 205 | * This routes the USB DMA traffic to go through FPD path instead |
| 193 | 206 | * of reaching DDR directly. This traffic routing is needed to |
| @@ -584,6 +584,7 @@ static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in, · 583 unmodified lines | ||
| 584 | 584 | |
| 585 | 585 | if (is_iso) { |
| 586 | 586 | switch (speed) { |
| 587 | + case USB_SPEED_SUPER_PLUS: | |
| 587 | 588 | case USB_SPEED_SUPER: |
| 588 | 589 | size = ss->isoc_maxpacket * |
| 589 | 590 | (ss->isoc_mult + 1) * |
| @@ -1895,7 +1895,7 @@ static int at91udc_probe(struct platform_device *pdev) · 1894 unmodified lines | ||
| 1895 | 1895 | at91_vbus_irq, 0, driver_name, udc); |
| 1896 | 1896 | if (retval) { |
| 1897 | 1897 | DBG("request vbus irq %d failed\n", |
| 1898 | − udc->board.vbus_pin); | |
| 1898 | + desc_to_gpio(udc->board.vbus_pin)); | |
| 1899 | 1899 | goto err_unprepare_iclk; |
| 1900 | 1900 | } |
| 1901 | 1901 | } |
| @@ -437,6 +437,9 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev) · 436 unmodified lines | ||
| 437 | 437 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); |
| 438 | 438 | int ret; |
| 439 | 439 | |
| 440 | + if (pm_runtime_suspended(dev)) | |
| 441 | + pm_runtime_resume(dev); | |
| 442 | + | |
| 440 | 443 | ret = xhci_priv_suspend_quirk(hcd); |
| 441 | 444 | if (ret) |
| 442 | 445 | return ret; |
| @@ -2301,6 +2301,16 @@ UNUSUAL_DEV( 0x2027, 0xa001, 0x0000, 0x9999, · 2300 unmodified lines | ||
| 2301 | 2301 | USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init, |
| 2302 | 2302 | US_FL_SCM_MULT_TARG ), |
| 2303 | 2303 | |
| 2304 | +/* | |
| 2305 | + * Reported by DocMAX <mail@vacharakis.de> | |
| 2306 | + * and Thomas Weißschuh <linux@weissschuh.net> | |
| 2307 | + */ | |
| 2308 | +UNUSUAL_DEV( 0x2109, 0x0715, 0x9999, 0x9999, | |
| 2309 | + "VIA Labs, Inc.", | |
| 2310 | + "VL817 SATA Bridge", | |
| 2311 | + USB_SC_DEVICE, USB_PR_DEVICE, NULL, | |
| 2312 | + US_FL_IGNORE_UAS), | |
| 2313 | + | |
| 2304 | 2314 | UNUSUAL_DEV( 0x2116, 0x0320, 0x0001, 0x0001, |
| 2305 | 2315 | "ST", |
| 2306 | 2316 | "2A", |
| @@ -56,7 +56,12 @@ int typec_link_ports(struct typec_port *con) · 55 unmodified lines | ||
| 56 | 56 | { |
| 57 | 57 | struct each_port_arg arg = { .port = con, .match = NULL }; |
| 58 | 58 | |
| 59 | + if (!has_acpi_companion(&con->dev)) | |
| 60 | + return 0; | |
| 61 | + | |
| 59 | 62 | bus_for_each_dev(&acpi_bus_type, NULL, &arg, typec_port_match); |
| 63 | + if (!arg.match) | |
| 64 | + return 0; | |
| 60 | 65 | |
| 61 | 66 | /* |
| 62 | 67 | * REVISIT: Now each connector can have only a single component master. |
| @@ -74,5 +79,6 @@ int typec_link_ports(struct typec_port *con) · 11 unmodified lines | ||
| 74 | 79 | |
| 75 | 80 | void typec_unlink_ports(struct typec_port *con) |
| 76 | 81 | { |
| 77 | − component_master_del(&con->dev, &typec_aggregate_ops); | |
| 82 | + if (has_acpi_companion(&con->dev)) | |
| 83 | + component_master_del(&con->dev, &typec_aggregate_ops); | |
| 78 | 84 | } |
| @@ -75,9 +75,25 @@ static int tcpci_write16(struct tcpci *tcpci, unsigned int reg, u16 val) · 74 unmodified lines | ||
| 75 | 75 | static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc) |
| 76 | 76 | { |
| 77 | 77 | struct tcpci *tcpci = tcpc_to_tcpci(tcpc); |
| 78 | + bool vconn_pres; | |
| 79 | + enum typec_cc_polarity polarity = TYPEC_POLARITY_CC1; | |
| 78 | 80 | unsigned int reg; |
| 79 | 81 | int ret; |
| 80 | 82 | |
| 83 | + ret = regmap_read(tcpci->regmap, TCPC_POWER_STATUS, ®); | |
| 84 | + if (ret < 0) | |
| 85 | + return ret; | |
| 86 | + | |
| 87 | + vconn_pres = !!(reg & TCPC_POWER_STATUS_VCONN_PRES); | |
| 88 | + if (vconn_pres) { | |
| 89 | + ret = regmap_read(tcpci->regmap, TCPC_TCPC_CTRL, ®); | |
| 90 | + if (ret < 0) | |
| 91 | + return ret; | |
| 92 | + | |
| 93 | + if (reg & TCPC_TCPC_CTRL_ORIENTATION) | |
| 94 | + polarity = TYPEC_POLARITY_CC2; | |
| 95 | + } | |
| 96 | + | |
| 81 | 97 | switch (cc) { |
| 82 | 98 | case TYPEC_CC_RA: |
| 83 | 99 | reg = (TCPC_ROLE_CTRL_CC_RA << TCPC_ROLE_CTRL_CC1_SHIFT) | |
| @@ -112,6 +128,16 @@ static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc) · 28 unmodified lines | ||
| 112 | 128 | break; |
| 113 | 129 | } |
| 114 | 130 | |
| 131 | + if (vconn_pres) { | |
| 132 | + if (polarity == TYPEC_POLARITY_CC2) { | |
| 133 | + reg &= ~(TCPC_ROLE_CTRL_CC1_MASK << TCPC_ROLE_CTRL_CC1_SHIFT); | |
| 134 | + reg |= (TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC1_SHIFT); | |
| 135 | + } else { | |
| 136 | + reg &= ~(TCPC_ROLE_CTRL_CC2_MASK << TCPC_ROLE_CTRL_CC2_SHIFT); | |
| 137 | + reg |= (TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC2_SHIFT); | |
| 138 | + } | |
| 139 | + } | |
| 140 | + | |
| 115 | 141 | ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg); |
| 116 | 142 | if (ret < 0) |
| 117 | 143 | return ret; |
| @@ -98,6 +98,7 @@ · 97 unmodified lines | ||
| 98 | 98 | #define TCPC_POWER_STATUS_SOURCING_VBUS BIT(4) |
| 99 | 99 | #define TCPC_POWER_STATUS_VBUS_DET BIT(3) |
| 100 | 100 | #define TCPC_POWER_STATUS_VBUS_PRES BIT(2) |
| 101 | +#define TCPC_POWER_STATUS_VCONN_PRES BIT(1) | |
| 101 | 102 | #define TCPC_POWER_STATUS_SINKING_VBUS BIT(0) |
| 102 | 103 | |
| 103 | 104 | #define TCPC_FAULT_STATUS 0x1f |
| @@ -5156,7 +5156,8 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port) · 5155 unmodified lines | ||
| 5156 | 5156 | case SNK_TRYWAIT_DEBOUNCE: |
| 5157 | 5157 | break; |
| 5158 | 5158 | case SNK_ATTACH_WAIT: |
| 5159 | − tcpm_set_state(port, SNK_UNATTACHED, 0); | |
| 5159 | + case SNK_DEBOUNCED: | |
| 5160 | + /* Do nothing, as TCPM is still waiting for vbus to reaach VSAFE5V to connect */ | |
| 5160 | 5161 | break; |
| 5161 | 5162 | |
| 5162 | 5163 | case SNK_NEGOTIATE_CAPABILITIES: |
| @@ -5263,6 +5264,10 @@ static void _tcpm_pd_vbus_vsafe0v(struct tcpm_port *port) · 100 unmodified lines | ||
| 5263 | 5264 | case PR_SWAP_SNK_SRC_SOURCE_ON: |
| 5264 | 5265 | /* Do nothing, vsafe0v is expected during transition */ |
| 5265 | 5266 | break; |
| 5267 | + case SNK_ATTACH_WAIT: | |
| 5268 | + case SNK_DEBOUNCED: | |
| 5269 | + /*Do nothing, still waiting for VSAFE5V for connect */ | |
| 5270 | + break; | |
| 5266 | 5271 | default: |
| 5267 | 5272 | if (port->pwr_role == TYPEC_SINK && port->auto_vbus_discharge_enabled) |
| 5268 | 5273 | tcpm_set_state(port, SNK_UNATTACHED, 0); |
| @@ -325,7 +325,7 @@ static int ucsi_ccg_init(struct ucsi_ccg *uc) · 324 unmodified lines | ||
| 325 | 325 | if (status < 0) |
| 326 | 326 | return status; |
| 327 | 327 | |
| 328 | − if (!data) | |
| 328 | + if (!(data & DEV_INT)) | |
| 329 | 329 | return 0; |
| 330 | 330 | |
| 331 | 331 | status = ccg_write(uc, CCGX_RAB_INTR_REG, &data, sizeof(data)); |
| @@ -91,6 +91,12 @@ fwnode_usb_role_switch_get(struct fwnode_handle *node) · 90 unmodified lines | ||
| 91 | 91 | |
| 92 | 92 | static inline void usb_role_switch_put(struct usb_role_switch *sw) { } |
| 93 | 93 | |
| 94 | +static inline struct usb_role_switch * | |
| 95 | +usb_role_switch_find_by_fwnode(const struct fwnode_handle *fwnode) | |
| 96 | +{ | |
| 97 | + return NULL; | |
| 98 | +} | |
| 99 | + | |
| 94 | 100 | static inline struct usb_role_switch * |
| 95 | 101 | usb_role_switch_register(struct device *parent, |
| 96 | 102 | const struct usb_role_switch_desc *desc) |