linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] USB: core: Disable LPM only for non-suspended ports
@ 2024-12-06  7:48 Kai-Heng Feng
  2024-12-06 14:13 ` Alan Stern
  2024-12-18 16:21 ` Jon Hunter
  0 siblings, 2 replies; 5+ messages in thread
From: Kai-Heng Feng @ 2024-12-06  7:48 UTC (permalink / raw)
  To: gregkh
  Cc: stern, mathias.nyman, linux-usb, linux-kernel, Kai-Heng Feng,
	Wayne Chang, stable

There's USB error when tegra board is shutting down:
[  180.919315] usb 2-3: Failed to set U1 timeout to 0x0,error code -113
[  180.919995] usb 2-3: Failed to set U1 timeout to 0xa,error code -113
[  180.920512] usb 2-3: Failed to set U2 timeout to 0x4,error code -113
[  186.157172] tegra-xusb 3610000.usb: xHCI host controller not responding, assume dead
[  186.157858] tegra-xusb 3610000.usb: HC died; cleaning up
[  186.317280] tegra-xusb 3610000.usb: Timeout while waiting for evaluate context command

The issue is caused by disabling LPM on already suspended ports.

For USB2 LPM, the LPM is already disabled during port suspend. For USB3
LPM, port won't transit to U1/U2 when it's already suspended in U3,
hence disabling LPM is only needed for ports that are not suspended.

Cc: Wayne Chang <waynec@nvidia.com>
Cc: stable@vger.kernel.org
Fixes: d920a2ed8620 ("usb: Disable USB3 LPM at shutdown")
Signed-off-by: Kai-Heng Feng <kaihengf@nvidia.com>
---
v3:
 Use udev->port_is_suspended which reflects upstream port status

