From a6a74ce09b4aded73151049bc8083a580fc1cf55 Mon Sep 17 00:00:00 2001 From: Tim Harvey Date: Fri, 19 May 2023 11:58:54 -0700 Subject: [PATCH 1/3] usb: ehci-mx6: remove unnecessary regulator enable from probe Remove the regulator_set_enable() call from device probe which resolves a regulator imbalance. This is unnecessary as regulator_set_enable() will be called when ehci_register calls the init_after_reset hook. Suggested-by: Marek Vasut Signed-off-by: Tim Harvey --- drivers/usb/host/ehci-mx6.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index fae20838c60..a9ed5e7a0d5 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -709,18 +709,6 @@ static int ehci_usb_probe(struct udevice *dev) goto err_regulator; #endif -#if CONFIG_IS_ENABLED(DM_REGULATOR) - if (priv->vbus_supply) { - ret = regulator_set_enable(priv->vbus_supply, - (type == USB_INIT_DEVICE) ? - false : true); - if (ret && ret != -ENOSYS) { - printf("Error enabling VBUS supply (ret=%i)\n", ret); - goto err_clk; - } - } -#endif - if (priv->init_type == USB_INIT_HOST) { setbits_le32(&ehci->usbmode, CM_HOST); writel(mx6_portsc(priv->phy_type), &ehci->portsc); @@ -744,10 +732,6 @@ err_phy: generic_shutdown_phy(&priv->phy); err_regulator: #endif -#if CONFIG_IS_ENABLED(DM_REGULATOR) - if (priv->vbus_supply) - regulator_set_enable(priv->vbus_supply, false); -#endif err_clk: #if CONFIG_IS_ENABLED(CLK) clk_disable(&priv->clk); From 15cba56dc80092c397be8bbe086abb926808857c Mon Sep 17 00:00:00 2001 From: Ravi Gunasekaran Date: Wed, 19 Jul 2023 14:29:08 +0530 Subject: [PATCH 2/3] usb: cdns3: gadget: Configure speed in udc_start When one of the functions does not support super speed, the composite driver forces the gadget to high speed. But the speed is never configured in the cdns3 gadget driver. So configure the speed in cdns3_gadget_udc_start just like in the kernel. Signed-off-by: Ravi Gunasekaran Reviewed-by: Marek Vasut --- drivers/usb/cdns3/gadget.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index fcaeab9cc1d..cae570cf598 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -82,6 +82,9 @@ static int __cdns3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request, gfp_t gfp_flags); +static void cdns3_gadget_udc_set_speed(struct usb_gadget *gadget, + enum usb_device_speed speed); + /** * cdns3_set_register_bit - set bit in given register. * @ptr: address of device controller register to be read and changed @@ -2341,6 +2344,7 @@ static int cdns3_gadget_udc_start(struct usb_gadget *gadget, spin_lock_irqsave(&priv_dev->lock, flags); priv_dev->gadget_driver = driver; + cdns3_gadget_udc_set_speed(gadget, gadget->max_speed); cdns3_gadget_config(priv_dev); spin_unlock_irqrestore(&priv_dev->lock, flags); return 0; From 3aba92c9dd2302a91b56d49791041766dcc7dfeb Mon Sep 17 00:00:00 2001 From: Richard Habeeb Date: Mon, 24 Jul 2023 15:45:25 -0400 Subject: [PATCH 3/3] usb: xhci: Fix double free on failure drivers/core/device.c will call `device_free()` after xhci_register already frees the private device data. This can cause a crash later during the boot process, observed on aarch64 RPi4b as a synchronous exception. All callers of xhci_register use priv_auto, so this won't lead to memory leaks. Signed-off-by: Richard Habeeb Reviewed-by: Bin Meng Reviewed-by: Simon Glass --- drivers/usb/host/xhci.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 9e33c5d8559..5cacf0769ec 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1418,7 +1418,6 @@ int xhci_register(struct udevice *dev, struct xhci_hccr *hccr, return 0; err: - free(ctrl); debug("%s: failed, ret=%d\n", __func__, ret); return ret; }