History

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

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

Linus Torvalds committed 4 years ago

Commit 44aa31a2 parents cb323ee 79aa3e116 files · +115 −15Browse files

Unified · Split

16 files
  1. drivers/usb/cdns3/drd.c +3 −3
  2. drivers/usb/common/ulpi.c +5 −2
  3. drivers/usb/core/hcd.c +14 −0
  4. drivers/usb/core/urb.c +12 −0
  5. drivers/usb/dwc2/gadget.c +1 −1
  6. drivers/usb/dwc3/dwc3-xilinx.c +18 −5
  7. drivers/usb/gadget/function/f_sourcesink.c +1 −0
  8. drivers/usb/gadget/udc/at91_udc.c +1 −1
  9. drivers/usb/host/xhci-plat.c +3 −0
  10. drivers/usb/storage/unusual_devs.h +10 −0
  11. drivers/usb/typec/port-mapper.c +7 −1
  12. drivers/usb/typec/tcpm/tcpci.c +26 −0
  13. drivers/usb/typec/tcpm/tcpci.h +1 −0
  14. drivers/usb/typec/tcpm/tcpm.c +6 −1
  15. drivers/usb/typec/ucsi/ucsi_ccg.c +1 −1
  16. include/linux/usb/role.h +6 −0
drivers/usb/cdns3/drd.c+3−3
@@ -483,11 +483,11 @@ int cdns_drd_exit(struct cdns *cdns) · 482 unmodified lines
483/* Indicate the cdns3 core was power lost before */483/* Indicate the cdns3 core was power lost before */
484bool cdns_power_is_lost(struct cdns *cdns)484bool cdns_power_is_lost(struct cdns *cdns)
485{485{
486 if (cdns->version == CDNS3_CONTROLLER_V1) {486 if (cdns->version == CDNS3_CONTROLLER_V0) {
487 if (!(readl(&cdns->otg_v1_regs->simulate) & BIT(0)))487 if (!(readl(&cdns->otg_v0_regs->simulate) & BIT(0)))
488 return true;488 return true;
489 } else {489 } else {
490 if (!(readl(&cdns->otg_v0_regs->simulate) & BIT(0)))490 if (!(readl(&cdns->otg_v1_regs->simulate) & BIT(0)))
491 return true;491 return true;
492 }492 }
493 return false;493 return false;
drivers/usb/common/ulpi.c+5−2
@@ -39,8 +39,11 @@ static int ulpi_match(struct device *dev, struct device_driver *driver) · 38 unmodified lines
39 struct ulpi *ulpi = to_ulpi_dev(dev);39 struct ulpi *ulpi = to_ulpi_dev(dev);
40 const struct ulpi_device_id *id;40 const struct ulpi_device_id *id;
41 41
42 /* Some ULPI devices don't have a vendor id so rely on OF match */42 /*
43 if (ulpi->id.vendor == 0)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 return of_driver_match_device(dev, driver);47 return of_driver_match_device(dev, driver);
45 48
46 for (id = drv->id_table; id->vendor; id++)49 for (id = drv->id_table; id->vendor; id++)
drivers/usb/core/hcd.c+14−0
@@ -1563,6 +1563,13 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags) · 1562 unmodified lines
1563 urb->hcpriv = NULL;1563 urb->hcpriv = NULL;
1564 INIT_LIST_HEAD(&urb->urb_list);1564 INIT_LIST_HEAD(&urb->urb_list);
1565 atomic_dec(&urb->use_count);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 atomic_dec(&urb->dev->urbnum);1573 atomic_dec(&urb->dev->urbnum);
1567 if (atomic_read(&urb->reject))1574 if (atomic_read(&urb->reject))
1568 wake_up(&usb_kill_urb_queue);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 usb_anchor_resume_wakeups(anchor);1673 usb_anchor_resume_wakeups(anchor);
1667 atomic_dec(&urb->use_count);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 if (unlikely(atomic_read(&urb->reject)))1682 if (unlikely(atomic_read(&urb->reject)))
1669 wake_up(&usb_kill_urb_queue);1683 wake_up(&usb_kill_urb_queue);
1670 usb_put_urb(urb);1684 usb_put_urb(urb);
drivers/usb/core/urb.c+12−0
@@ -715,6 +715,12 @@ void usb_kill_urb(struct urb *urb) · 714 unmodified lines
715 if (!(urb && urb->dev && urb->ep))715 if (!(urb && urb->dev && urb->ep))
716 return;716 return;
717 atomic_inc(&urb->reject);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 usb_hcd_unlink_urb(urb, -ENOENT);725 usb_hcd_unlink_urb(urb, -ENOENT);
720 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0);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 if (!urb)762 if (!urb)
757 return;763 return;
758 atomic_inc(&urb->reject);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 if (!urb->dev || !urb->ep)772 if (!urb->dev || !urb->ep)
761 return;773 return;
drivers/usb/dwc2/gadget.c+1−1
@@ -5097,7 +5097,7 @@ int dwc2_hsotg_suspend(struct dwc2_hsotg *hsotg) · 5096 unmodified lines
5097 hsotg->gadget.speed = USB_SPEED_UNKNOWN;5097 hsotg->gadget.speed = USB_SPEED_UNKNOWN;
5098 spin_unlock_irqrestore(&hsotg->lock, flags);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 if (hsotg->eps_in[ep])5101 if (hsotg->eps_in[ep])
5102 dwc2_hsotg_ep_disable_lock(&hsotg->eps_in[ep]->ep);5102 dwc2_hsotg_ep_disable_lock(&hsotg->eps_in[ep]->ep);
5103 if (hsotg->eps_out[ep])5103 if (hsotg->eps_out[ep])
drivers/usb/dwc3/dwc3-xilinx.c+18−5
@@ -102,14 +102,26 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data) · 101 unmodified lines
102 int ret;102 int ret;
103 u32 reg;103 u32 reg;
104 104
105 usb3_phy = devm_phy_get(dev, "usb3-phy");105 usb3_phy = devm_phy_optional_get(dev, "usb3-phy");
106 if (PTR_ERR(usb3_phy) == -EPROBE_DEFER) {106 if (IS_ERR(usb3_phy)) {
107 ret = -EPROBE_DEFER;107 ret = PTR_ERR(usb3_phy);
108 dev_err_probe(dev, ret,
109 "failed to get USB3 PHY\n");
108 goto err;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 crst = devm_reset_control_get_exclusive(dev, "usb_crst");125 crst = devm_reset_control_get_exclusive(dev, "usb_crst");
114 if (IS_ERR(crst)) {126 if (IS_ERR(crst)) {
115 ret = PTR_ERR(crst);127 ret = PTR_ERR(crst);
@@ -188,6 +200,7 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data) · 72 unmodified lines
188 goto err;200 goto err;
189 }201 }
190 202
203skip_usb3_phy:
191 /*204 /*
192 * This routes the USB DMA traffic to go through FPD path instead205 * This routes the USB DMA traffic to go through FPD path instead
193 * of reaching DDR directly. This traffic routing is needed to206 * of reaching DDR directly. This traffic routing is needed to
drivers/usb/gadget/function/f_sourcesink.c+1−0
@@ -584,6 +584,7 @@ static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in, · 583 unmodified lines
584 584
585 if (is_iso) {585 if (is_iso) {
586 switch (speed) {586 switch (speed) {
587 case USB_SPEED_SUPER_PLUS:
587 case USB_SPEED_SUPER:588 case USB_SPEED_SUPER:
588 size = ss->isoc_maxpacket *589 size = ss->isoc_maxpacket *
589 (ss->isoc_mult + 1) *590 (ss->isoc_mult + 1) *
drivers/usb/gadget/udc/at91_udc.c+1−1
@@ -1895,7 +1895,7 @@ static int at91udc_probe(struct platform_device *pdev) · 1894 unmodified lines
1895 at91_vbus_irq, 0, driver_name, udc);1895 at91_vbus_irq, 0, driver_name, udc);
1896 if (retval) {1896 if (retval) {
1897 DBG("request vbus irq %d failed\n",1897 DBG("request vbus irq %d failed\n",
1898 udc->board.vbus_pin);1898 desc_to_gpio(udc->board.vbus_pin));
1899 goto err_unprepare_iclk;1899 goto err_unprepare_iclk;
1900 }1900 }
1901 }1901 }
drivers/usb/host/xhci-plat.c+3−0
@@ -437,6 +437,9 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev) · 436 unmodified lines
437 struct xhci_hcd *xhci = hcd_to_xhci(hcd);437 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
438 int ret;438 int ret;
439 439
440 if (pm_runtime_suspended(dev))
441 pm_runtime_resume(dev);
442
440 ret = xhci_priv_suspend_quirk(hcd);443 ret = xhci_priv_suspend_quirk(hcd);
441 if (ret)444 if (ret)
442 return ret;445 return ret;
drivers/usb/storage/unusual_devs.h+10−0
@@ -2301,6 +2301,16 @@ UNUSUAL_DEV( 0x2027, 0xa001, 0x0000, 0x9999, · 2300 unmodified lines
2301 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,2301 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
2302 US_FL_SCM_MULT_TARG ),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 */
2308UNUSUAL_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
2304UNUSUAL_DEV( 0x2116, 0x0320, 0x0001, 0x0001,2314UNUSUAL_DEV( 0x2116, 0x0320, 0x0001, 0x0001,
2305 "ST",2315 "ST",
2306 "2A",2316 "2A",
drivers/usb/typec/port-mapper.c+7−1
@@ -56,7 +56,12 @@ int typec_link_ports(struct typec_port *con) · 55 unmodified lines
56{56{
57 struct each_port_arg arg = { .port = con, .match = NULL };57 struct each_port_arg arg = { .port = con, .match = NULL };
58 58
59 if (!has_acpi_companion(&con->dev))
60 return 0;
61
59 bus_for_each_dev(&acpi_bus_type, NULL, &arg, typec_port_match);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 * REVISIT: Now each connector can have only a single component master.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
75void typec_unlink_ports(struct typec_port *con)80void 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}
drivers/usb/typec/tcpm/tcpci.c+26−0
@@ -75,9 +75,25 @@ static int tcpci_write16(struct tcpci *tcpci, unsigned int reg, u16 val) · 74 unmodified lines
75static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc)75static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc)
76{76{
77 struct tcpci *tcpci = tcpc_to_tcpci(tcpc);77 struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
78 bool vconn_pres;
79 enum typec_cc_polarity polarity = TYPEC_POLARITY_CC1;
78 unsigned int reg;80 unsigned int reg;
79 int ret;81 int ret;
80 82
83 ret = regmap_read(tcpci->regmap, TCPC_POWER_STATUS, &reg);
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, &reg);
90 if (ret < 0)
91 return ret;
92
93 if (reg & TCPC_TCPC_CTRL_ORIENTATION)
94 polarity = TYPEC_POLARITY_CC2;
95 }
96
81 switch (cc) {97 switch (cc) {
82 case TYPEC_CC_RA:98 case TYPEC_CC_RA:
83 reg = (TCPC_ROLE_CTRL_CC_RA << TCPC_ROLE_CTRL_CC1_SHIFT) |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 break;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 ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg);141 ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg);
116 if (ret < 0)142 if (ret < 0)
117 return ret;143 return ret;
drivers/usb/typec/tcpm/tcpci.h+1−0
@@ -98,6 +98,7 @@ · 97 unmodified lines
98#define TCPC_POWER_STATUS_SOURCING_VBUS BIT(4)98#define TCPC_POWER_STATUS_SOURCING_VBUS BIT(4)
99#define TCPC_POWER_STATUS_VBUS_DET BIT(3)99#define TCPC_POWER_STATUS_VBUS_DET BIT(3)
100#define TCPC_POWER_STATUS_VBUS_PRES BIT(2)100#define TCPC_POWER_STATUS_VBUS_PRES BIT(2)
101#define TCPC_POWER_STATUS_VCONN_PRES BIT(1)
101#define TCPC_POWER_STATUS_SINKING_VBUS BIT(0)102#define TCPC_POWER_STATUS_SINKING_VBUS BIT(0)
102 103
103#define TCPC_FAULT_STATUS 0x1f104#define TCPC_FAULT_STATUS 0x1f
drivers/usb/typec/tcpm/tcpm.c+6−1
@@ -5156,7 +5156,8 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port) · 5155 unmodified lines
5156 case SNK_TRYWAIT_DEBOUNCE:5156 case SNK_TRYWAIT_DEBOUNCE:
5157 break;5157 break;
5158 case SNK_ATTACH_WAIT: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 break;5161 break;
5161 5162
5162 case SNK_NEGOTIATE_CAPABILITIES:5163 case SNK_NEGOTIATE_CAPABILITIES:
@@ -5263,6 +5264,10 @@ static void _tcpm_pd_vbus_vsafe0v(struct tcpm_port *port) · 100 unmodified lines
5263 case PR_SWAP_SNK_SRC_SOURCE_ON:5264 case PR_SWAP_SNK_SRC_SOURCE_ON:
5264 /* Do nothing, vsafe0v is expected during transition */5265 /* Do nothing, vsafe0v is expected during transition */
5265 break;5266 break;
5267 case SNK_ATTACH_WAIT:
5268 case SNK_DEBOUNCED:
5269 /*Do nothing, still waiting for VSAFE5V for connect */
5270 break;
5266 default:5271 default:
5267 if (port->pwr_role == TYPEC_SINK && port->auto_vbus_discharge_enabled)5272 if (port->pwr_role == TYPEC_SINK && port->auto_vbus_discharge_enabled)
5268 tcpm_set_state(port, SNK_UNATTACHED, 0);5273 tcpm_set_state(port, SNK_UNATTACHED, 0);
drivers/usb/typec/ucsi/ucsi_ccg.c+1−1
@@ -325,7 +325,7 @@ static int ucsi_ccg_init(struct ucsi_ccg *uc) · 324 unmodified lines
325 if (status < 0)325 if (status < 0)
326 return status;326 return status;
327 327
328 if (!data)328 if (!(data & DEV_INT))
329 return 0;329 return 0;
330 330
331 status = ccg_write(uc, CCGX_RAB_INTR_REG, &data, sizeof(data));331 status = ccg_write(uc, CCGX_RAB_INTR_REG, &data, sizeof(data));
include/linux/usb/role.h+6−0
@@ -91,6 +91,12 @@ fwnode_usb_role_switch_get(struct fwnode_handle *node) · 90 unmodified lines
91 91
92static inline void usb_role_switch_put(struct usb_role_switch *sw) { }92static inline void usb_role_switch_put(struct usb_role_switch *sw) { }
93 93
94static inline struct usb_role_switch *
95usb_role_switch_find_by_fwnode(const struct fwnode_handle *fwnode)
96{
97 return NULL;
98}
99
94static inline struct usb_role_switch *100static inline struct usb_role_switch *
95usb_role_switch_register(struct device *parent,101usb_role_switch_register(struct device *parent,
96 const struct usb_role_switch_desc *desc)102 const struct usb_role_switch_desc *desc)