v2:
 Add "Cc: stable@vger.kernel.org"

 drivers/usb/core/port.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index e7da2fca11a4..c92fb648a1c4 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -452,10 +452,11 @@ static int usb_port_runtime_suspend(struct device *dev)
 static void usb_port_shutdown(struct device *dev)
 {
 	struct usb_port *port_dev = to_usb_port(dev);
+	struct usb_device *udev = port_dev->child;
 
-	if (port_dev->child) {
-		usb_disable_usb2_hardware_lpm(port_dev->child);
-		usb_unlocked_disable_lpm(port_dev->child);
+	if (udev && !udev->port_is_suspended) {
+		usb_disable_usb2_hardware_lpm(udev);
+		usb_unlocked_disable_lpm(udev);
 	}
 }
 
-- 
2.47.0


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

* Re: [PATCH v3] USB: core: Disable LPM only for non-suspended ports
  2024-12-06  7:48 [PATCH v3] USB: core: Disable LPM only for non-suspended ports Kai-Heng Feng
@ 2024-12-06 14:13 ` Alan Stern
  2024-12-18 16:21 ` Jon Hunter
  1 sibling, 0 replies; 5+ messages in thread
From: Alan Stern @ 2024-12-06 14:13 UTC (permalink / raw)
  To: Kai-Heng Feng
  Cc: gregkh, mathias.nyman, linux-usb, linux-kernel, Wayne Chang,
	stable

On Fri, Dec 06, 2024 at 03:48:17PM +0800, Kai-Heng Feng wrote:
> There's USB error when tegra board is shutting down:
> [  180.919315] usb 2-3: Failed to set U1 timeout to 0x0,error code -113
> [  180.919995] usb 2-3: Failed to set U1 timeout to 0xa,error code -113
> [  180.920512] usb 2-3: Failed to set U2 timeout to 0x4,error code -113
> [  186.157172] tegra-xusb 3610000.usb: xHCI host controller not responding, assume dead
> [  186.157858] tegra-xusb 3610000.usb: HC died; cleaning up
> [  186.317280] tegra-xusb 3610000.usb: Timeout while waiting for evaluate context command
> 
> The issue is caused by disabling LPM on already suspended ports.
> 
> For USB2 LPM, the LPM is already disabled during port suspend. For USB3
> LPM, port won't transit to U1/U2 when it's already suspended in U3,
> hence disabling LPM is only needed for ports that are not suspended.
> 
> Cc: Wayne Chang <waynec@nvidia.com>
> Cc: stable@vger.kernel.org
> Fixes: d920a2ed8620 ("usb: Disable USB3 LPM at shutdown")
> Signed-off-by: Kai-Heng Feng <kaihengf@nvidia.com>
> ---
> v3:
>  Use udev->port_is_suspended which reflects upstream port status
> 
> v2:
>  Add "Cc: stable@vger.kernel.org"

Acked-by: Alan Stern <stern@rowland.harvard.edu>

>  drivers/usb/core/port.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
> index e7da2fca11a4..c92fb648a1c4 100644
> --- a/drivers/usb/core/port.c
> +++ b/drivers/usb/core/port.c
> @@ -452,10 +452,11 @@ static int usb_port_runtime_suspend(struct device *dev)
>  static void usb_port_shutdown(struct device *dev)
>  {
>  	struct usb_port *port_dev = to_usb_port(dev);
> +	struct usb_device *udev = port_dev->child;
>  
> -	if (port_dev->child) {
> -		usb_disable_usb2_hardware_lpm(port_dev->child);
> -		usb_unlocked_disable_lpm(port_dev->child);
> +	if (udev && !udev->port_is_suspended) {
> +		usb_disable_usb2_hardware_lpm(udev);
> +		usb_unlocked_disable_lpm(udev);
>  	}
>  }
>  
> -- 
> 2.47.0
> 

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

* Re: [PATCH v3] USB: core: Disable LPM only for non-suspended ports
  2024-12-06  7:48 [PATCH v3] USB: core: Disable LPM only for non-suspended ports Kai-Heng Feng
  2024-12-06 14:13 ` Alan Stern
@ 2024-12-18 16:21 ` Jon Hunter
  2025-01-02 14:20   ` Jon Hunter
  1 sibling, 1 reply; 5+ messages in thread
From: Jon Hunter @ 2024-12-18 16:21 UTC (permalink / raw)
  To: Kai-Heng Feng, gregkh
  Cc: stern, mathias.nyman, linux-usb, linux-kernel, Wayne Chang,
	stable, linux-tegra@vger.kernel.org


On 06/12/2024 07:48, Kai-Heng Feng wrote:
> There's USB error when tegra board is shutting down:
> [  180.919315] usb 2-3: Failed to set U1 timeout to 0x0,error code -113
> [  180.919995] usb 2-3: Failed to set U1 timeout to 0xa,error code -113
> [  180.920512] usb 2-3: Failed to set U2 timeout to 0x4,error code -113
> [  186.157172] tegra-xusb 3610000.usb: xHCI host controller not responding, assume dead
> [  186.157858] tegra-xusb 3610000.usb: HC died; cleaning up
> [  186.317280] tegra-xusb 3610000.usb: Timeout while waiting for evaluate context command
> 
> The issue is caused by disabling LPM on already suspended ports.
> 
> For USB2 LPM, the LPM is already disabled during port suspend. For USB3
> LPM, port won't transit to U1/U2 when it's already suspended in U3,
> hence disabling LPM is only needed for ports that are not suspended.
> 
> Cc: Wayne Chang <waynec@nvidia.com>
> Cc: stable@vger.kernel.org
> Fixes: d920a2ed8620 ("usb: Disable USB3 LPM at shutdown")
> Signed-off-by: Kai-Heng Feng <kaihengf@nvidia.com>
> ---
> v3:
>   Use udev->port_is_suspended which reflects upstream port status
> 
> v2:
>   Add "Cc: stable@vger.kernel.org"
> 
>   drivers/usb/core/port.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
> index e7da2fca11a4..c92fb648a1c4 100644
> --- a/drivers/usb/core/port.c
> +++ b/drivers/usb/core/port.c
> @@ -452,10 +452,11 @@ static int usb_port_runtime_suspend(struct device *dev)
>   static void usb_port_shutdown(struct device *dev)
>   {
>   	struct usb_port *port_dev = to_usb_port(dev);
> +	struct usb_device *udev = port_dev->child;
>   
> -	if (port_dev->child) {
> -		usb_disable_usb2_hardware_lpm(port_dev->child);
> -		usb_unlocked_disable_lpm(port_dev->child);
> +	if (udev && !udev->port_is_suspended) {
> +		usb_disable_usb2_hardware_lpm(udev);
> +		usb_unlocked_disable_lpm(udev);
>   	}
>   }
>   


This resolves the issue I have been seeing [0].

Tested-by: Jon Hunter <jonathanh@nvidia.com>

Thanks!
Jon

[0] 
https://lore.kernel.org/linux-usb/d5e79487-0f99-4ff2-8f49-0c403f1190af@nvidia.com/

-- 
nvpublic


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

* Re: [PATCH v3] USB: core: Disable LPM only for non-suspended ports
  2024-12-18 16:21 ` Jon Hunter
@ 2025-01-02 14:20   ` Jon Hunter
  2025-01-03  7:09     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Jon Hunter @ 2025-01-02 14:20 UTC (permalink / raw)
  To: gregkh
  Cc: stern, mathias.nyman, linux-usb, linux-kernel, Wayne Chang,
	stable, linux-tegra@vger.kernel.org, Kai-Heng Feng

Hi Greg,

On 18/12/2024 16:21, Jon Hunter wrote:
> 
> On 06/12/2024 07:48, Kai-Heng Feng wrote:
>> There's USB error when tegra board is shutting down:
>> [  180.919315] usb 2-3: Failed to set U1 timeout to 0x0,error code -113
>> [  180.919995] usb 2-3: Failed to set U1 timeout to 0xa,error code -113
>> [  180.920512] usb 2-3: Failed to set U2 timeout to 0x4,error code -113
>> [  186.157172] tegra-xusb 3610000.usb: xHCI host controller not 
>> responding, assume dead
>> [  186.157858] tegra-xusb 3610000.usb: HC died; cleaning up
>> [  186.317280] tegra-xusb 3610000.usb: Timeout while waiting for 
>> evaluate context command
>>
>> The issue is caused by disabling LPM on already suspended ports.
>>
>> For USB2 LPM, the LPM is already disabled during port suspend. For USB3
>> LPM, port won't transit to U1/U2 when it's already suspended in U3,
>> hence disabling LPM is only needed for ports that are not suspended.
>>
>> Cc: Wayne Chang <waynec@nvidia.com>
>> Cc: stable@vger.kernel.org
>> Fixes: d920a2ed8620 ("usb: Disable USB3 LPM at shutdown")
>> Signed-off-by: Kai-Heng Feng <kaihengf@nvidia.com>
>> ---
>> v3:
>>   Use udev->port_is_suspended which reflects upstream port status
>>
>> v2:
>>   Add "Cc: stable@vger.kernel.org"
>>
>>   drivers/usb/core/port.c | 7 ++++---
>>   1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
>> index e7da2fca11a4..c92fb648a1c4 100644
>> --- a/drivers/usb/core/port.c
>> +++ b/drivers/usb/core/port.c
>> @@ -452,10 +452,11 @@ static int usb_port_runtime_suspend(struct 
>> device *dev)
>>   static void usb_port_shutdown(struct device *dev)
>>   {
>>       struct usb_port *port_dev = to_usb_port(dev);
>> +    struct usb_device *udev = port_dev->child;
>> -    if (port_dev->child) {
>> -        usb_disable_usb2_hardware_lpm(port_dev->child);
>> -        usb_unlocked_disable_lpm(port_dev->child);
>> +    if (udev && !udev->port_is_suspended) {
>> +        usb_disable_usb2_hardware_lpm(udev);
>> +        usb_unlocked_disable_lpm(udev);
>>       }
>>   }
> 
> 
> This resolves the issue I have been seeing [0].
> 
> Tested-by: Jon Hunter <jonathanh@nvidia.com>
> 
> Thanks!
> Jon
> 
> [0] https://lore.kernel.org/linux-usb/ 
> d5e79487-0f99-4ff2-8f49-0c403f1190af@nvidia.com/


Let me know if you OK to pick up this fix now?

Thanks!
Jon

-- 
nvpublic


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

* Re: [PATCH v3] USB: core: Disable LPM only for non-suspended ports
  2025-01-02 14:20   ` Jon Hunter
@ 2025-01-03  7:09     ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2025-01-03  7:09 UTC (permalink / raw)
  To: Jon Hunter
  Cc: stern, mathias.nyman, linux-usb, linux-kernel, Wayne Chang,
	stable, linux-tegra@vger.kernel.org, Kai-Heng Feng

On Thu, Jan 02, 2025 at 02:20:13PM +0000, Jon Hunter wrote:
> Hi Greg,
> 
> On 18/12/2024 16:21, Jon Hunter wrote:
> > 
> > On 06/12/2024 07:48, Kai-Heng Feng wrote:
> > > There's USB error when tegra board is shutting down:
> > > [  180.919315] usb 2-3: Failed to set U1 timeout to 0x0,error code -113
> > > [  180.919995] usb 2-3: Failed to set U1 timeout to 0xa,error code -113
> > > [  180.920512] usb 2-3: Failed to set U2 timeout to 0x4,error code -113
> > > [  186.157172] tegra-xusb 3610000.usb: xHCI host controller not
> > > responding, assume dead
> > > [  186.157858] tegra-xusb 3610000.usb: HC died; cleaning up
> > > [  186.317280] tegra-xusb 3610000.usb: Timeout while waiting for
> > > evaluate context command
> > > 
> > > The issue is caused by disabling LPM on already suspended ports.
> > > 
> > > For USB2 LPM, the LPM is already disabled during port suspend. For USB3
> > > LPM, port won't transit to U1/U2 when it's already suspended in U3,
> > > hence disabling LPM is only needed for ports that are not suspended.
> > > 
> > > Cc: Wayne Chang <waynec@nvidia.com>
> > > Cc: stable@vger.kernel.org
> > > Fixes: d920a2ed8620 ("usb: Disable USB3 LPM at shutdown")
> > > Signed-off-by: Kai-Heng Feng <kaihengf@nvidia.com>
> > > ---
> > > v3:
> > >   Use udev->port_is_suspended which reflects upstream port status
> > > 
> > > v2:
> > >   Add "Cc: stable@vger.kernel.org"
> > > 
> > >   drivers/usb/core/port.c | 7 ++++---
> > >   1 file changed, 4 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
> > > index e7da2fca11a4..c92fb648a1c4 100644
> > > --- a/drivers/usb/core/port.c
> > > +++ b/drivers/usb/core/port.c
> > > @@ -452,10 +452,11 @@ static int usb_port_runtime_suspend(struct
> > > device *dev)
> > >   static void usb_port_shutdown(struct device *dev)
> > >   {
> > >       struct usb_port *port_dev = to_usb_port(dev);
> > > +    struct usb_device *udev = port_dev->child;
> > > -    if (port_dev->child) {
> > > -        usb_disable_usb2_hardware_lpm(port_dev->child);
> > > -        usb_unlocked_disable_lpm(port_dev->child);
> > > +    if (udev && !udev->port_is_suspended) {
> > > +        usb_disable_usb2_hardware_lpm(udev);
> > > +        usb_unlocked_disable_lpm(udev);
> > >       }
> > >   }
> > 
> > 
> > This resolves the issue I have been seeing [0].
> > 
> > Tested-by: Jon Hunter <jonathanh@nvidia.com>
> > 
> > Thanks!
> > Jon
> > 
> > [0] https://lore.kernel.org/linux-usb/
> > d5e79487-0f99-4ff2-8f49-0c403f1190af@nvidia.com/
> 
> 
> Let me know if you OK to pick up this fix now?

This is already in linux-next and in my usb-linus branch and should go
to Linus today or tomorrow.

thanks,

greg k-h

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

end of thread, other threads:[~2025-01-03  7:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-06  7:48 [PATCH v3] USB: core: Disable LPM only for non-suspended ports Kai-Heng Feng
2024-12-06 14:13 ` Alan Stern
2024-12-18 16:21 ` Jon Hunter
2025-01-02 14:20   ` Jon Hunter
2025-01-03  7:09     ` Greg KH

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).