Why is host-initated USB3 Link Power Management (LPM) not enabled on my Linux system?

0

I'm running Linux kernel 4.20.17 on a Coffee Lake-based NUC which is always on, therefore I'd like to try to save as much power as possible when the system is idling. I have an external 2.5" bus-powered USB3.0 hard drive connected to it (to the root hub). I managed to configure the USB runtime PM to autosuspend (spin-down) the drive after a predefined period of time which gives me an idle power consumption of around 6W. However, when I physically unplug the drive in the suspended state, the power consumption goes down by another watt which is a lot and suggests that link PM is not active and might help here.

The device itself advertises the respective U1 and U2 exit latencies:

Bus 002 Device 002: ID 1058:2599 Western Digital Technologies, Inc. My Passport Ultra (WD40NMZW)
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               3.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         9
  idVendor           0x1058 Western Digital Technologies, Inc.
  idProduct          0x2599 My Passport Ultra (WD40NMZW)
  bcdDevice           10.12
  iManufacturer           2 Western Digital
  iProduct                3 My Passport 2599
  iSerial                 1 575831314439354837315633
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           44
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              896mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk-Only
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0400  1x 1024 bytes
        bInterval               0
        bMaxBurst              15
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0400  1x 1024 bytes
        bInterval               0
        bMaxBurst              15
Binary Object Store Descriptor:
  bLength                 5
  bDescriptorType        15
  wTotalLength           22
  bNumDeviceCaps          2
  USB 2.0 Extension Device Capability:
    bLength                 7
    bDescriptorType        16
    bDevCapabilityType      2
    bmAttributes   0x0000f41e
      BESL Link Power Management (LPM) Supported
    BESL value     1024 us 
    Deep BESL value    61440 us 
  SuperSpeed USB Device Capability:
    bLength                10
    bDescriptorType        16
    bDevCapabilityType      3
    bmAttributes         0x00
    wSpeedsSupported   0x000e
      Device can operate at Full Speed (12Mbps)
      Device can operate at High Speed (480Mbps)
      Device can operate at SuperSpeed (5Gbps)
    bFunctionalitySupport   1
      Lowest fully-functional device speed is Full Speed (12Mbps)
    bU1DevExitLat          10 micro seconds
    bU2DevExitLat        2047 micro seconds
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x000c
  (Bus Powered)
  U1 Enabled
  U2 Enabled

The root hub does the same:

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               3.10
  bDeviceClass            9 Hub
  bDeviceSubClass         0 
  bDeviceProtocol         3 
  bMaxPacketSize0         9
  idVendor           0x1d6b Linux Foundation
  idProduct          0x0003 3.0 root hub
  bcdDevice            4.20
  iManufacturer           3 Linux 4.20.17-gentoo xhci-hcd
  iProduct                2 xHCI Host Controller
  iSerial                 1 0000:00:14.0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           31
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 Full speed (or root) hub
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval              12
        bMaxBurst               0
Hub Descriptor:
  bLength              12
  bDescriptorType      42
  nNbrPorts             6
  wHubCharacteristic 0x000a
    No power switching (usb 1.0)
    Per-port overcurrent protection
  bPwrOn2PwrGood       10 * 2 milli seconds
  bHubContrCurrent      0 milli Ampere
  bHubDecLat          0.0 micro seconds
  wHubDelay             0 nano seconds
  DeviceRemovable    0x00
 Hub Port Status:
   Port 1: 0000.02a0 lowspeed L1
   Port 2: 0000.0203 lowspeed enable connect
   Port 3: 0000.02a0 lowspeed L1
   Port 4: 0000.02a0 lowspeed L1
   Port 5: 0000.02a0 lowspeed L1
   Port 6: 0000.02a0 lowspeed L1
