Pull USB driver fixes from Greg KH: "Here are some small USB driver fixes for reported problems for 6.9-rc7. Included in here are: - usb core fixes for found issues - typec driver fixes for reported problems - usb gadget driver fixes for reported problems - xhci build fixes - dwc3 driver fixes for reported issues All of these have been in linux-next this past week with no reported problems" * tag 'usb-6.9-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: typec: tcpm: Check for port partner validity before consuming it usb: typec: tcpm: enforce ready state when queueing alt mode vdm usb: typec: tcpm: unregister existing source caps before re-registration usb: typec: tcpm: clear pd_event queue in PORT_RESET usb: typec: tcpm: queue correct sop type in tcpm_queue_vdm_unlocked usb: Fix regression caused by invalid ep0 maxpacket in virtual SuperSpeed device usb: ohci: Prevent missed ohci interrupts usb: typec: qcom-pmic: fix pdphy start() error handling usb: typec: qcom-pmic: fix use-after-free on late probe errors usb: gadget: f_fs: Fix a race condition when processing setup packets. USB: core: Fix access violation during port device removal usb: dwc3: core: Prevent phy suspend during init usb: xhci-plat: Don't include xhci.h usb: gadget: uvc: use correct buffer size when parsing configfs lists usb: gadget: composite: fix OS descriptors w_value logic usb: gadget: f_fs: Fix race between aio_cancel() and AIO request complete
Unified · Split
| @@ -5110,9 +5110,10 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, · 5109 unmodified lines | |||
| 5110 | } | 5110 | } |
| 5111 | if (usb_endpoint_maxp(&udev->ep0.desc) == i) { | 5111 | if (usb_endpoint_maxp(&udev->ep0.desc) == i) { |
| 5112 | ; /* Initial ep0 maxpacket guess is right */ | 5112 | ; /* Initial ep0 maxpacket guess is right */ |
| 5113 | } else if ((udev->speed == USB_SPEED_FULL || | 5113 | } else if (((udev->speed == USB_SPEED_FULL || |
| 5114 | udev->speed == USB_SPEED_HIGH) && | 5114 | udev->speed == USB_SPEED_HIGH) && |
| 5115 | (i == 8 || i == 16 || i == 32 || i == 64)) { | 5115 | (i == 8 || i == 16 || i == 32 || i == 64)) || |
| 5116 | (udev->speed >= USB_SPEED_SUPER && i > 0)) { | ||
| 5116 | /* Initial guess is wrong; use the descriptor's value */ | 5117 | /* Initial guess is wrong; use the descriptor's value */ |
| 5117 | if (udev->speed == USB_SPEED_FULL) | 5118 | if (udev->speed == USB_SPEED_FULL) |
| 5118 | dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i); | 5119 | dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i); |
| @@ -51,13 +51,15 @@ static ssize_t disable_show(struct device *dev, · 50 unmodified lines | |||
| 51 | struct usb_port *port_dev = to_usb_port(dev); | 51 | struct usb_port *port_dev = to_usb_port(dev); |
| 52 | struct usb_device *hdev = to_usb_device(dev->parent->parent); | 52 | struct usb_device *hdev = to_usb_device(dev->parent->parent); |
| 53 | struct usb_hub *hub = usb_hub_to_struct_hub(hdev); | 53 | struct usb_hub *hub = usb_hub_to_struct_hub(hdev); |
| 54 | struct usb_interface *intf = to_usb_interface(hub->intfdev); | 54 | struct usb_interface *intf = to_usb_interface(dev->parent); |
| 55 | int port1 = port_dev->portnum; | 55 | int port1 = port_dev->portnum; |
| 56 | u16 portstatus, unused; | 56 | u16 portstatus, unused; |
| 57 | bool disabled; | 57 | bool disabled; |
| 58 | int rc; | 58 | int rc; |
| 59 | struct kernfs_node *kn; | 59 | struct kernfs_node *kn; |
| 60 | 60 | ||
| 61 | if (!hub) | ||
| 62 | return -ENODEV; | ||
| 61 | hub_get(hub); | 63 | hub_get(hub); |
| 62 | rc = usb_autopm_get_interface(intf); | 64 | rc = usb_autopm_get_interface(intf); |
| 63 | if (rc < 0) | 65 | if (rc < 0) |
| @@ -101,12 +103,14 @@ static ssize_t disable_store(struct device *dev, struct device_attribute *attr, · 37 unmodified lines | |||
| 101 | struct usb_port *port_dev = to_usb_port(dev); | 103 | struct usb_port *port_dev = to_usb_port(dev); |
| 102 | struct usb_device *hdev = to_usb_device(dev->parent->parent); | 104 | struct usb_device *hdev = to_usb_device(dev->parent->parent); |
| 103 | struct usb_hub *hub = usb_hub_to_struct_hub(hdev); | 105 | struct usb_hub *hub = usb_hub_to_struct_hub(hdev); |
| 104 | struct usb_interface *intf = to_usb_interface(hub->intfdev); | 106 | struct usb_interface *intf = to_usb_interface(dev->parent); |
| 105 | int port1 = port_dev->portnum; | 107 | int port1 = port_dev->portnum; |
| 106 | bool disabled; | 108 | bool disabled; |
| 107 | int rc; | 109 | int rc; |
| 108 | struct kernfs_node *kn; | 110 | struct kernfs_node *kn; |
| 109 | 111 | ||
| 112 | if (!hub) | ||
| 113 | return -ENODEV; | ||
| 110 | rc = kstrtobool(buf, &disabled); | 114 | rc = kstrtobool(buf, &disabled); |
| 111 | if (rc) | 115 | if (rc) |
| 112 | return rc; | 116 | return rc; |
| @@ -104,6 +104,27 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc) · 103 unmodified lines | |||
| 104 | return 0; | 104 | return 0; |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | void dwc3_enable_susphy(struct dwc3 *dwc, bool enable) | ||
| 108 | { | ||
| 109 | u32 reg; | ||
| 110 | |||
| 111 | reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); | ||
| 112 | if (enable && !dwc->dis_u3_susphy_quirk) | ||
| 113 | reg |= DWC3_GUSB3PIPECTL_SUSPHY; | ||
| 114 | else | ||
| 115 | reg &= ~DWC3_GUSB3PIPECTL_SUSPHY; | ||
| 116 | |||
| 117 | dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); | ||
| 118 | |||
| 119 | reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); | ||
| 120 | if (enable && !dwc->dis_u2_susphy_quirk) | ||
| 121 | reg |= DWC3_GUSB2PHYCFG_SUSPHY; | ||
| 122 | else | ||
| 123 | reg &= ~DWC3_GUSB2PHYCFG_SUSPHY; | ||
| 124 | |||
| 125 | dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); | ||
| 126 | } | ||
| 127 | |||
| 107 | void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode) | 128 | void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode) |
| 108 | { | 129 | { |
| 109 | u32 reg; | 130 | u32 reg; |
| @@ -585,11 +606,8 @@ static int dwc3_core_ulpi_init(struct dwc3 *dwc) · 475 unmodified lines | |||
| 585 | */ | 606 | */ |
| 586 | static int dwc3_phy_setup(struct dwc3 *dwc) | 607 | static int dwc3_phy_setup(struct dwc3 *dwc) |
| 587 | { | 608 | { |
| 588 | unsigned int hw_mode; | ||
| 589 | u32 reg; | 609 | u32 reg; |
| 590 | 610 | ||
| 591 | hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0); | ||
| 592 | |||
| 593 | reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); | 611 | reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); |
| 594 | 612 | ||
| 595 | /* | 613 | /* |
| @@ -599,21 +617,16 @@ static int dwc3_phy_setup(struct dwc3 *dwc) · 3 unmodified lines | |||
| 599 | reg &= ~DWC3_GUSB3PIPECTL_UX_EXIT_PX; | 617 | reg &= ~DWC3_GUSB3PIPECTL_UX_EXIT_PX; |
| 600 | 618 | ||
| 601 | /* | 619 | /* |
| 602 | * Above 1.94a, it is recommended to set DWC3_GUSB3PIPECTL_SUSPHY | 620 | * Above DWC_usb3.0 1.94a, it is recommended to set |
| 603 | * to '0' during coreConsultant configuration. So default value | 621 | * DWC3_GUSB3PIPECTL_SUSPHY to '0' during coreConsultant configuration. |
| 604 | * will be '0' when the core is reset. Application needs to set it | 622 | * So default value will be '0' when the core is reset. Application |
| 605 | * to '1' after the core initialization is completed. | 623 | * needs to set it to '1' after the core initialization is completed. |
| 606 | */ | 624 | * |
| 607 | if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) | 625 | * Similarly for DRD controllers, GUSB3PIPECTL.SUSPENDENABLE must be |
| 608 | reg |= DWC3_GUSB3PIPECTL_SUSPHY; | 626 | * cleared after power-on reset, and it can be set after core |
| 609 | 627 | * initialization. | |
| 610 | /* | ||
| 611 | * For DRD controllers, GUSB3PIPECTL.SUSPENDENABLE must be cleared after | ||
| 612 | * power-on reset, and it can be set after core initialization, which is | ||
| 613 | * after device soft-reset during initialization. | ||
| 614 | */ | 628 | */ |
| 615 | if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD) | 629 | reg &= ~DWC3_GUSB3PIPECTL_SUSPHY; |
| 616 | reg &= ~DWC3_GUSB3PIPECTL_SUSPHY; | ||
| 617 | 630 | ||
| 618 | if (dwc->u2ss_inp3_quirk) | 631 | if (dwc->u2ss_inp3_quirk) |
| 619 | reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK; | 632 | reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK; |
| @@ -639,9 +652,6 @@ static int dwc3_phy_setup(struct dwc3 *dwc) · 19 unmodified lines | |||
| 639 | if (dwc->tx_de_emphasis_quirk) | 652 | if (dwc->tx_de_emphasis_quirk) |
| 640 | reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis); | 653 | reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis); |
| 641 | 654 | ||
| 642 | if (dwc->dis_u3_susphy_quirk) | ||
| 643 | reg &= ~DWC3_GUSB3PIPECTL_SUSPHY; | ||
| 644 | |||
| 645 | if (dwc->dis_del_phy_power_chg_quirk) | 655 | if (dwc->dis_del_phy_power_chg_quirk) |
| 646 | reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE; | 656 | reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE; |
| 647 | 657 | ||
| @@ -689,24 +699,15 @@ static int dwc3_phy_setup(struct dwc3 *dwc) · 41 unmodified lines | |||
| 689 | } | 699 | } |
| 690 | 700 | ||
| 691 | /* | 701 | /* |
| 692 | * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to | 702 | * Above DWC_usb3.0 1.94a, it is recommended to set |
| 693 | * '0' during coreConsultant configuration. So default value will | 703 | * DWC3_GUSB2PHYCFG_SUSPHY to '0' during coreConsultant configuration. |
| 694 | * be '0' when the core is reset. Application needs to set it to | 704 | * So default value will be '0' when the core is reset. Application |
| 695 | * '1' after the core initialization is completed. | 705 | * needs to set it to '1' after the core initialization is completed. |
| 696 | */ | 706 | * |
| 697 | if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) | 707 | * Similarly for DRD controllers, GUSB2PHYCFG.SUSPHY must be cleared |
| 698 | reg |= DWC3_GUSB2PHYCFG_SUSPHY; | 708 | * after power-on reset, and it can be set after core initialization. |
| 699 | |||
| 700 | /* | ||
| 701 | * For DRD controllers, GUSB2PHYCFG.SUSPHY must be cleared after | ||
| 702 | * power-on reset, and it can be set after core initialization, which is | ||
| 703 | * after device soft-reset during initialization. | ||
| 704 | */ | 709 | */ |
| 705 | if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD) | 710 | reg &= ~DWC3_GUSB2PHYCFG_SUSPHY; |
| 706 | reg &= ~DWC3_GUSB2PHYCFG_SUSPHY; | ||
| 707 | |||
| 708 | if (dwc->dis_u2_susphy_quirk) | ||
| 709 | reg &= ~DWC3_GUSB2PHYCFG_SUSPHY; | ||
| 710 | 711 | ||
| 711 | if (dwc->dis_enblslpm_quirk) | 712 | if (dwc->dis_enblslpm_quirk) |
| 712 | reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM; | 713 | reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM; |
| @@ -1227,21 +1228,6 @@ static int dwc3_core_init(struct dwc3 *dwc) · 514 unmodified lines | |||
| 1227 | if (ret) | 1228 | if (ret) |
| 1228 | goto err_exit_phy; | 1229 | goto err_exit_phy; |
| 1229 | 1230 | ||
| 1230 | if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD && | ||
| 1231 | !DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) { | ||
| 1232 | if (!dwc->dis_u3_susphy_quirk) { | ||
| 1233 | reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); | ||
| 1234 | reg |= DWC3_GUSB3PIPECTL_SUSPHY; | ||
| 1235 | dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); | ||
| 1236 | } | ||
| 1237 | |||
| 1238 | if (!dwc->dis_u2_susphy_quirk) { | ||
| 1239 | reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); | ||
| 1240 | reg |= DWC3_GUSB2PHYCFG_SUSPHY; | ||
| 1241 | dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); | ||
| 1242 | } | ||
| 1243 | } | ||
| 1244 | |||
| 1245 | dwc3_core_setup_global_control(dwc); | 1231 | dwc3_core_setup_global_control(dwc); |
| 1246 | dwc3_core_num_eps(dwc); | 1232 | dwc3_core_num_eps(dwc); |
| 1247 | 1233 | ||
| @@ -1580,6 +1580,7 @@ int dwc3_event_buffers_setup(struct dwc3 *dwc); · 1579 unmodified lines | |||
| 1580 | void dwc3_event_buffers_cleanup(struct dwc3 *dwc); | 1580 | void dwc3_event_buffers_cleanup(struct dwc3 *dwc); |
| 1581 | 1581 | ||
| 1582 | int dwc3_core_soft_reset(struct dwc3 *dwc); | 1582 | int dwc3_core_soft_reset(struct dwc3 *dwc); |
| 1583 | void dwc3_enable_susphy(struct dwc3 *dwc, bool enable); | ||
| 1583 | 1584 | ||
| 1584 | #if IS_ENABLED(CONFIG_USB_DWC3_HOST) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE) | 1585 | #if IS_ENABLED(CONFIG_USB_DWC3_HOST) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE) |
| 1585 | int dwc3_host_init(struct dwc3 *dwc); | 1586 | int dwc3_host_init(struct dwc3 *dwc); |
| @@ -2924,6 +2924,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc) · 2923 unmodified lines | |||
| 2924 | dwc3_ep0_out_start(dwc); | 2924 | dwc3_ep0_out_start(dwc); |
| 2925 | 2925 | ||
| 2926 | dwc3_gadget_enable_irq(dwc); | 2926 | dwc3_gadget_enable_irq(dwc); |
| 2927 | dwc3_enable_susphy(dwc, true); | ||
| 2927 | 2928 | ||
| 2928 | return 0; | 2929 | return 0; |
| 2929 | 2930 | ||
| @@ -4690,6 +4691,7 @@ void dwc3_gadget_exit(struct dwc3 *dwc) · 1760 unmodified lines | |||
| 4690 | if (!dwc->gadget) | 4691 | if (!dwc->gadget) |
| 4691 | return; | 4692 | return; |
| 4692 | 4693 | ||
| 4694 | dwc3_enable_susphy(dwc, false); | ||
| 4693 | usb_del_gadget(dwc->gadget); | 4695 | usb_del_gadget(dwc->gadget); |
| 4694 | dwc3_gadget_free_endpoints(dwc); | 4696 | dwc3_gadget_free_endpoints(dwc); |
| 4695 | usb_put_gadget(dwc->gadget); | 4697 | usb_put_gadget(dwc->gadget); |
| @@ -10,10 +10,13 @@ · 9 unmodified lines | |||
| 10 | #include <linux/irq.h> | 10 | #include <linux/irq.h> |
| 11 | #include <linux/of.h> | 11 | #include <linux/of.h> |
| 12 | #include <linux/platform_device.h> | 12 | #include <linux/platform_device.h> |
| 13 | #include <linux/usb.h> | ||
| 14 | #include <linux/usb/hcd.h> | ||
| 13 | 15 | ||
| 14 | #include "../host/xhci-port.h" | 16 | #include "../host/xhci-port.h" |
| 15 | #include "../host/xhci-ext-caps.h" | 17 | #include "../host/xhci-ext-caps.h" |
| 16 | #include "../host/xhci-caps.h" | 18 | #include "../host/xhci-caps.h" |
| 19 | #include "../host/xhci-plat.h" | ||
| 17 | #include "core.h" | 20 | #include "core.h" |
| 18 | 21 | ||
| 19 | #define XHCI_HCSPARAMS1 0x4 | 22 | #define XHCI_HCSPARAMS1 0x4 |
| @@ -57,6 +60,24 @@ static void dwc3_power_off_all_roothub_ports(struct dwc3 *dwc) · 37 unmodified lines | |||
| 57 | } | 60 | } |
| 58 | } | 61 | } |
| 59 | 62 | ||
| 63 | static void dwc3_xhci_plat_start(struct usb_hcd *hcd) | ||
| 64 | { | ||
| 65 | struct platform_device *pdev; | ||
| 66 | struct dwc3 *dwc; | ||
| 67 | |||
| 68 | if (!usb_hcd_is_primary_hcd(hcd)) | ||
| 69 | return; | ||
| 70 | |||
| 71 | pdev = to_platform_device(hcd->self.controller); | ||
| 72 | dwc = dev_get_drvdata(pdev->dev.parent); | ||
| 73 | |||
| 74 | dwc3_enable_susphy(dwc, true); | ||
| 75 | } | ||
| 76 | |||
| 77 | static const struct xhci_plat_priv dwc3_xhci_plat_quirk = { | ||
| 78 | .plat_start = dwc3_xhci_plat_start, | ||
| 79 | }; | ||
| 80 | |||
| 60 | static void dwc3_host_fill_xhci_irq_res(struct dwc3 *dwc, | 81 | static void dwc3_host_fill_xhci_irq_res(struct dwc3 *dwc, |
| 61 | int irq, char *name) | 82 | int irq, char *name) |
| 62 | { | 83 | { |
| @@ -167,6 +188,11 @@ int dwc3_host_init(struct dwc3 *dwc) · 104 unmodified lines | |||
| 167 | } | 188 | } |
| 168 | } | 189 | } |
| 169 | 190 | ||
| 191 | ret = platform_device_add_data(xhci, &dwc3_xhci_plat_quirk, | ||
| 192 | sizeof(struct xhci_plat_priv)); | ||
| 193 | if (ret) | ||
| 194 | goto err; | ||
| 195 | |||
| 170 | ret = platform_device_add(xhci); | 196 | ret = platform_device_add(xhci); |
| 171 | if (ret) { | 197 | if (ret) { |
| 172 | dev_err(dwc->dev, "failed to register xHCI device\n"); | 198 | dev_err(dwc->dev, "failed to register xHCI device\n"); |
| @@ -192,6 +218,7 @@ void dwc3_host_exit(struct dwc3 *dwc) · 19 unmodified lines | |||
| 192 | if (dwc->sys_wakeup) | 218 | if (dwc->sys_wakeup) |
| 193 | device_init_wakeup(&dwc->xhci->dev, false); | 219 | device_init_wakeup(&dwc->xhci->dev, false); |
| 194 | 220 | ||
| 221 | dwc3_enable_susphy(dwc, false); | ||
| 195 | platform_device_unregister(dwc->xhci); | 222 | platform_device_unregister(dwc->xhci); |
| 196 | dwc->xhci = NULL; | 223 | dwc->xhci = NULL; |
| 197 | } | 224 | } |
| @@ -2112,7 +2112,7 @@ unknown: · 2111 unmodified lines | |||
| 2112 | buf[5] = 0x01; | 2112 | buf[5] = 0x01; |
| 2113 | switch (ctrl->bRequestType & USB_RECIP_MASK) { | 2113 | switch (ctrl->bRequestType & USB_RECIP_MASK) { |
| 2114 | case USB_RECIP_DEVICE: | 2114 | case USB_RECIP_DEVICE: |
| 2115 | if (w_index != 0x4 || (w_value >> 8)) | 2115 | if (w_index != 0x4 || (w_value & 0xff)) |
| 2116 | break; | 2116 | break; |
| 2117 | buf[6] = w_index; | 2117 | buf[6] = w_index; |
| 2118 | /* Number of ext compat interfaces */ | 2118 | /* Number of ext compat interfaces */ |
| @@ -2128,9 +2128,9 @@ unknown: · 9 unmodified lines | |||
| 2128 | } | 2128 | } |
| 2129 | break; | 2129 | break; |
| 2130 | case USB_RECIP_INTERFACE: | 2130 | case USB_RECIP_INTERFACE: |
| 2131 | if (w_index != 0x5 || (w_value >> 8)) | 2131 | if (w_index != 0x5 || (w_value & 0xff)) |
| 2132 | break; | 2132 | break; |
| 2133 | interface = w_value & 0xFF; | 2133 | interface = w_value >> 8; |
| 2134 | if (interface >= MAX_CONFIG_INTERFACES || | 2134 | if (interface >= MAX_CONFIG_INTERFACES || |
| 2135 | !os_desc_cfg->interface[interface]) | 2135 | !os_desc_cfg->interface[interface]) |
| 2136 | break; | 2136 | break; |
| @@ -852,6 +852,7 @@ static void ffs_user_copy_worker(struct work_struct *work) · 851 unmodified lines | |||
| 852 | work); | 852 | work); |
| 853 | int ret = io_data->status; | 853 | int ret = io_data->status; |
| 854 | bool kiocb_has_eventfd = io_data->kiocb->ki_flags & IOCB_EVENTFD; | 854 | bool kiocb_has_eventfd = io_data->kiocb->ki_flags & IOCB_EVENTFD; |
| 855 | unsigned long flags; | ||
| 855 | 856 | ||
| 856 | if (io_data->read && ret > 0) { | 857 | if (io_data->read && ret > 0) { |
| 857 | kthread_use_mm(io_data->mm); | 858 | kthread_use_mm(io_data->mm); |
| @@ -864,6 +865,11 @@ static void ffs_user_copy_worker(struct work_struct *work) · 6 unmodified lines | |||
| 864 | if (io_data->ffs->ffs_eventfd && !kiocb_has_eventfd) | 865 | if (io_data->ffs->ffs_eventfd && !kiocb_has_eventfd) |
| 865 | eventfd_signal(io_data->ffs->ffs_eventfd); | 866 | eventfd_signal(io_data->ffs->ffs_eventfd); |
| 866 | 867 | ||
| 868 | spin_lock_irqsave(&io_data->ffs->eps_lock, flags); | ||
| 869 | usb_ep_free_request(io_data->ep, io_data->req); | ||
| 870 | io_data->req = NULL; | ||
| 871 | spin_unlock_irqrestore(&io_data->ffs->eps_lock, flags); | ||
| 872 | |||
| 867 | if (io_data->read) | 873 | if (io_data->read) |
| 868 | kfree(io_data->to_free); | 874 | kfree(io_data->to_free); |
| 869 | ffs_free_buffer(io_data); | 875 | ffs_free_buffer(io_data); |
| @@ -877,7 +883,6 @@ static void ffs_epfile_async_io_complete(struct usb_ep *_ep, · 7 unmodified lines | |||
| 877 | struct ffs_data *ffs = io_data->ffs; | 883 | struct ffs_data *ffs = io_data->ffs; |
| 878 | 884 | ||
| 879 | io_data->status = req->status ? req->status : req->actual; | 885 | io_data->status = req->status ? req->status : req->actual; |
| 880 | usb_ep_free_request(_ep, req); | ||
| 881 | 886 | ||
| 882 | INIT_WORK(&io_data->work, ffs_user_copy_worker); | 887 | INIT_WORK(&io_data->work, ffs_user_copy_worker); |
| 883 | queue_work(ffs->io_completion_wq, &io_data->work); | 888 | queue_work(ffs->io_completion_wq, &io_data->work); |
| @@ -3806,7 +3811,7 @@ static int ffs_func_setup(struct usb_function *f, · 2922 unmodified lines | |||
| 3806 | __ffs_event_add(ffs, FUNCTIONFS_SETUP); | 3811 | __ffs_event_add(ffs, FUNCTIONFS_SETUP); |
| 3807 | spin_unlock_irqrestore(&ffs->ev.waitq.lock, flags); | 3812 | spin_unlock_irqrestore(&ffs->ev.waitq.lock, flags); |
| 3808 | 3813 | ||
| 3809 | return creq->wLength == 0 ? USB_GADGET_DELAYED_STATUS : 0; | 3814 | return ffs->ev.setup.wLength == 0 ? USB_GADGET_DELAYED_STATUS : 0; |
| 3810 | } | 3815 | } |
| 3811 | 3816 | ||
| 3812 | static bool ffs_func_req_match(struct usb_function *f, | 3817 | static bool ffs_func_req_match(struct usb_function *f, |
| @@ -92,10 +92,10 @@ static int __uvcg_iter_item_entries(const char *page, size_t len, · 91 unmodified lines | |||
| 92 | 92 | ||
| 93 | while (pg - page < len) { | 93 | while (pg - page < len) { |
| 94 | i = 0; | 94 | i = 0; |
| 95 | while (i < sizeof(buf) && (pg - page < len) && | 95 | while (i < bufsize && (pg - page < len) && |
| 96 | *pg != '\0' && *pg != '\n') | 96 | *pg != '\0' && *pg != '\n') |
| 97 | buf[i++] = *pg++; | 97 | buf[i++] = *pg++; |
| 98 | if (i == sizeof(buf)) { | 98 | if (i == bufsize) { |
| 99 | ret = -EINVAL; | 99 | ret = -EINVAL; |
| 100 | goto out_free_buf; | 100 | goto out_free_buf; |
| 101 | } | 101 | } |
| @@ -888,6 +888,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) · 887 unmodified lines | |||
| 888 | /* Check for an all 1's result which is a typical consequence | 888 | /* Check for an all 1's result which is a typical consequence |
| 889 | * of dead, unclocked, or unplugged (CardBus...) devices | 889 | * of dead, unclocked, or unplugged (CardBus...) devices |
| 890 | */ | 890 | */ |
| 891 | again: | ||
| 891 | if (ints == ~(u32)0) { | 892 | if (ints == ~(u32)0) { |
| 892 | ohci->rh_state = OHCI_RH_HALTED; | 893 | ohci->rh_state = OHCI_RH_HALTED; |
| 893 | ohci_dbg (ohci, "device removed!\n"); | 894 | ohci_dbg (ohci, "device removed!\n"); |
| @@ -982,6 +983,13 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) · 88 unmodified lines | |||
| 982 | } | 983 | } |
| 983 | spin_unlock(&ohci->lock); | 984 | spin_unlock(&ohci->lock); |
| 984 | 985 | ||
| 986 | /* repeat until all enabled interrupts are handled */ | ||
| 987 | if (ohci->rh_state != OHCI_RH_HALTED) { | ||
| 988 | ints = ohci_readl(ohci, ®s->intrstatus); | ||
| 989 | if (ints && (ints & ohci_readl(ohci, ®s->intrenable))) | ||
| 990 | goto again; | ||
| 991 | } | ||
| 992 | |||
| 985 | return IRQ_HANDLED; | 993 | return IRQ_HANDLED; |
| 986 | } | 994 | } |
| 987 | 995 | ||
| @@ -8,7 +8,9 @@ · 7 unmodified lines | |||
| 8 | #ifndef _XHCI_PLAT_H | 8 | #ifndef _XHCI_PLAT_H |
| 9 | #define _XHCI_PLAT_H | 9 | #define _XHCI_PLAT_H |
| 10 | 10 | ||
| 11 | #include "xhci.h" /* for hcd_to_xhci() */ | 11 | struct device; |
| 12 | struct platform_device; | ||
| 13 | struct usb_hcd; | ||
| 12 | 14 | ||
| 13 | struct xhci_plat_priv { | 15 | struct xhci_plat_priv { |
| 14 | const char *firmware_name; | 16 | const char *firmware_name; |
| @@ -6,6 +6,7 @@ · 5 unmodified lines | |||
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | #include <linux/usb/rzv2m_usb3drd.h> | 8 | #include <linux/usb/rzv2m_usb3drd.h> |
| 9 | #include "xhci.h" | ||
| 9 | #include "xhci-plat.h" | 10 | #include "xhci-plat.h" |
| 10 | #include "xhci-rzv2m.h" | 11 | #include "xhci-rzv2m.h" |
| 11 | 12 | ||
| @@ -104,14 +104,18 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev) · 103 unmodified lines | |||
| 104 | 104 | ||
| 105 | ret = tcpm->port_start(tcpm, tcpm->tcpm_port); | 105 | ret = tcpm->port_start(tcpm, tcpm->tcpm_port); |
| 106 | if (ret) | 106 | if (ret) |
| 107 | goto fwnode_remove; | 107 | goto port_unregister; |
| 108 | 108 | ||
| 109 | ret = tcpm->pdphy_start(tcpm, tcpm->tcpm_port); | 109 | ret = tcpm->pdphy_start(tcpm, tcpm->tcpm_port); |
| 110 | if (ret) | 110 | if (ret) |
| 111 | goto fwnode_remove; | 111 | goto port_stop; |
| 112 | 112 | ||
| 113 | return 0; | 113 | return 0; |
| 114 | 114 | ||
| 115 | port_stop: | ||
| 116 | tcpm->port_stop(tcpm); | ||
| 117 | port_unregister: | ||
| 118 | tcpm_unregister_port(tcpm->tcpm_port); | ||
| 115 | fwnode_remove: | 119 | fwnode_remove: |
| 116 | fwnode_remove_software_node(tcpm->tcpc.fwnode); | 120 | fwnode_remove_software_node(tcpm->tcpc.fwnode); |
| 117 | 121 | ||
| @@ -475,10 +475,8 @@ static int qcom_pmic_typec_pdphy_enable(struct pmic_typec_pdphy *pmic_typec_pdph · 474 unmodified lines | |||
| 475 | 475 | ||
| 476 | qcom_pmic_typec_pdphy_reset_off(pmic_typec_pdphy); | 476 | qcom_pmic_typec_pdphy_reset_off(pmic_typec_pdphy); |
| 477 | done: | 477 | done: |
| 478 | if (ret) { | 478 | if (ret) |
| 479 | regulator_disable(pmic_typec_pdphy->vdd_pdphy); | ||
| 480 | dev_err(dev, "pdphy_enable fail %d\n", ret); | 479 | dev_err(dev, "pdphy_enable fail %d\n", ret); |
| 481 | } | ||
| 482 | 480 | ||
| 483 | return ret; | 481 | return ret; |
| 484 | } | 482 | } |
| @@ -524,12 +522,17 @@ static int qcom_pmic_typec_pdphy_start(struct pmic_typec *tcpm, · 39 unmodified lines | |||
| 524 | 522 | ||
| 525 | ret = pmic_typec_pdphy_reset(pmic_typec_pdphy); | 523 | ret = pmic_typec_pdphy_reset(pmic_typec_pdphy); |
| 526 | if (ret) | 524 | if (ret) |
| 527 | return ret; | 525 | goto err_disable_vdd_pdhy; |
| 528 | 526 | ||
| 529 | for (i = 0; i < pmic_typec_pdphy->nr_irqs; i++) | 527 | for (i = 0; i < pmic_typec_pdphy->nr_irqs; i++) |
| 530 | enable_irq(pmic_typec_pdphy->irq_data[i].irq); | 528 | enable_irq(pmic_typec_pdphy->irq_data[i].irq); |
| 531 | 529 | ||
| 532 | return 0; | 530 | return 0; |
| 531 | |||
| 532 | err_disable_vdd_pdhy: | ||
| 533 | regulator_disable(pmic_typec_pdphy->vdd_pdphy); | ||
| 534 | |||
| 535 | return ret; | ||
| 533 | } | 536 | } |
| 534 | 537 | ||
| 535 | static void qcom_pmic_typec_pdphy_stop(struct pmic_typec *tcpm) | 538 | static void qcom_pmic_typec_pdphy_stop(struct pmic_typec *tcpm) |
| @@ -1564,8 +1564,12 @@ static void tcpm_queue_vdm(struct tcpm_port *port, const u32 header, · 1563 unmodified lines | |||
| 1564 | static void tcpm_queue_vdm_unlocked(struct tcpm_port *port, const u32 header, | 1564 | static void tcpm_queue_vdm_unlocked(struct tcpm_port *port, const u32 header, |
| 1565 | const u32 *data, int cnt, enum tcpm_transmit_type tx_sop_type) | 1565 | const u32 *data, int cnt, enum tcpm_transmit_type tx_sop_type) |
| 1566 | { | 1566 | { |
| 1567 | if (port->state != SRC_READY && port->state != SNK_READY && | ||
| 1568 | port->state != SRC_VDM_IDENTITY_REQUEST) | ||
| 1569 | return; | ||
| 1570 | |||
| 1567 | mutex_lock(&port->lock); | 1571 | mutex_lock(&port->lock); |
| 1568 | tcpm_queue_vdm(port, header, data, cnt, TCPC_TX_SOP); | 1572 | tcpm_queue_vdm(port, header, data, cnt, tx_sop_type); |
| 1569 | mutex_unlock(&port->lock); | 1573 | mutex_unlock(&port->lock); |
| 1570 | } | 1574 | } |
| 1571 | 1575 | ||
| @@ -1580,7 +1584,8 @@ static void svdm_consume_identity(struct tcpm_port *port, const u32 *p, int cnt) · 8 unmodified lines | |||
| 1580 | port->partner_ident.cert_stat = p[VDO_INDEX_CSTAT]; | 1584 | port->partner_ident.cert_stat = p[VDO_INDEX_CSTAT]; |
| 1581 | port->partner_ident.product = product; | 1585 | port->partner_ident.product = product; |
| 1582 | 1586 | ||
| 1583 | typec_partner_set_identity(port->partner); | 1587 | if (port->partner) |
| 1588 | typec_partner_set_identity(port->partner); | ||
| 1584 | 1589 | ||
| 1585 | tcpm_log(port, "Identity: %04x:%04x.%04x", | 1590 | tcpm_log(port, "Identity: %04x:%04x.%04x", |
| 1586 | PD_IDH_VID(vdo), | 1591 | PD_IDH_VID(vdo), |
| @@ -1742,6 +1747,9 @@ static void tcpm_register_partner_altmodes(struct tcpm_port *port) · 155 unmodified lines | |||
| 1742 | struct typec_altmode *altmode; | 1747 | struct typec_altmode *altmode; |
| 1743 | int i; | 1748 | int i; |
| 1744 | 1749 | ||
| 1750 | if (!port->partner) | ||
| 1751 | return; | ||
| 1752 | |||
| 1745 | for (i = 0; i < modep->altmodes; i++) { | 1753 | for (i = 0; i < modep->altmodes; i++) { |
| 1746 | altmode = typec_partner_register_altmode(port->partner, | 1754 | altmode = typec_partner_register_altmode(port->partner, |
| 1747 | &modep->altmode_desc[i]); | 1755 | &modep->altmode_desc[i]); |
| @@ -2996,7 +3004,7 @@ static int tcpm_register_source_caps(struct tcpm_port *port) · 1248 unmodified lines | |||
| 2996 | { | 3004 | { |
| 2997 | struct usb_power_delivery_desc desc = { port->negotiated_rev }; | 3005 | struct usb_power_delivery_desc desc = { port->negotiated_rev }; |
| 2998 | struct usb_power_delivery_capabilities_desc caps = { }; | 3006 | struct usb_power_delivery_capabilities_desc caps = { }; |
| 2999 | struct usb_power_delivery_capabilities *cap; | 3007 | struct usb_power_delivery_capabilities *cap = port->partner_source_caps; |
| 3000 | 3008 | ||
| 3001 | if (!port->partner_pd) | 3009 | if (!port->partner_pd) |
| 3002 | port->partner_pd = usb_power_delivery_register(NULL, &desc); | 3010 | port->partner_pd = usb_power_delivery_register(NULL, &desc); |
| @@ -3006,6 +3014,9 @@ static int tcpm_register_source_caps(struct tcpm_port *port) · 3 unmodified lines | |||
| 3006 | memcpy(caps.pdo, port->source_caps, sizeof(u32) * port->nr_source_caps); | 3014 | memcpy(caps.pdo, port->source_caps, sizeof(u32) * port->nr_source_caps); |
| 3007 | caps.role = TYPEC_SOURCE; | 3015 | caps.role = TYPEC_SOURCE; |
| 3008 | 3016 | ||
| 3017 | if (cap) | ||
| 3018 | usb_power_delivery_unregister_capabilities(cap); | ||
| 3019 | |||
| 3009 | cap = usb_power_delivery_register_capabilities(port->partner_pd, &caps); | 3020 | cap = usb_power_delivery_register_capabilities(port->partner_pd, &caps); |
| 3010 | if (IS_ERR(cap)) | 3021 | if (IS_ERR(cap)) |
| 3011 | return PTR_ERR(cap); | 3022 | return PTR_ERR(cap); |
| @@ -4231,7 +4242,10 @@ static int tcpm_init_vconn(struct tcpm_port *port) · 1219 unmodified lines | |||
| 4231 | 4242 | ||
| 4232 | static void tcpm_typec_connect(struct tcpm_port *port) | 4243 | static void tcpm_typec_connect(struct tcpm_port *port) |
| 4233 | { | 4244 | { |
| 4245 | struct typec_partner *partner; | ||
| 4246 | |||
| 4234 | if (!port->connected) { | 4247 | if (!port->connected) { |
| 4248 | port->connected = true; | ||
| 4235 | /* Make sure we don't report stale identity information */ | 4249 | /* Make sure we don't report stale identity information */ |
| 4236 | memset(&port->partner_ident, 0, sizeof(port->partner_ident)); | 4250 | memset(&port->partner_ident, 0, sizeof(port->partner_ident)); |
| 4237 | port->partner_desc.usb_pd = port->pd_capable; | 4251 | port->partner_desc.usb_pd = port->pd_capable; |
| @@ -4241,9 +4255,13 @@ static void tcpm_typec_connect(struct tcpm_port *port) · 3 unmodified lines | |||
| 4241 | port->partner_desc.accessory = TYPEC_ACCESSORY_AUDIO; | 4255 | port->partner_desc.accessory = TYPEC_ACCESSORY_AUDIO; |
| 4242 | else | 4256 | else |
| 4243 | port->partner_desc.accessory = TYPEC_ACCESSORY_NONE; | 4257 | port->partner_desc.accessory = TYPEC_ACCESSORY_NONE; |
| 4244 | port->partner = typec_register_partner(port->typec_port, | 4258 | partner = typec_register_partner(port->typec_port, &port->partner_desc); |
| 4245 | &port->partner_desc); | 4259 | if (IS_ERR(partner)) { |
| 4246 | port->connected = true; | 4260 | dev_err(port->dev, "Failed to register partner (%ld)\n", PTR_ERR(partner)); |
| 4261 | return; | ||
| 4262 | } | ||
| 4263 | |||
| 4264 | port->partner = partner; | ||
| 4247 | typec_partner_set_usb_power_delivery(port->partner, port->partner_pd); | 4265 | typec_partner_set_usb_power_delivery(port->partner, port->partner_pd); |
| 4248 | } | 4266 | } |
| 4249 | } | 4267 | } |
| @@ -4323,9 +4341,11 @@ static void tcpm_typec_disconnect(struct tcpm_port *port) · 73 unmodified lines | |||
| 4323 | port->plug_prime = NULL; | 4341 | port->plug_prime = NULL; |
| 4324 | port->cable = NULL; | 4342 | port->cable = NULL; |
| 4325 | if (port->connected) { | 4343 | if (port->connected) { |
| 4326 | typec_partner_set_usb_power_delivery(port->partner, NULL); | 4344 | if (port->partner) { |
| 4327 | typec_unregister_partner(port->partner); | 4345 | typec_partner_set_usb_power_delivery(port->partner, NULL); |
| 4328 | port->partner = NULL; | 4346 | typec_unregister_partner(port->partner); |
| 4347 | port->partner = NULL; | ||
| 4348 | } | ||
| 4329 | port->connected = false; | 4349 | port->connected = false; |
| 4330 | } | 4350 | } |
| 4331 | } | 4351 | } |
| @@ -4549,6 +4569,9 @@ static enum typec_cc_status tcpm_pwr_opmode_to_rp(enum typec_pwr_opmode opmode) · 217 unmodified lines | |||
| 4549 | 4569 | ||
| 4550 | static void tcpm_set_initial_svdm_version(struct tcpm_port *port) | 4570 | static void tcpm_set_initial_svdm_version(struct tcpm_port *port) |
| 4551 | { | 4571 | { |
| 4572 | if (!port->partner) | ||
| 4573 | return; | ||
| 4574 | |||
| 4552 | switch (port->negotiated_rev) { | 4575 | switch (port->negotiated_rev) { |
| 4553 | case PD_REV30: | 4576 | case PD_REV30: |
| 4554 | break; | 4577 | break; |
| @@ -5605,6 +5628,7 @@ static void run_state_machine(struct tcpm_port *port) · 1050 unmodified lines | |||
| 5605 | break; | 5628 | break; |
| 5606 | case PORT_RESET: | 5629 | case PORT_RESET: |
| 5607 | tcpm_reset_port(port); | 5630 | tcpm_reset_port(port); |
| 5631 | port->pd_events = 0; | ||
| 5608 | if (port->self_powered) | 5632 | if (port->self_powered) |
| 5609 | tcpm_set_cc(port, TYPEC_CC_OPEN); | 5633 | tcpm_set_cc(port, TYPEC_CC_OPEN); |
| 5610 | else | 5634 | else |