diff mbox series

[V2] drivers:usb:disable usb hub&port async suspend

Message ID 20240228072030.2470-1-buckzhangwh@gmail.com (mailing list archive)
State Superseded
Headers show
Series [V2] drivers:usb:disable usb hub&port async suspend | expand

Commit Message

buckzhangwh@gmail.com Feb. 28, 2024, 7:20 a.m. UTC
From: weihui zhang <buckzhangwh@gmail.com>

we prepare 30 mobile phones only for usb plugg in and out.
testers plug USB in and out very frequently after phone in deep.
Repeat the test again and again,some phones are crashed.
our analysis:
We analyze ten kernel-dumps,we found something common kernel is blocked.
pasre in crash,all the dump are directed to usb(device port/hub).
here is a kdump,task 446 &365&4511 are UN.
446:
.... ->|kobj_attr_store
          |state_store
            |pm_suspend
              |enter_state
                |suspend_devices_and_enter
                 |dpm_resume_end
                   |dpm_resume
                    |dpm_resume
                     |async_synchronize_full
                      |async_synchronize_cookie_domain
                       |schedule
446 is waiting for 365&4511,no doubtful usb thread.
here is some warning log:
[83.958310] musb device disconnect detected from VBUS GPIO.
..........
[84.908017] musb device connection detected from VBUS GPIO.
[84.911946] typec port1-partner: parent port1 should not be sleeping
task 365 & 4511:
... ->worker_thread
       |process_one_work
        |async_run_entry_fn
          |async_resume
            |device_resume
              |dpm_wait_for_superior
                |wait_for_completion
                  |wait_for_common
                     |schedule_timeout
I guess usb async resume/suspend are disordered,So I try to disable.
After that,we tested the case for a month,the bug never happened again.
the fn device_enable_async_suspend set the dev->power.async_suspend= 1.
dev->power.async_suspend=1&pm_async_enabled=1,fork task like 365
   ---> dpm_resume
           |dpm_async_fn
             |async_resume  
dev->power.async_suspend=0,disable async
     --->dpm_resume
            |device_resume
              |call device resume fn.
here is a demo:
Only few devices such as scsi/pci/usb call device_enable_async_suspend.
but scsi call device_disable_async_suspend at drivers/scsi/hosts.c

Signed-off-by: weihui zhang <buckzhangwh@gmail.com>
---
 drivers/usb/core/hub.c  | 2 +-
 drivers/usb/core/port.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Greg Kroah-Hartman Feb. 28, 2024, 8:10 a.m. UTC | #1
On Tue, Feb 27, 2024 at 11:20:30PM -0800, buckzhangwh@gmail.com wrote:
> From: weihui zhang <buckzhangwh@gmail.com>
> 
> we prepare 30 mobile phones only for usb plugg in and out.
> testers plug USB in and out very frequently after phone in deep.
> Repeat the test again and again,some phones are crashed.
> our analysis:
> We analyze ten kernel-dumps,we found something common kernel is blocked.
> pasre in crash,all the dump are directed to usb(device port/hub).
> here is a kdump,task 446 &365&4511 are UN.
> 446:
> .... ->|kobj_attr_store
>           |state_store
>             |pm_suspend
>               |enter_state
>                 |suspend_devices_and_enter
>                  |dpm_resume_end
>                    |dpm_resume
>                     |dpm_resume
>                      |async_synchronize_full
>                       |async_synchronize_cookie_domain
>                        |schedule
> 446 is waiting for 365&4511,no doubtful usb thread.
> here is some warning log:
> [83.958310] musb device disconnect detected from VBUS GPIO.
> ..........
> [84.908017] musb device connection detected from VBUS GPIO.
> [84.911946] typec port1-partner: parent port1 should not be sleeping
> task 365 & 4511:
> ... ->worker_thread
>        |process_one_work
>         |async_run_entry_fn
>           |async_resume
>             |device_resume
>               |dpm_wait_for_superior
>                 |wait_for_completion
>                   |wait_for_common
>                      |schedule_timeout
> I guess usb async resume/suspend are disordered,So I try to disable.
> After that,we tested the case for a month,the bug never happened again.
> the fn device_enable_async_suspend set the dev->power.async_suspend= 1.
> dev->power.async_suspend=1&pm_async_enabled=1,fork task like 365
>    ---> dpm_resume
>            |dpm_async_fn
>              |async_resume  
> dev->power.async_suspend=0,disable async
>      --->dpm_resume
>             |device_resume
>               |call device resume fn.
> here is a demo:
> Only few devices such as scsi/pci/usb call device_enable_async_suspend.
> but scsi call device_disable_async_suspend at drivers/scsi/hosts.c
> 
> Signed-off-by: weihui zhang <buckzhangwh@gmail.com>
> ---
>  drivers/usb/core/hub.c  | 2 +-
>  drivers/usb/core/port.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index e38a4124f..de74f70e5 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -2602,7 +2602,7 @@ int usb_new_device(struct usb_device *udev)
>  		add_device_randomness(udev->manufacturer,
>  				      strlen(udev->manufacturer));
>  
> -	device_enable_async_suspend(&udev->dev);
> +	device_disable_async_suspend(&udev->dev);
>  
>  	/* check whether the hub or firmware marks this port as non-removable */
>  	set_usb_port_removable(udev);
> diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
> index c628c1abc..97696c415 100644
> --- a/drivers/usb/core/port.c
> +++ b/drivers/usb/core/port.c
> @@ -760,7 +760,7 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1)
>  	pm_runtime_set_active(&port_dev->dev);
>  	pm_runtime_get_noresume(&port_dev->dev);
>  	pm_runtime_enable(&port_dev->dev);
> -	device_enable_async_suspend(&port_dev->dev);
> +	device_disable_async_suspend(&port_dev->dev);
>  
>  	/*
>  	 * Keep hidden the ability to enable port-poweroff if the hub
> -- 
> 2.17.1
> 
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- This looks like a new version of a previously submitted patch, but you
  did not list below the --- line any changes from the previous version.
  Please read the section entitled "The canonical patch format" in the
  kernel file, Documentation/process/submitting-patches.rst for what
  needs to be done here to properly describe this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot
diff mbox series

Patch

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index e38a4124f..de74f70e5 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2602,7 +2602,7 @@  int usb_new_device(struct usb_device *udev)
 		add_device_randomness(udev->manufacturer,
 				      strlen(udev->manufacturer));
 
-	device_enable_async_suspend(&udev->dev);
+	device_disable_async_suspend(&udev->dev);
 
 	/* check whether the hub or firmware marks this port as non-removable */
 	set_usb_port_removable(udev);
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index c628c1abc..97696c415 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -760,7 +760,7 @@  int usb_hub_create_port_device(struct usb_hub *hub, int port1)
 	pm_runtime_set_active(&port_dev->dev);
 	pm_runtime_get_noresume(&port_dev->dev);
 	pm_runtime_enable(&port_dev->dev);
-	device_enable_async_suspend(&port_dev->dev);
+	device_disable_async_suspend(&port_dev->dev);
 
 	/*
 	 * Keep hidden the ability to enable port-poweroff if the hub