Binary Object Store Descriptor:
  bLength                 5
  bDescriptorType        15
  wTotalLength           91
  bNumDeviceCaps          2
  SuperSpeed USB Device Capability:
    bLength                10
    bDescriptorType        16
    bDevCapabilityType      3
    bmAttributes         0x02
      Latency Tolerance Messages (LTM) Supported
    wSpeedsSupported   0x0008
      Device can operate at SuperSpeed (5Gbps)
    bFunctionalitySupport   3
      Lowest fully-functional device speed is SuperSpeed (5Gbps)
    bU1DevExitLat          10 micro seconds
    bU2DevExitLat         918 micro seconds
  SuperSpeedPlus USB Device Capability:
    bLength                76
    bDescriptorType        16
    bDevCapabilityType     10
    bmAttributes         0x000000ef
      Sublink Speed Attribute count 15
      Sublink Speed ID count 7
    wFunctionalitySupport   0x0001
    bmSublinkSpeedAttr[0]   0x00050034
      Speed Attribute ID: 4 5Gb/s Symmetric RX SuperSpeed
    bmSublinkSpeedAttr[1]   0x000500b4
      Speed Attribute ID: 4 5Gb/s Symmetric TX SuperSpeed
    bmSublinkSpeedAttr[2]   0x000a4035
      Speed Attribute ID: 5 10Gb/s Symmetric RX SuperSpeedPlus
    bmSublinkSpeedAttr[3]   0x000a40b5
      Speed Attribute ID: 5 10Gb/s Symmetric TX SuperSpeedPlus
    bmSublinkSpeedAttr[4]   0x04e00026
      Speed Attribute ID: 6 1248Mb/s Symmetric RX SuperSpeed
    bmSublinkSpeedAttr[5]   0x04e000a6
      Speed Attribute ID: 6 1248Mb/s Symmetric TX SuperSpeed
    bmSublinkSpeedAttr[6]   0x09c00027
      Speed Attribute ID: 7 2496Mb/s Symmetric RX SuperSpeed
    bmSublinkSpeedAttr[7]   0x09c000a7
      Speed Attribute ID: 7 2496Mb/s Symmetric TX SuperSpeed
    bmSublinkSpeedAttr[8]   0x13800028
      Speed Attribute ID: 8 4992Mb/s Symmetric RX SuperSpeed
    bmSublinkSpeedAttr[9]   0x138000a8
      Speed Attribute ID: 8 4992Mb/s Symmetric TX SuperSpeed
    bmSublinkSpeedAttr[10]   0x05b10029
      Speed Attribute ID: 9 1457Mb/s Symmetric RX SuperSpeed
    bmSublinkSpeedAttr[11]   0x05b100a9
      Speed Attribute ID: 9 1457Mb/s Symmetric TX SuperSpeed
    bmSublinkSpeedAttr[12]   0x0b63002a
      Speed Attribute ID: 10 2915Mb/s Symmetric RX SuperSpeed
    bmSublinkSpeedAttr[13]   0x0b6300aa
      Speed Attribute ID: 10 2915Mb/s Symmetric TX SuperSpeed
    bmSublinkSpeedAttr[14]   0x16c6002b
      Speed Attribute ID: 11 5830Mb/s Symmetric RX SuperSpeed
    bmSublinkSpeedAttr[15]   0x16c600ab
      Speed Attribute ID: 11 5830Mb/s Symmetric TX SuperSpeed
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0001
  Self Powered

However, sysfs says that U1 and U2 for the hub is disabled:

# cat /sys/bus/usb/devices/usb2/power/usb3_hardware_lpm_u1
disabled
# cat /sys/bus/usb/devices/usb2/power/usb3_hardware_lpm_u1
disabled

For the device it is enabled:

# cat /sys/bus/usb/devices/usb2/2-2/power/usb3_hardware_lpm_u1
enabled
# cat /sys/bus/usb/devices/usb2/2-2/power/usb3_hardware_lpm_u2
enabled

Runtime PM is enabled everywhere:

# cat /sys/bus/usb/devices/usb2/power/control
auto
# cat /sys/bus/usb/devices/usb2/2-2/power/control
auto

