Skip to content

Commit

Permalink
usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot
Browse files Browse the repository at this point in the history
The dwc3 could not release resources when the module is built-in
because this module does not have shutdown method. This causes the USB
3.0 hub is not able to detect after warm boot.

Change-Id: Idedc4d651a6b2256284a2944e389f952612ee3df
Signed-off-by: Brian Kim <[email protected]>
  • Loading branch information
bkrepo committed Mar 28, 2017
1 parent 4e555dd commit 480176d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
44 changes: 44 additions & 0 deletions drivers/usb/dwc3/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,49 @@ static int dwc3_probe(struct platform_device *pdev)
return ret;
}

static void dwc3_shutdown(struct platform_device *pdev)
{
struct dwc3 *dwc = platform_get_drvdata(pdev);

usb_phy_set_suspend(dwc->usb2_phy, 1);
usb_phy_set_suspend(dwc->usb3_phy, 1);

if (dwc->dr_mode != USB_DR_MODE_OTG)
pm_runtime_put(&pdev->dev);
pm_runtime_disable(&pdev->dev);

dwc3_debugfs_exit(dwc);

switch (dwc->dr_mode) {
case USB_DR_MODE_PERIPHERAL:
dwc3_gadget_exit(dwc);
break;
case USB_DR_MODE_HOST:
dwc3_host_exit(dwc);
break;
case USB_DR_MODE_OTG:
dwc3_otg_stop(dwc);
dwc3_host_exit(dwc);
dwc3_gadget_exit(dwc);
dwc3_otg_exit(dwc);
break;
default:
/* do nothing */
break;
}

dwc3_event_buffers_cleanup(dwc);
dwc3_free_event_buffers(dwc);

usb_phy_set_suspend(dwc->usb2_phy, 1);
usb_phy_set_suspend(dwc->usb3_phy, 1);

dwc3_core_exit(dwc);

pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
}

static int dwc3_remove(struct platform_device *pdev)
{
struct dwc3 *dwc = platform_get_drvdata(pdev);
Expand Down Expand Up @@ -811,6 +854,7 @@ MODULE_DEVICE_TABLE(of, of_dwc3_match);
static struct platform_driver dwc3_driver = {
.probe = dwc3_probe,
.remove = dwc3_remove,
.shutdown = dwc3_shutdown,
.driver = {
.name = "dwc3",
.of_match_table = of_match_ptr(of_dwc3_match),
Expand Down
5 changes: 5 additions & 0 deletions drivers/usb/host/xhci-plat.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/phy/phy.h>

#include "xhci.h"

Expand Down Expand Up @@ -188,9 +189,13 @@ static int xhci_plat_remove(struct platform_device *dev)
struct usb_hcd *hcd = platform_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);

phy_power_off(xhci->shared_hcd->phy);
phy_exit(xhci->shared_hcd->phy);
usb_remove_hcd(xhci->shared_hcd);
usb_put_hcd(xhci->shared_hcd);

phy_power_off(hcd->phy);
phy_exit(hcd->phy);
usb_remove_hcd(hcd);
iounmap(hcd->regs);
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
Expand Down

0 comments on commit 480176d

Please sign in to comment.