Re: [PATCH] usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot
Hi, gustavo panizzowrites: >>>gustavo panizzo writes: >>>--- >>>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(>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); > > >What about dwc3_event_buffers_cleanup? should I remove it from >dwc3_shutdown()? >It is already in dwc3_core_exit() I think so. We should avoid duplicate code. >>>+ 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); >> >> >>We've done these in dwc3_core_exit(). >>> >>>This is the patch after testing on a Odroid XU4, on top of linux-next >>>964bcc1b4f57028d56dace7d9bc5924f2eb43f36 which translates to >>>4.13.0-rc1-next-20170717+ >>>I tested this patch for a week without problems with heavy USB and NIC >>>usage. >>>Please consider merging it Author: Brian Kim Date: Wed Jul 12 11:26:55 2017 +0800 usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot 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 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 326b302fc440..09de37d47ee7 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1259,6 +1259,32 @@ 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(>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); + + dwc3_core_exit(dwc); + dwc3_ulpi_exit(dwc); + + pm_runtime_put_sync(>dev); + pm_runtime_allow(>dev); + pm_runtime_disable(>dev); +} + static int dwc3_remove(struct platform_device *pdev) { struct dwc3 *dwc = platform_get_drvdata(pdev); @@ -1488,6 +1514,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), Patch applies cleanly on top of c6be5a0e3cebc145127d46a58350e05d2bcf6323 from linux-next Can you _please_ merge it? >>> >>>why are you upset? You didn't do the changes I requested until now. It's >> >>I'm not
Re: [PATCH] usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot
Hello On Fri, Sep 15, 2017 at 09:01:13AM +, gustavo panizzo wrote: Hello On Thu, Sep 07, 2017 at 01:51:31PM +0300, Felipe Balbi wrote: Hi, gustavo panizzowrites: --- 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(>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); What about dwc3_event_buffers_cleanup? should I remove it from dwc3_shutdown()? It is already in dwc3_core_exit() I think so. We should avoid duplicate code. + 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); We've done these in dwc3_core_exit(). This is the patch after testing on a Odroid XU4, on top of linux-next 964bcc1b4f57028d56dace7d9bc5924f2eb43f36 which translates to 4.13.0-rc1-next-20170717+ I tested this patch for a week without problems with heavy USB and NIC usage. Please consider merging it Author: Brian Kim Date: Wed Jul 12 11:26:55 2017 +0800 usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot 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 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 326b302fc440..09de37d47ee7 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1259,6 +1259,32 @@ 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(>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); + + dwc3_core_exit(dwc); + dwc3_ulpi_exit(dwc); + + pm_runtime_put_sync(>dev); + pm_runtime_allow(>dev); + pm_runtime_disable(>dev); +} + static int dwc3_remove(struct platform_device *pdev) { struct dwc3 *dwc = platform_get_drvdata(pdev); @@ -1488,6 +1514,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), Patch applies cleanly on top of c6be5a0e3cebc145127d46a58350e05d2bcf6323 from linux-next Can you _please_ merge it? why are you upset? You didn't do the changes I requested until now. It's I'm not upset too late for v4.14 merge window and you didn't even send this as a proper patch. I also have no evidence that you've been testing mainline kernel, the commits you pointed me to are against a v4.9 vendor kernel. the commit i sent was tested, and is still running, on top linux-next 964bcc1b4f57028d56dace7d9bc5924f2eb43f36, which gives an uname -r 4.13.0-rc1-next-20170717+ Test this against a vanilla tree (v4.13 was tagged days ago) and give me logs showing the problem without your commit. the patch does not work on top of 4.13.0 :( could you draft a patch i can test? thanks dmesg on top of 4.13.0 [0.00] Booting Linux on physical CPU 0x100 [0.00] random: get_random_bytes called from start_kernel+0x44/0x460 with crng_init=0 [0.00] Linux
Re: [PATCH] usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot
Hello On Thu, Sep 07, 2017 at 01:51:31PM +0300, Felipe Balbi wrote: Hi, gustavo panizzowrites: --- 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(>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); What about dwc3_event_buffers_cleanup? should I remove it from dwc3_shutdown()? It is already in dwc3_core_exit() I think so. We should avoid duplicate code. + 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); We've done these in dwc3_core_exit(). This is the patch after testing on a Odroid XU4, on top of linux-next 964bcc1b4f57028d56dace7d9bc5924f2eb43f36 which translates to 4.13.0-rc1-next-20170717+ I tested this patch for a week without problems with heavy USB and NIC usage. Please consider merging it Author: Brian Kim Date: Wed Jul 12 11:26:55 2017 +0800 usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot 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 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 326b302fc440..09de37d47ee7 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1259,6 +1259,32 @@ 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(>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); + + dwc3_core_exit(dwc); + dwc3_ulpi_exit(dwc); + + pm_runtime_put_sync(>dev); + pm_runtime_allow(>dev); + pm_runtime_disable(>dev); +} + static int dwc3_remove(struct platform_device *pdev) { struct dwc3 *dwc = platform_get_drvdata(pdev); @@ -1488,6 +1514,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), Patch applies cleanly on top of c6be5a0e3cebc145127d46a58350e05d2bcf6323 from linux-next Can you _please_ merge it? why are you upset? You didn't do the changes I requested until now. It's I'm not upset too late for v4.14 merge window and you didn't even send this as a proper patch. I also have no evidence that you've been testing mainline kernel, the commits you pointed me to are against a v4.9 vendor kernel. the commit i sent was tested, and is still running, on top linux-next 964bcc1b4f57028d56dace7d9bc5924f2eb43f36, which gives an uname -r 4.13.0-rc1-next-20170717+ Test this against a vanilla tree (v4.13 was tagged days ago) and give me logs showing the problem without your commit. dmesg on top of 4.13.0 [0.00] Booting Linux on physical CPU 0x100 [0.00] random: get_random_bytes called from start_kernel+0x44/0x460 with crng_init=0 [0.00] Linux version 4.13.0 (root@odroid) (gcc version 6.3.0 20170516 (Debian 6.3.0-18)) #4 SMP Thu Sep 14 21:26:18 UTC 2017 [0.00] CPU: ARMv7 Processor
Re: [PATCH] usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot
Hi, gustavo panizzowrites: --- 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(>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); >> >> >>What about dwc3_event_buffers_cleanup? should I remove it from >>dwc3_shutdown()? >>It is already in dwc3_core_exit() > >I think so. We should avoid duplicate code. > + 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); >>> >>> >>>We've done these in dwc3_core_exit(). This is the patch after testing on a Odroid XU4, on top of linux-next 964bcc1b4f57028d56dace7d9bc5924f2eb43f36 which translates to 4.13.0-rc1-next-20170717+ I tested this patch for a week without problems with heavy USB and NIC usage. Please consider merging it > > Author: Brian Kim > Date: Wed Jul 12 11:26:55 2017 +0800 > >usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot >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 > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index 326b302fc440..09de37d47ee7 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -1259,6 +1259,32 @@ 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(>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); > + > + dwc3_core_exit(dwc); > + dwc3_ulpi_exit(dwc); > + > + pm_runtime_put_sync(>dev); > + pm_runtime_allow(>dev); > + pm_runtime_disable(>dev); > +} > + > static int dwc3_remove(struct platform_device *pdev) > { > struct dwc3 *dwc = platform_get_drvdata(pdev); > @@ -1488,6 +1514,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), > > Patch applies cleanly on top of c6be5a0e3cebc145127d46a58350e05d2bcf6323 from > linux-next > Can you _please_ merge it? why are you upset? You didn't do the changes I requested until now. It's too late for v4.14 merge window and you didn't even send this as a proper patch. I also have no evidence that you've been testing mainline kernel, the commits you pointed me to are against a v4.9 vendor kernel. Test this against a vanilla tree (v4.13 was tagged days ago) and give me logs showing the problem without your commit. Also, the commit you pointed me to couldn't be the
Re: [PATCH] usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot
Hello On Sun, Jul 30, 2017 at 07:53:03AM +0800, gustavo panizzo wrote: Hi On Mon, Jul 24, 2017 at 12:53:27PM +0300, Felipe Balbi wrote: Hi, gustavo panizzowrites: On Wed, Jul 12, 2017 at 02:08:04PM +0800, Baolin Wang wrote: Hi, On 12 July 2017 at 11:52, gustavo panizzo wrote: 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(>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); What about dwc3_event_buffers_cleanup? should I remove it from dwc3_shutdown()? It is already in dwc3_core_exit() I think so. We should avoid duplicate code. + 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); We've done these in dwc3_core_exit(). This is the patch after testing on a Odroid XU4, on top of linux-next 964bcc1b4f57028d56dace7d9bc5924f2eb43f36 which translates to 4.13.0-rc1-next-20170717+ I tested this patch for a week without problems with heavy USB and NIC usage. Please consider merging it Author: Brian Kim Date: Wed Jul 12 11:26:55 2017 +0800 usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot 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 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 326b302fc440..09de37d47ee7 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1259,6 +1259,32 @@ 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(>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); + + dwc3_core_exit(dwc); + dwc3_ulpi_exit(dwc); + + pm_runtime_put_sync(>dev); + pm_runtime_allow(>dev); + pm_runtime_disable(>dev); +} + static int dwc3_remove(struct platform_device *pdev) { struct dwc3 *dwc = platform_get_drvdata(pdev); @@ -1488,6 +1514,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), Patch applies cleanly on top of c6be5a0e3cebc145127d46a58350e05d2bcf6323 from linux-next Can you _please_ merge it? Author: gustavo panizzo Date: Wed Jul 12 11:26:55 2017 +0800 usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot 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
Re: [PATCH] usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot
Hi On Mon, Jul 24, 2017 at 12:53:27PM +0300, Felipe Balbi wrote: Hi, gustavo panizzowrites: On Wed, Jul 12, 2017 at 02:08:04PM +0800, Baolin Wang wrote: Hi, On 12 July 2017 at 11:52, gustavo panizzo wrote: 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(>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); What about dwc3_event_buffers_cleanup? should I remove it from dwc3_shutdown()? It is already in dwc3_core_exit() I think so. We should avoid duplicate code. + 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); We've done these in dwc3_core_exit(). This is the patch after testing on a Odroid XU4, on top of linux-next 964bcc1b4f57028d56dace7d9bc5924f2eb43f36 which translates to 4.13.0-rc1-next-20170717+ I tested this patch for a week without problems with heavy USB and NIC usage. Please consider merging it Author: gustavo panizzo Date: Wed Jul 12 11:26:55 2017 +0800 usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot 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. if the original patch is from Brian, then 'Author' should be Brian. Please fix it. sure, i just didn't want to attribute something he didn't write I also don't get why all of a sudden we need to implement ->shutdown(). Why is it that we never needed it before and we need it now? Commit c499ff71ff2a281366c6ec7a904c547d806cbcd1 broke USB3 for the Odroid XU4, this 2 patches fix the USB3 https://github.com/hardkernel/linux/commit/74b9605e5587b30912d6b6093e9d7fb06d043c33 https://github.com/hardkernel/linux/commit/2166ffd004e04a61887eb2a39f8639dc12140c58 Hardkernel didn't upstreamed them, after investigation in Debian #843448 the 2 patches were identified. The first patch is being upstreamed by Jochen Sprickerhof http://marc.info/?l=linux-usb=149945465112440=2 I'm taking care of the second patch Care to bisect to find the first commit which started causing this problem? c499ff71ff2a281366c6ec7a904c547d806cbcd1 -- balbi -- IRC: gfa GPG: 0X44BB1BA79F6C6333 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot
Hi, gustavo panizzowrites: >>> On Wed, Jul 12, 2017 at 02:08:04PM +0800, Baolin Wang wrote: Hi, On 12 July 2017 at 11:52, gustavo panizzo wrote: > > 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(>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); >>> >>> >>> What about dwc3_event_buffers_cleanup? should I remove it from >>> dwc3_shutdown()? >>> It is already in dwc3_core_exit() >> >>I think so. We should avoid duplicate code. >> > + 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); We've done these in dwc3_core_exit(). > > This is the patch after testing on a Odroid XU4, on top of linux-next > 964bcc1b4f57028d56dace7d9bc5924f2eb43f36 which translates to > 4.13.0-rc1-next-20170717+ > I tested this patch for a week without problems with heavy USB and NIC usage. > Please consider merging it > > > Author: gustavo panizzo > Date: Wed Jul 12 11:26:55 2017 +0800 > > usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot > > 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. if the original patch is from Brian, then 'Author' should be Brian. Please fix it. I also don't get why all of a sudden we need to implement ->shutdown(). Why is it that we never needed it before and we need it now? Care to bisect to find the first commit which started causing this problem? -- balbi signature.asc Description: PGP signature
Re: [PATCH] usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot
Hello, On Thu, Jul 13, 2017 at 01:58:26PM +0800, Baolin Wang wrote: Hi, On 13 July 2017 at 07:20, gustavo panizzowrote: Hello Wang thanks for your response On Wed, Jul 12, 2017 at 02:08:04PM +0800, Baolin Wang wrote: Hi, On 12 July 2017 at 11:52, gustavo panizzo wrote: 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(>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); What about dwc3_event_buffers_cleanup? should I remove it from dwc3_shutdown()? It is already in dwc3_core_exit() I think so. We should avoid duplicate code. + 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); We've done these in dwc3_core_exit(). This is the patch after testing on a Odroid XU4, on top of linux-next 964bcc1b4f57028d56dace7d9bc5924f2eb43f36 which translates to 4.13.0-rc1-next-20170717+ I tested this patch for a week without problems with heavy USB and NIC usage. Please consider merging it Author: gustavo panizzo Date: Wed Jul 12 11:26:55 2017 +0800 usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot 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 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 326b302fc440..09de37d47ee7 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1259,6 +1259,32 @@ 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(>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); + + dwc3_core_exit(dwc); + dwc3_ulpi_exit(dwc); + + pm_runtime_put_sync(>dev); + pm_runtime_allow(>dev); + pm_runtime_disable(>dev); +} + static int dwc3_remove(struct platform_device *pdev) { struct dwc3 *dwc = platform_get_drvdata(pdev); @@ -1488,6 +1514,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), + + dwc3_core_exit(dwc); + dwc3_ulpi_exit(dwc); + + pm_runtime_put_sync(>dev); + pm_runtime_allow(>dev); + pm_runtime_disable(>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
Re: [PATCH] usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot
Hi, On 13 July 2017 at 07:20, gustavo panizzowrote: > Hello Wang > > thanks for your response > > > On Wed, Jul 12, 2017 at 02:08:04PM +0800, Baolin Wang wrote: >> >> Hi, >> >> On 12 July 2017 at 11:52, gustavo panizzo wrote: >>> >>> 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(>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); > > > What about dwc3_event_buffers_cleanup? should I remove it from > dwc3_shutdown()? > It is already in dwc3_core_exit() I think so. We should avoid duplicate code. >>> + 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); >> >> >> We've done these in dwc3_core_exit(). >> >>> + >>> + dwc3_core_exit(dwc); >>> + dwc3_ulpi_exit(dwc); >>> + >>> + pm_runtime_put_sync(>dev); >>> + pm_runtime_allow(>dev); >>> + pm_runtime_disable(>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 >>> >>> -- >>> To unsubscribe from this list: send the line "unsubscribe linux-usb" in >>> the body of a message to majord...@vger.kernel.org >>> More majordomo info at http://vger.kernel.org/majordomo-info.html >> >> >> >> >> -- >> Baolin.wang >> Best Regards > > > -- > IRC: gfa > GPG: 0X44BB1BA79F6C6333 > -- Baolin.wang Best Regards -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot
Hello Wang thanks for your response On Wed, Jul 12, 2017 at 02:08:04PM +0800, Baolin Wang wrote: Hi, On 12 July 2017 at 11:52, gustavo panizzowrote: 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(>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); What about dwc3_event_buffers_cleanup? should I remove it from dwc3_shutdown()? It is already in dwc3_core_exit() + 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); We've done these in dwc3_core_exit(). + + dwc3_core_exit(dwc); + dwc3_ulpi_exit(dwc); + + pm_runtime_put_sync(>dev); + pm_runtime_allow(>dev); + pm_runtime_disable(>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 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- Baolin.wang Best Regards -- IRC: gfa GPG: 0X44BB1BA79F6C6333 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot
Hi, On 12 July 2017 at 11:52, gustavo panizzowrote: > 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(>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); We've done these in dwc3_core_exit(). > + > + dwc3_core_exit(dwc); > + dwc3_ulpi_exit(dwc); > + > + pm_runtime_put_sync(>dev); > + pm_runtime_allow(>dev); > + pm_runtime_disable(>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 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Baolin.wang Best Regards -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html