I captured USB traffic from the moment of plugging the hard drive up to the moment when it is suspended and spun down. The host does configure PORT_U1_TIMEOUT and PORT_U2_TIMEOUT on the root hub and does send "U1 ENABLE" and "U2 ENABLE" to the device, but it sets the value to zero, effectively prohibiting LPM in any direction:

No.     Time           Source                Destination           Protocol Length Info
     92 28.402366      host                  2.1.0                 USBHUB   64     SET_FEATURE Request    [Port 12802: PORT_U1_TIMEOUT]

USB URB
    [Source: host]
    Source or Destination: host
    [Destination: 2.1.0]
    Source or Destination: 2.1.0
    URB id: 0xffff9b2bc463b240
    URB type: URB_SUBMIT ('S')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x00, Direction: OUT
        0... .... = Direction: OUT (0)
        .... 0000 = Endpoint number: 0
    Device: 1
    URB bus id: 2
    Device setup request: relevant (0)
    Data: present (0)
    URB sec: 1554154417
    URB usec: 588745
    URB status: Operation now in progress (-EINPROGRESS) (-115)
    URB length [bytes]: 0
    Data length [bytes]: 0
    [Response in: 93]
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000000
    Number of ISO descriptors: 0
    [bInterfaceClass: Unknown (0xffff)]
URB setup
    bmRequestType: 0x23
        0... .... = Direction: Host-to-device
        .01. .... = Type: Class (0x1)
        ...0 0011 = Recipient: Other (0x03)
bRequest: SET_FEATURE (0x03)
wValue: 0x0017
    PortFeatureSelector: PORT_U1_TIMEOUT (23)
wIndex: 12802
    Port: 2
    PortSelector: 50
wLength: 0
    (zero): 0



No.     Time           Source                Destination           Protocol Length Info
     94 28.402401      host                  2.2.0                 USB      64     SET FEATURE Request

USB URB
    [Source: host]
    Source or Destination: host
    [Destination: 2.2.0]
    Source or Destination: 2.2.0
    URB id: 0xffff9b2bc463b240
    URB type: URB_SUBMIT ('S')
    URB transfer type: URB_CONTROL (0x02)
    Endpoint: 0x00, Direction: OUT
        0... .... = Direction: OUT (0)
        .... 0000 = Endpoint number: 0
    Device: 2
    URB bus id: 2
    Device setup request: relevant (0)
    Data: present (0)
    URB sec: 1554154417
    URB usec: 588780
    URB status: Operation now in progress (-EINPROGRESS) (-115)
    URB length [bytes]: 0
    Data length [bytes]: 0
    [Response in: 95]
    Interval: 0
    Start frame: 0
    Copy of Transfer Flags: 0x00000000
    Number of ISO descriptors: 0
URB setup
    bmRequestType: 0x00
        0... .... = Direction: Host-to-device
        .00. .... = Type: Standard (0x0)
        ...0 0000 = Recipient: Device (0x00)
    bRequest: SET FEATURE (3)
    wFeatureSelector: U1 ENABLE (48)
    wIndex: 0 (0x0000)
    wLength: 0

Respectively, there are no LGO_U1 packets seen in the trace.

dmesg output: https://pastebin.com/8EUw9bCr

There are no warnings in dmesg either from "xhci" or "usbcore" about the disabled LPM.

# uname -a
Linux nuc8 4.20.17-gentoo #9 SMP Tue Apr 9 22:48:18 CEST 2019 x86_64 Intel(R) Core(TM) i3-8109U CPU @ 3.00GHz GenuineIntel GNU/Linux

The PM-related kernel configuration is enabled:

CONFIG_PM=y
CONFIG_PM_DEBUG=y
CONFIG_PM_ADVANCED_DEBUG=y

This is Intel hardware which is supposed to support all kinds of PM well and is supported well by xhci driver. I'd like to understand why the hub-initiated USB3 LPM is disabled and how I could enable it.

Thank you

linux
usb
power-management
asked on Super User Apr 9, 2019 by jhjs23223

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0