Seeking Assistance: Implementing USB Device Suspend/Resume in User Space Driver

Alan Stern stern at rowland.harvard.edu
Tue May 7 10:20:58 EDT 2024


On Tue, May 07, 2024 at 05:14:25PM +0530, Muni Sekhar wrote:
> Thank you, it is very helpful.
> 
> To verify the USB device suspend\resume functionality, I configured
> the USB Power Management variables as follows:
> 
> # cat /sys/bus/usb/devices/2-1.7/power/wakeup
> enabled
> 
> # cat /sys/bus/usb/devices/2-1.7/power/control
> on

This means that the device will be permanently on, and so it will never 
be suspended.  If you want to allow the device to be suspended, you 
have to write "auto" to the file.

> # cat /sys/bus/usb/devices/2-1.7/power/autosuspend_delay_ms
> 0
> 
> # cat /sys/module/usbcore/parameters/autosuspend
> 2
> 
> 
> So, I configured the system to autosuspend the USB device as soon as
> it becomes idle, with no transactions running through the USB device.
> Now, how can I verify that the USB device has entered suspend mode
> from user space? When checking /var/log/kern.log, there are no
> relevant print statements. Are there any other log files related to
> power management or USB subsystems?
> Please correct me if anything in the test procedure mentioned above is
> incorrect.

You can see the device's current state by reading the 
power/runtime_status attribute file in sysfs.  There are lots of other 
informative files in that directory; you should look at them.

If you want to get more debugging information in the kernel log, you can 
enable dynamic debugging for usbcore:

	echo module usbcore =p >/sys/kernel/debug/dynamic_debug/control

Alan Stern



More information about the Kernelnewbies mailing list