Skip to contentSkip to conversation

USB device autosuspend and its runtime usage count.

Query Anshuman Gupta 3 participants 5 messages Aug 13, 2018

lore
Share & tools
lore
#0 lore raw

Hi ,
I need to test a functionality with USB autosuspend with latest kernel Linux 4.18-rc8. I am trying to autosuspend a USB key board, i enabled its autosuspend by doing echo "auto" to its "control" attributes. I am expecting USB keyboard to go to autosuspend after autosuspend_delay_ms. But USB key board is not going to autosuspend because its runtime usage count is not equal to zero.

Below are the log snippets:

root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/runtime_enabled
enabled
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/control
auto
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/autosuspend_delay_ms
2000
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/runtime_status
active
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/runtime_usage
1
root@intel-Kabylake-Client-platform:# sleep 60; cat /sys/bus/usb/devices/1-5/power/runtime_usage
1

My USB keyboard runtime usage reference count is not decreasing to zero. Here am i missing something regarding runtime usage count or is it some issue with my kernel or OS?

Thanks,
Anshuman Gupta.

#1 lore raw
Quoted 23 lines · Anshuman Gupta

Hi ,
I need to test a functionality with USB autosuspend with latest kernel Linux 4.18-rc8. I am trying to autosuspend a USB key board, i enabled its autosuspend by doing echo "auto" to its "control" attributes. I am expecting USB keyboard to go to autosuspend after autosuspend_delay_ms. But USB key board is not going to autosuspend because its runtime usage count is not equal to zero.

Below are the log snippets:

root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/runtime_enabled
enabled
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/control
auto
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/autosuspend_delay_ms
2000
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/runtime_status
active
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/runtime_usage
1
root@intel-Kabylake-Client-platform:# sleep 60; cat /sys/bus/usb/devices/1-5/power/runtime_usage
1
Quoted 3 lines

My USB keyboard runtime usage reference count is not decreasing to zero. Here am i missing something regarding runtime usage count or is it some issue with my kernel or OS?

Very hard to say without further information. Is the HID device the only interface of the whole device?
Does the device support remote wakeup?
Is an LED on?

Usbhid does support autosuspend, but its criteria must be met. And all interface drivers must call the device idle. Or you have discovered a kernel bug.

Regards
Oliver

#2 lore raw
Quoted 24 lines · Oliver Neukum
Quoted 23 lines · Anshuman Gupta

Hi ,
I need to test a functionality with USB autosuspend with latest kernel Linux 4.18-rc8. I am trying to autosuspend a USB key board, i enabled its autosuspend by doing echo "auto" to its "control" attributes. I am expecting USB keyboard to go to autosuspend after autosuspend_delay_ms. But USB key board is not going to autosuspend because its runtime usage count is not equal to zero.

Below are the log snippets:

root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/runtime_enabled
enabled
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/control
auto
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/autosuspend_delay_ms
2000
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/runtime_status
active
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/runtime_usage
1
root@intel-Kabylake-Client-platform:# sleep 60; cat /sys/bus/usb/devices/1-5/power/runtime_usage
1
Quoted 6 lines
Quoted 3 lines

My USB keyboard runtime usage reference count is not decreasing to zero. Here am i missing something regarding runtime usage count or is it some issue with my kernel or OS?

Very hard to say without further information. Is the HID device the only interface of the whole device?

yes, HID device is only the interface for given device, below here lsusb -t log for usb dev 1-5.

root@intel-Kabylake-Client-platform:# lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M
    |__ Port 5: Dev 3, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
    |__ Port 5: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
Quoted 1 line

Does the device support remote wakeup?

yes, from lsusb logs it seems, it is supporting remote wakeup.

root@intel-Kabylake-Client-platform:# lsusb 
Bus 001 Device 003: ID 04d9:1702 Holtek Semiconductor, Inc. Keyboard LKS02
root@intel-Kabylake-Client-platform:# lsusb -v -d 04d9:1702 | grep Remote
      Remote Wakeup
Quoted 1 line

Is an LED on?

Num lock led was on, but switching it off also does not help.

Quoted 3 lines

Usbhid does support autosuspend, but its criteria must be met. And all interface drivers must call the device idle.

All of its interfaces are in runtime suspend

root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5\:1.0/power/runtime_status 
suspended
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5\:1.1/power/runtime_status 
suspended
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/runtime_active_kids 
0
Quoted 5 lines

Or you have discovered a kernel bug.

Regards
Oliver

Signature · 2 lines
Thanks,
Anshuman
#3 lore raw
Quoted 9 lines · Anshuman Gupta

All of its interfaces are in runtime suspend

root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5\:1.0/power/runtime_status 
suspended
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5\:1.1/power/runtime_status 
suspended
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/runtime_active_kids 
0

Is the RESET_RESUME quirk set for this device?
All children idle but the parent active is odd.

Regards
Oliver

#4 lore raw
In reply to Anshuman Gupta
Quoted 52 lines · Anshuman Gupta
Quoted 24 lines · Oliver Neukum
Quoted 23 lines · Anshuman Gupta

Hi ,
I need to test a functionality with USB autosuspend with latest kernel Linux 4.18-rc8. I am trying to autosuspend a USB key board, i enabled its autosuspend by doing echo "auto" to its "control" attributes. I am expecting USB keyboard to go to autosuspend after autosuspend_delay_ms. But USB key board is not going to autosuspend because its runtime usage count is not equal to zero.

Below are the log snippets:

root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/runtime_enabled
enabled
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/control
auto
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/autosuspend_delay_ms
2000
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/runtime_status
active
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/runtime_usage
1
root@intel-Kabylake-Client-platform:# sleep 60; cat /sys/bus/usb/devices/1-5/power/runtime_usage
1
Quoted 6 lines
Quoted 3 lines

My USB keyboard runtime usage reference count is not decreasing to zero. Here am i missing something regarding runtime usage count or is it some issue with my kernel or OS?

Very hard to say without further information. Is the HID device the only interface of the whole device?

yes, HID device is only the interface for given device, below here lsusb -t log for usb dev 1-5.

root@intel-Kabylake-Client-platform:# lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M
    |__ Port 5: Dev 3, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
    |__ Port 5: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
Quoted 1 line

Does the device support remote wakeup?

yes, from lsusb logs it seems, it is supporting remote wakeup.

root@intel-Kabylake-Client-platform:# lsusb 
Bus 001 Device 003: ID 04d9:1702 Holtek Semiconductor, Inc. Keyboard LKS02
root@intel-Kabylake-Client-platform:# lsusb -v -d 04d9:1702 | grep Remote
      Remote Wakeup
Quoted 1 line

Is an LED on?

Num lock led was on, but switching it off also does not help.

Quoted 3 lines

Usbhid does support autosuspend, but its criteria must be met. And all interface drivers must call the device idle.

Quoted 8 lines

All of its interfaces are in runtime suspend

root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5\:1.0/power/runtime_status 
suspended
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5\:1.1/power/runtime_status 
suspended
root@intel-Kabylake-Client-platform:# cat /sys/bus/usb/devices/1-5/power/runtime_active_kids 
0

What matters is not the power/* settings for the interfaces themselves, but rather the power/* settings for the interfaces' children.

Alan Stern