Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750877AbdGLEAO (ORCPT ); Wed, 12 Jul 2017 00:00:14 -0400 Received: from tk.zumbi.com.ar ([106.185.28.14]:45402 "EHLO tk.zumbi.com.ar" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750703AbdGLEAL (ORCPT ); Wed, 12 Jul 2017 00:00:11 -0400 X-Greylist: delayed 429 seconds by postgrey-1.27 at vger.kernel.org; Wed, 12 Jul 2017 00:00:10 EDT From: gustavo panizzo To: balbi@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, gustavo panizzo , Brian Kim Subject: [PATCH] usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot Date: Wed, 12 Jul 2017 11:52:38 +0800 Message-Id: <20170712035238.27554-1-gfa@zumbi.com.ar> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2068 Lines: 68 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. Original patch by Brian Kim, updated and submitted upstream by gustavo panizzo. Also see https://bugs.debian.org/843448 Signed-off-by: Brian Kim Signed-off-by: gustavo panizzo --- drivers/usb/dwc3/core.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 326b302fc440..f92dfe213d89 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1259,6 +1259,38 @@ 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); + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + pm_runtime_get_sync(&pdev->dev); + /* + * restore res->start back to its original value so that, in case the + * probe is deferred, we don't end up getting error in request the + * memory region the next time probe is called. + */ + res->start -= DWC3_GLOBALS_REGS_START; + + dwc3_debugfs_exit(dwc); + dwc3_core_exit_mode(dwc); + 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); + + phy_power_off(dwc->usb2_generic_phy); + phy_power_off(dwc->usb3_generic_phy); + + dwc3_core_exit(dwc); + dwc3_ulpi_exit(dwc); + + pm_runtime_put_sync(&pdev->dev); + pm_runtime_allow(&pdev->dev); + pm_runtime_disable(&pdev->dev); +} + static int dwc3_remove(struct platform_device *pdev) { struct dwc3 *dwc = platform_get_drvdata(pdev); @@ -1488,6 +1520,7 @@ MODULE_DEVICE_TABLE(acpi, dwc3_acpi_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), -- 2.11.0