linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] usb: chipidea: tegra: Delay PHY suspending
@ 2021-06-09 12:04 Dmitry Osipenko
  2021-06-09 12:07 ` Dmitry Osipenko
  2021-06-12  7:34 ` Peter Chen
  0 siblings, 2 replies; 4+ messages in thread
From: Dmitry Osipenko @ 2021-06-09 12:04 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Peter Chen, Greg Kroah-Hartman,
	Alan Stern, Felipe Balbi, Maxim Schwalm
  Cc: linux-tegra, linux-usb, linux-kernel

The ChipIdea driver enters into suspend immediately after seeing a
VBUS disconnection. Some devices need an extra delay after losing
VBUS, otherwise VBUS may be floating, preventing the PHY's suspending
by the VBUS detection sensors. This problem was found on Tegra30 Asus
Transformer TF700T tablet device, where the USB PHY wakes up immediately
from suspend because VBUS sensor continues to detect VBUS as active after
disconnection. A minimum delay of 20ms is needed in order to fix this
issue, hence add 25ms delay before suspending the PHY.

Reported-by: Maxim Schwalm <maxim.schwalm@gmail.com> # Asus TF700T
Tested-by: Maxim Schwalm <maxim.schwalm@gmail.com> # Asus TF700T
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/usb/chipidea/ci_hdrc_tegra.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/chipidea/ci_hdrc_tegra.c b/drivers/usb/chipidea/ci_hdrc_tegra.c
index 60361141ac04..d1359b76a0e8 100644
--- a/drivers/usb/chipidea/ci_hdrc_tegra.c
+++ b/drivers/usb/chipidea/ci_hdrc_tegra.c
@@ -4,6 +4,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
@@ -255,6 +256,13 @@ static int tegra_ehci_hub_control(struct ci_hdrc *ci, u16 typeReq, u16 wValue,
 
 static void tegra_usb_enter_lpm(struct ci_hdrc *ci, bool enable)
 {
+	/*
+	 * Give hardware time to settle down after VBUS disconnection,
+	 * otherwise PHY may wake up from suspend immediately.
+	 */
+	if (enable)
+		msleep(25);
+
 	/*
 	 * Touching any register which belongs to AHB clock domain will
 	 * hang CPU if USB controller is put into low power mode because
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] usb: chipidea: tegra: Delay PHY suspending
  2021-06-09 12:04 [PATCH v1] usb: chipidea: tegra: Delay PHY suspending Dmitry Osipenko
@ 2021-06-09 12:07 ` Dmitry Osipenko
  2021-06-12  7:34 ` Peter Chen
  1 sibling, 0 replies; 4+ messages in thread
From: Dmitry Osipenko @ 2021-06-09 12:07 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Greg Kroah-Hartman, Alan Stern,
	Felipe Balbi, Maxim Schwalm, Peter Chen
  Cc: linux-tegra, linux-usb, linux-kernel

09.06.2021 15:04, Dmitry Osipenko пишет:
> The ChipIdea driver enters into suspend immediately after seeing a
> VBUS disconnection. Some devices need an extra delay after losing
> VBUS, otherwise VBUS may be floating, preventing the PHY's suspending
> by the VBUS detection sensors. This problem was found on Tegra30 Asus
> Transformer TF700T tablet device, where the USB PHY wakes up immediately
> from suspend because VBUS sensor continues to detect VBUS as active after
> disconnection. A minimum delay of 20ms is needed in order to fix this
> issue, hence add 25ms delay before suspending the PHY.
> 
> Reported-by: Maxim Schwalm <maxim.schwalm@gmail.com> # Asus TF700T
> Tested-by: Maxim Schwalm <maxim.schwalm@gmail.com> # Asus TF700T
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/usb/chipidea/ci_hdrc_tegra.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_tegra.c b/drivers/usb/chipidea/ci_hdrc_tegra.c
> index 60361141ac04..d1359b76a0e8 100644
> --- a/drivers/usb/chipidea/ci_hdrc_tegra.c
> +++ b/drivers/usb/chipidea/ci_hdrc_tegra.c
> @@ -4,6 +4,7 @@
>   */
>  
>  #include <linux/clk.h>
> +#include <linux/delay.h>
>  #include <linux/io.h>
>  #include <linux/module.h>
>  #include <linux/of_device.h>
> @@ -255,6 +256,13 @@ static int tegra_ehci_hub_control(struct ci_hdrc *ci, u16 typeReq, u16 wValue,
>  
>  static void tegra_usb_enter_lpm(struct ci_hdrc *ci, bool enable)
>  {
> +	/*
> +	 * Give hardware time to settle down after VBUS disconnection,
> +	 * otherwise PHY may wake up from suspend immediately.
> +	 */
> +	if (enable)
> +		msleep(25);
> +
>  	/*
>  	 * Touching any register which belongs to AHB clock domain will
>  	 * hang CPU if USB controller is put into low power mode because
> 

I missed that Peter's email address changed. Making this reply to the
new address for visibility.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] usb: chipidea: tegra: Delay PHY suspending
  2021-06-09 12:04 [PATCH v1] usb: chipidea: tegra: Delay PHY suspending Dmitry Osipenko
  2021-06-09 12:07 ` Dmitry Osipenko
@ 2021-06-12  7:34 ` Peter Chen
  2021-06-12 13:55   ` Dmitry Osipenko
  1 sibling, 1 reply; 4+ messages in thread
From: Peter Chen @ 2021-06-12  7:34 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Thierry Reding, Jonathan Hunter, Peter Chen, Greg Kroah-Hartman,
	Alan Stern, Felipe Balbi, Maxim Schwalm, linux-tegra, linux-usb,
	linux-kernel

On 21-06-09 15:04:04, Dmitry Osipenko wrote:
> The ChipIdea driver enters into suspend immediately after seeing a
> VBUS disconnection. Some devices need an extra delay after losing
> VBUS, otherwise VBUS may be floating, preventing the PHY's suspending
> by the VBUS detection sensors. This problem was found on Tegra30 Asus
> Transformer TF700T tablet device, where the USB PHY wakes up immediately
> from suspend because VBUS sensor continues to detect VBUS as active after
> disconnection. A minimum delay of 20ms is needed in order to fix this
> issue, hence add 25ms delay before suspending the PHY.
> 
> Reported-by: Maxim Schwalm <maxim.schwalm@gmail.com> # Asus TF700T
> Tested-by: Maxim Schwalm <maxim.schwalm@gmail.com> # Asus TF700T
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/usb/chipidea/ci_hdrc_tegra.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_tegra.c b/drivers/usb/chipidea/ci_hdrc_tegra.c
> index 60361141ac04..d1359b76a0e8 100644
> --- a/drivers/usb/chipidea/ci_hdrc_tegra.c
> +++ b/drivers/usb/chipidea/ci_hdrc_tegra.c
> @@ -4,6 +4,7 @@
>   */
>  
>  #include <linux/clk.h>
> +#include <linux/delay.h>
>  #include <linux/io.h>
>  #include <linux/module.h>
>  #include <linux/of_device.h>
> @@ -255,6 +256,13 @@ static int tegra_ehci_hub_control(struct ci_hdrc *ci, u16 typeReq, u16 wValue,
>  
>  static void tegra_usb_enter_lpm(struct ci_hdrc *ci, bool enable)
>  {
> +	/*
> +	 * Give hardware time to settle down after VBUS disconnection,
> +	 * otherwise PHY may wake up from suspend immediately.
> +	 */
> +	if (enable)
> +		msleep(25);
> +

How could you know 25ms is enough for other Tegra designs?
Could you poll VBUS wakeup threshold register to ensure the
wakeup will not occur? The similar design exists at function:
hw_wait_vbus_lower_bsv.

-- 

Thanks,
Peter Chen


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] usb: chipidea: tegra: Delay PHY suspending
  2021-06-12  7:34 ` Peter Chen
@ 2021-06-12 13:55   ` Dmitry Osipenko
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Osipenko @ 2021-06-12 13:55 UTC (permalink / raw)
  To: Peter Chen
  Cc: Thierry Reding, Jonathan Hunter, Peter Chen, Greg Kroah-Hartman,
	Alan Stern, Felipe Balbi, Maxim Schwalm, linux-tegra, linux-usb,
	linux-kernel

12.06.2021 10:34, Peter Chen пишет:
> On 21-06-09 15:04:04, Dmitry Osipenko wrote:
>> The ChipIdea driver enters into suspend immediately after seeing a
>> VBUS disconnection. Some devices need an extra delay after losing
>> VBUS, otherwise VBUS may be floating, preventing the PHY's suspending
>> by the VBUS detection sensors. This problem was found on Tegra30 Asus
>> Transformer TF700T tablet device, where the USB PHY wakes up immediately
>> from suspend because VBUS sensor continues to detect VBUS as active after
>> disconnection. A minimum delay of 20ms is needed in order to fix this
>> issue, hence add 25ms delay before suspending the PHY.
>>
>> Reported-by: Maxim Schwalm <maxim.schwalm@gmail.com> # Asus TF700T
>> Tested-by: Maxim Schwalm <maxim.schwalm@gmail.com> # Asus TF700T
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  drivers/usb/chipidea/ci_hdrc_tegra.c | 8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/drivers/usb/chipidea/ci_hdrc_tegra.c b/drivers/usb/chipidea/ci_hdrc_tegra.c
>> index 60361141ac04..d1359b76a0e8 100644
>> --- a/drivers/usb/chipidea/ci_hdrc_tegra.c
>> +++ b/drivers/usb/chipidea/ci_hdrc_tegra.c
>> @@ -4,6 +4,7 @@
>>   */
>>  
>>  #include <linux/clk.h>
>> +#include <linux/delay.h>
>>  #include <linux/io.h>
>>  #include <linux/module.h>
>>  #include <linux/of_device.h>
>> @@ -255,6 +256,13 @@ static int tegra_ehci_hub_control(struct ci_hdrc *ci, u16 typeReq, u16 wValue,
>>  
>>  static void tegra_usb_enter_lpm(struct ci_hdrc *ci, bool enable)
>>  {
>> +	/*
>> +	 * Give hardware time to settle down after VBUS disconnection,
>> +	 * otherwise PHY may wake up from suspend immediately.
>> +	 */
>> +	if (enable)
>> +		msleep(25);
>> +
> 
> How could you know 25ms is enough for other Tegra designs?

I don't know what is the maximum timeout could be, but it shouldn't be a
problem to bump the timeout if somebody will report the need to do so.

> Could you poll VBUS wakeup threshold register to ensure the
> wakeup will not occur?

We indeed can poll the wakeup threshold status in the PHY driver, it
works too. I'll make the patch for the PHY driver, thank you for the
suggestion.

> The similar design exists at function:
> hw_wait_vbus_lower_bsv.

The hw_wait_vbus_lower_bsv uses 5sec timeout, which should be too much.
I'll set the polling timeout to 100ms.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-12 13:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 12:04 [PATCH v1] usb: chipidea: tegra: Delay PHY suspending Dmitry Osipenko
2021-06-09 12:07 ` Dmitry Osipenko
2021-06-12  7:34 ` Peter Chen
2021-06-12 13:55   ` Dmitry Osipenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).