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
483483 /* Indicate the cdns3 core was power lost before */
484484 bool cdns_power_is_lost(struct cdns *cdns)
485485 {
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)))
488488 return true;
489489 } else {
490− if (!(readl(&cdns->otg_v0_regs->simulate) & BIT(0)))
490+ if (!(readl(&cdns->otg_v1_regs->simulate) & BIT(0)))
491491 return true;
492492 }
493493 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
3939 struct ulpi *ulpi = to_ulpi_dev(dev);
4040 const struct ulpi_device_id *id;
4141
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)
4447 return of_driver_match_device(dev, driver);
4548
4649 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
15631563 urb->hcpriv = NULL;
15641564 INIT_LIST_HEAD(&urb->urb_list);
15651565 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+
15661573 atomic_dec(&urb->dev->urbnum);
15671574 if (atomic_read(&urb->reject))
15681575 wake_up(&usb_kill_urb_queue);
@@ -1665,6 +1672,13 @@ static void __usb_hcd_giveback_urb(struct urb *urb) · 96 unmodified lines
16651672
16661673 usb_anchor_resume_wakeups(anchor);
16671674 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+
16681682 if (unlikely(atomic_read(&urb->reject)))
16691683 wake_up(&usb_kill_urb_queue);
16701684 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
715715 if (!(urb && urb->dev && urb->ep))
716716 return;
717717 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();
718724
719725 usb_hcd_unlink_urb(urb, -ENOENT);
720726 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
756762 if (!urb)
757763 return;
758764 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();
759771
760772 if (!urb->dev || !urb->ep)
761773 return;
drivers/usb/dwc2/gadget.c+1−1
@@ -5097,7 +5097,7 @@ int dwc2_hsotg_suspend(struct dwc2_hsotg *hsotg) · 5096 unmodified lines
50975097 hsotg->gadget.speed = USB_SPEED_UNKNOWN;
50985098 spin_unlock_irqrestore(&hsotg->lock, flags);
50995099
5100− for (ep = 0; ep < hsotg->num_of_eps; ep++) {
5100+ for (ep = 1; ep < hsotg->num_of_eps; ep++) {
51015101 if (hsotg->eps_in[ep])
51025102 dwc2_hsotg_ep_disable_lock(&hsotg->eps_in[ep]->ep);
51035103 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
102102 int ret;
103103 u32 reg;
104104
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");
108110 goto err;
109− } else if (IS_ERR(usb3_phy)) {
110− usb3_phy = NULL;
111111 }
112112
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+
113125 crst = devm_reset_control_get_exclusive(dev, "usb_crst");
114126 if (IS_ERR(crst)) {
115127 ret = PTR_ERR(crst);
@@ -188,6 +200,7 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data) · 72 unmodified lines
188200 goto err;
189201 }
190202
203+skip_usb3_phy:
191204 /*
192205 * This routes the USB DMA traffic to go through FPD path instead
193206 * 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
584584
585585 if (is_iso) {
586586 switch (speed) {
587+ case USB_SPEED_SUPER_PLUS:
587588 case USB_SPEED_SUPER:
588589 size = ss->isoc_maxpacket *
589590 (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
18951895 at91_vbus_irq, 0, driver_name, udc);
18961896 if (retval) {
18971897 DBG("request vbus irq %d failed\n",
1898− udc->board.vbus_pin);
1898+ desc_to_gpio(udc->board.vbus_pin));
18991899 goto err_unprepare_iclk;
19001900 }
19011901 }
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
437437 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
438438 int ret;
439439
440+ if (pm_runtime_suspended(dev))
441+ pm_runtime_resume(dev);
442+
440443 ret = xhci_priv_suspend_quirk(hcd);
441444 if (ret)
442445 return ret;
drivers/usb/storage/unusual_devs.h+10−0
@@ -2301,6 +2301,16 @@ UNUSUAL_DEV( 0x2027, 0xa001, 0x0000, 0x9999, · 2300 unmodified lines
23012301 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
23022302 US_FL_SCM_MULT_TARG ),
23032303
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+
23042314 UNUSUAL_DEV( 0x2116, 0x0320, 0x0001, 0x0001,
23052315 "ST",
23062316 "2A",
drivers/usb/typec/port-mapper.c+7−1
@@ -56,7 +56,12 @@ int typec_link_ports(struct typec_port *con) · 55 unmodified lines
5656 {
5757 struct each_port_arg arg = { .port = con, .match = NULL };
5858
59+ if (!has_acpi_companion(&con->dev))
60+ return 0;
61+
5962 bus_for_each_dev(&acpi_bus_type, NULL, &arg, typec_port_match);
63+ if (!arg.match)
64+ return 0;
6065
6166 /*
6267 * 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
7479
7580 void typec_unlink_ports(struct typec_port *con)
7681 {
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);
7884 }
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
7575 static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc)
7676 {
7777 struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
78+ bool vconn_pres;
79+ enum typec_cc_polarity polarity = TYPEC_POLARITY_CC1;
7880 unsigned int reg;
7981 int ret;
8082
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+
8197 switch (cc) {
8298 case TYPEC_CC_RA:
8399 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
112128 break;
113129 }
114130
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+
115141 ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg);
116142 if (ret < 0)
117143 return ret;
drivers/usb/typec/tcpm/tcpci.h+1−0
@@ -98,6 +98,7 @@ · 97 unmodified lines
9898 #define TCPC_POWER_STATUS_SOURCING_VBUS BIT(4)
9999 #define TCPC_POWER_STATUS_VBUS_DET BIT(3)
100100 #define TCPC_POWER_STATUS_VBUS_PRES BIT(2)
101+#define TCPC_POWER_STATUS_VCONN_PRES BIT(1)
101102 #define TCPC_POWER_STATUS_SINKING_VBUS BIT(0)
102103
103104 #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
51565156 case SNK_TRYWAIT_DEBOUNCE:
51575157 break;
51585158 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 */
51605161 break;
51615162
51625163 case SNK_NEGOTIATE_CAPABILITIES:
@@ -5263,6 +5264,10 @@ static void _tcpm_pd_vbus_vsafe0v(struct tcpm_port *port) · 100 unmodified lines
52635264 case PR_SWAP_SNK_SRC_SOURCE_ON:
52645265 /* Do nothing, vsafe0v is expected during transition */
52655266 break;
5267+ case SNK_ATTACH_WAIT:
5268+ case SNK_DEBOUNCED:
5269+ /*Do nothing, still waiting for VSAFE5V for connect */
5270+ break;
52665271 default:
52675272 if (port->pwr_role == TYPEC_SINK && port->auto_vbus_discharge_enabled)
52685273 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
325325 if (status < 0)
326326 return status;
327327
328− if (!data)
328+ if (!(data & DEV_INT))
329329 return 0;
330330
331331 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
9191
9292 static inline void usb_role_switch_put(struct usb_role_switch *sw) { }
9393
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+
94100 static inline struct usb_role_switch *
95101 usb_role_switch_register(struct device *parent,
96102 const struct usb_role_switch_desc *desc)