External mouse and keyboard sleep when they stay untouched for a few seconds

Hello! I asked this question on matrix but the answers did not work, so I decided to start a conversation here.

I have an external mouse I used across many operating systems but I feel like I see this behavior only with NixOS. At the beginning I only had one laptop an Asus Zenbook with a USB-C dock station and so on. I thought something along the way was not right, but I get this behavior with a new System76 Thelio without any dock station.

In practice when I don’t move the mouse for a few seconds it “goes to sleep” (not sure if that’s what it does), but in practice I have to wait a few seconds when touching it again in order to get it awake and working. The same happens with the keyboard, the light goes off, after ~3seconds and the first time I press a key it does not work.

Nothing shows up in dmesg.

I am using i3 and I have libinput installed, my configuration is available on GitHub https://github.com/gianarb/dotfiles/tree/master/nixos/machines

Thanks a lot!

I just realized that the problem happens only when I boot the laptop with keyboard and mouse attached to it. If I connect them when the laptop has booted everything works

I just realized that the problem happens only when I boot the laptop with keyboard and mouse attached to it. If I connect them when the laptop has booted everything works

This problem persist even when I am using a workstation (thelio system76), if it boots with the keyboard attached vs if I remove and connect it again when the boot is over

Could it be something different about the kernel modules that get loaded? I would try to save the output of the lsmod command on each situation and then confront them with diff to see if there is any difference

Thaanks a lot @azazel75 ! I am a bit short on ideas about how to debug this issue. I tried what you suggested but as you can see the diff does not show anything that important, at least for what I can tell

$ diff -d <(sort ~/Documents/notes/test-lsmod/first-boot.txt) <(sort ~/Documents/notes/test-lsmod/when-everything-works-after-reconnect.txt)
16c16
< bluetooth             614400  47 btrtl,btintel,btbcm,bnep,btusb,rfcomm
---
> bluetooth             614400  45 btrtl,btintel,btbcm,bnep,btusb,rfcomm
48c48
< drm                   512000  7 drm_kms_helper,nvidia,nvidia_drm
---
> drm                   512000  10 drm_kms_helper,nvidia,nvidia_drm
124,126c124,126
< nvidia              35176448  178 nvidia_uvm,nvidia_modeset
< nvidia_drm             57344  3
< nvidia_modeset       1179648  5 nvidia_drm
---
> nvidia              35176448  420 nvidia_uvm,nvidia_modeset
> nvidia_drm             57344  6
> nvidia_modeset       1179648  9 nvidia_drm

You’re right @gianarb there’s no difference, but clearly the same devices get configured differently, so depending on your energy, I would look for the following things:

  • look into dmesg when the devices get first recognized;
  • see if lsusb tells something different;
  • is having the X or Wayland session a key fatctor? E.g. Without starting a graphical session but using something like gpm on console and connecting the devices after boot, do they still behave correctly?
  • With the help of lsusb look into /sys/bus/usb/devices/x and see if something seems different.
1 Like

I have a strong motivation to attempt a fix for this because it is a problem I have with both my machines :smiley: And I would really like to switch on the workstation and enjoy it without having to walk around to play with the usb ports! So let’s try!

dmesg for the mouse does not bring anythig to my attention

[    6.656069] usb 5-3: new full-speed usb device number 2 using xhci_hcd
[    6.799765] usb 5-3: new usb device found, idvendor=3938, idproduct=1031, bcddevice= 1.36
[    6.799767] usb 5-3: new usb device strings: mfr=1, product=2, serialnumber=0
[    6.799768] usb 5-3: product: 2.4g wireless mouse
[    6.799769] usb 5-3: manufacturer: mosart semi.
[    6.811771] input: mosart semi. 2.4g wireless mouse as /devices/pci0000:00/0000:00:08.1/0000:0c:00.3/usb5/5-3/5-3:1.0/0003:3938:1031.0004/input/input6
[    6.811784] input: MOSART Semi. 2.4G Wireless Mouse as /devices/pci0000:00/0000:00:08.1/0000:0c:00.3/usb5/5-3/5-3:1.0/0003:3938:1031.0004/input/input7
[    6.812245] hid-generic 0003:3938:1031.0004: input,hiddev98,hidraw3: USB HID v1.10 Mouse [MOSART Semi. 2.4G Wireless Mouse] on usb-0000:0c:00.3-3/input0

I think the keyboard is this one:

$ lsusb
...
Bus 001 Device 002: ID 04b4:6001 Cypress Semiconductor Corp.  

Maybe this is a bit weird but I can’t really tell: [ 1.378989] usb 3-4: config 1 has an invalid interface number: 2 but max is 1

[    1.293154] ata2: SATA link down (SStatus 0 SControl 300)
[    1.378989] usb 3-4: config 1 has an invalid interface number: 2 but max is 1
[    1.378990] usb 3-4: config 1 has no interface number 1
[    1.379037] usb 1-3: New USB device found, idVendor=04b4, idProduct=6001, bcdDevice= 1.03
[    1.379038] usb 1-3: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    1.390989] usb 3-4: New USB device found, idVendor=0b05, idProduct=18f3, bcdDevice= 1.00
[    1.390990] usb 3-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3


...
...
[    1.436690] input: HID 04b4:6001 as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1-3/1-3:1.0/0003:04B4:6001.0001/input/input0
[    1.489690] hid-generic 0003:04B4:6001.0001: input,hidraw0: USB HID v1.11 Keyboard [HID 04b4:6001] on usb-0000:07:00.1-3/input0
[    1.489938] input: HID 04b4:6001 Mouse as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1-3/1-3:1.1/0003:04B4:6001.0002/input/input1
[    1.489951] input: HID 04b4:6001 System Control as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1-3/1-3:1.1/0003:04B4:6001.0002/input/input2
[    1.542236] usb 1-4: new high-speed USB device number 3 using xhci_hcd
[    1.542290] input: HID 04b4:6001 Consumer Control as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1-3/1-3:1.1/0003:04B4:6001.0002/input/input3
[    1.542305] input: HID 04b4:6001 as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1-3/1-3:1.1/0003:04B4:6001.0002/input/input4
[    1.542318] input: HID 04b4:6001 Keyboard as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1-3/1-3:1.1/0003:04B4:6001.0002/input/input5
[    1.542409] hid-generic 0003:04B4:6001.0002: input,hiddev96,hidraw1: USB HID v1.11 Mouse [HID 04b4:6001] on usb-0000:07:00.1-3/input1
[    1.542500] hid-generic 0003:0B05:18F3.0003: hiddev97,hidraw2: USB HID v1.11 Device [AsusTek Computer Inc. AURA LED Controller] on usb-0000:07:00.3-4/input2
[    1.670782] usb 1-4: New USB device found, idVendor=0451, idProduct=8142, bcdDevice= 1.00
[    1.670784] usb 1-4: New USB device strings: Mfr=0, Product=0, SerialNumber=1
[    1.670785] usb 1-4: SerialNumber: 1D0018611882
lsusb -d 3938:1031 -v                                                                               huge: Wed Sep 15 10:10:54 2021│ + D/D/n/t/dmesg-first-boot.txt
                                                                                                                                              │    34 [    0.988986] usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1
can't get debug descriptor: Resource temporarily unavailable                                                                                  │    33 [    0.988987] usb usb4: Product: xHCI Host Controller
                                                                                                                                              │    32 [    0.988987] usb usb4: Manufacturer: Linux 5.10.62 xhci-hcd
Bus 005 Device 002: ID 3938:1031 MOSART Semi. 2.4G Wireless Mouse                                                                             │    31 [    0.988987] usb usb4: SerialNumber: 0000:07:00.3
Device Descriptor:                                                                                                                            │    30 [    0.989019] hub 4-0:1.0: USB hub found
  bLength                18                                                                                                                   │    29 [    0.989026] hub 4-0:1.0: 4 ports detected
  bDescriptorType         1                                                                                                                   │    28 [    0.989126] usb: port power management may be unreliable
  bcdUSB               1.10                                                                                                                   │    27 [    0.989193] xhci_hcd 0000:0c:00.3: xHCI Host Controller
  bDeviceClass            0                                                                                                                   │    26 [    0.989195] xhci_hcd 0000:0c:00.3: new USB bus registered, assigned bus number 5
  bDeviceSubClass         0                                                                                                                   │    25 [    0.989287] xhci_hcd 0000:0c:00.3: hcc params 0x0278ffe5 hci version 0x110 quirks 0x0000000000000410
  bDeviceProtocol         0                                                                                                                   │    24 [    0.989491] usb usb5: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.10
  bMaxPacketSize0         8                                                                                                                   │    23 [    0.989491] usb usb5: New USB device strings: Mfr=3, Product=2, SerialNumber=1
  idVendor           0x3938                                                                                                                   │    22 [    0.989491] usb usb5: Product: xHCI Host Controller
  idProduct          0x1031                                                                                                                   │    21 [    0.989492] usb usb5: Manufacturer: Linux 5.10.62 xhci-hcd
  bcdDevice            1.36                                                                                                                   │    20 [    0.989492] usb usb5: SerialNumber: 0000:0c:00.3
  iManufacturer           1 MOSART Semi.                                                                                                      │    19 [    0.989525] hub 5-0:1.0: USB hub found
  iProduct                2 2.4G Wireless Mouse                                                                                               │    18 [    0.989529] hub 5-0:1.0: 4 ports detected
  iSerial                 0                                                                                                                   │    17 [    0.989641] xhci_hcd 0000:0c:00.3: xHCI Host Controller
  bNumConfigurations      1                                                                                                                   │    16 [    0.989642] xhci_hcd 0000:0c:00.3: new USB bus registered, assigned bus number 6
  Configuration Descriptor:                                                                                                                   │    15 [    0.989642] xhci_hcd 0000:0c:00.3: Host supports USB 3.1 Enhanced SuperSpeed
    bLength                 9                                                                                                                 │    14 [    0.989648] usb usb6: We don't know the algorithms for LPM for this host, disabling LPM.
    bDescriptorType         2                                                                                                                 │    13 [    0.989655] usb usb6: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 5.10
    wTotalLength       0x0022                                                                                                                 │    12 [    0.989655] usb usb6: New USB device strings: Mfr=3, Product=2, SerialNumber=1
    bNumInterfaces          1                                                                                                                 │    11 [    0.989655] usb usb6: Product: xHCI Host Controller
    bConfigurationValue     1                                                                                                                 │    10 [    0.989656] usb usb6: Manufacturer: Linux 5.10.62 xhci-hcd
    iConfiguration          0                                                                                                                 │     9 [    0.989656] usb usb6: SerialNumber: 0000:0c:00.3
    bmAttributes         0xa0                                                                                                                 │     8 [    0.989688] hub 6-0:1.0: USB hub found
      (Bus Powered)                                                                                                                           │     7 [    0.989691] hub 6-0:1.0: 4 ports detected
      Remote Wakeup                                                                                                                           │     6 [    0.989889] nvme nvme0: Shutdown timeout set to 10 seconds
    MaxPower              100mA                                                                                                               │     5 [    0.996302] nvme nvme0: 32/0/0 default/read/poll queues
    Interface Descriptor:                                                                                                                     │     4 [    0.998574]  nvme0n1: p1 p2
      bLength                 9                                                                                                               │     3 [    1.227355] usb 1-3: new full-speed USB device number 2 using xhci_hcd
      bDescriptorType         4                                                                                                               │     2 [    1.235354] usb 3-4: new full-speed USB device number 2 using xhci_hcd
      bInterfaceNumber        0                                                                                                               │     1 [    1.292784] ata1: SATA link down (SStatus 0 SControl 300)
      bAlternateSetting       0                                                                                                               │  893  [    1.293154] ata2: SATA link down (SStatus 0 SControl 300)
      bNumEndpoints           1                                                                                                               │     1 [    1.378989] usb 3-4: config 1 has an invalid interface number: 2 but max is 1
      bInterfaceClass         3 Human Interface Device                                                                                        │     2 [    1.378990] usb 3-4: config 1 has no interface number 1
      bInterfaceSubClass      1 Boot Interface Subclass                                                                                       │     3 [    1.379037] usb 1-3: New USB device found, idVendor=04b4, idProduct=6001, bcdDevice= 1.03
      bInterfaceProtocol      2 Mouse                                                                                                         │     4 [    1.379038] usb 1-3: New USB device strings: Mfr=0, Product=0, SerialNumber=0
      iInterface              0                                                                                                               │     5 [    1.390989] usb 3-4: New USB device found, idVendor=0b05, idProduct=18f3, bcdDevice= 1.00
        HID Device Descriptor:                                                                                                                │     6 [    1.390990] usb 3-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
          bLength                 9                                                                                                           │     7 [    1.390990] usb 3-4: Product: AURA LED Controller
          bDescriptorType        33                                                                                                           │     8 [    1.390991] usb 3-4: Manufacturer: AsusTek Computer Inc.
          bcdHID               1.10                                                                                                           │     9 [    1.390991] usb 3-4: SerialNumber: 9876543210
          bCountryCode            0 Not supported                                                                                             │    10 [    1.400939] hid: raw HID events driver (C) Jiri Kosina
          bNumDescriptors         1                                                                                                           │    11 [    1.436015] usbcore: registered new interface driver usbhid
          bDescriptorType        34 Report                                                                                                    │    12 [    1.436016] usbhid: USB HID core driver
          wDescriptorLength     118                                                                                                           │    13 [    1.436690] input: HID 04b4:6001 as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1-3/1-3:1.0/0003:>
         Report Descriptors:                                                                                                                  │    14 [    1.489690] hid-generic 0003:04B4:6001.0001: input,hidraw0: USB HID v1.11 Keyboard [HID 04b4:6001] on usb-0000:07:00.1-3/input0
           ** UNAVAILABLE **                                                                                                                  │    15 [    1.489938] input: HID 04b4:6001 Mouse as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1-3/1-3:1.1>
      Endpoint Descriptor:                                                                                                                    │    16 [    1.489951] input: HID 04b4:6001 System Control as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1->
        bLength                 7                                                                                                             │    17 [    1.542236] usb 1-4: new high-speed USB device number 3 using xhci_hcd
        bDescriptorType         5                                                                                                             │    18 [    1.542290] input: HID 04b4:6001 Consumer Control as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/>
        bEndpointAddress     0x81  EP 1 IN                                                                                                    │    19 [    1.542305] input: HID 04b4:6001 as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1-3/1-3:1.1/0003:>
        bmAttributes            3                                                                                                             │    20 [    1.542318] input: HID 04b4:6001 Keyboard as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1-3/1-3:>
          Transfer Type            Interrupt                                                                                                  │    21 [    1.542409] hid-generic 0003:04B4:6001.0002: input,hiddev96,hidraw1: USB HID v1.11 Mouse [HID 04b4:6001] on usb-0000:07:00.1-3/inp>
          Synch Type               None                                                                                                       │    22 [    1.542500] hid-generic 0003:0B05:18F3.0003: hiddev97,hidraw2: USB HID v1.11 Device [AsusTek Computer Inc. AURA LED Controller] on>
          Usage Type               Data                                                                                                       │    23 [    1.670782] usb 1-4: New USB device found, idVendor=0451, idProduct=8142, bcdDevice= 1.00
        wMaxPacketSize     0x0007  1x 7 bytes                                                                                                 │    24 [    1.670784] usb 1-4: New USB device strings: Mfr=0, Product=0, SerialNumber=1
        bInterval               4                                                                                                             │    25 [    1.670785] usb 1-4: SerialNumber: 1D0018611882
Device Status:     0x0000                                                                                                                     │    26 [    1.678059] tsc: Refined TSC clocksource calibration: 3393.626 MHz
  (Bus Powered) 

Same for the keyboard:

gianarb@huge ~  $ lsusb -d 04b4:6001 -v

Bus 001 Device 002: ID 04b4:6001 Cypress Semiconductor Corp.
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x04b4 Cypress Semiconductor Corp.
  idProduct          0x6001
  bcdDevice            1.03
  iManufacturer           0
  iProduct                0
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0042
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          2 Game_Keyboard
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      1 Keyboard
      iInterface              2 Game_Keyboard
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode           33 US
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      63
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              4 Function_Device
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode           33 US
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     176
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)

I will proceed with the other tests (gpm) in a bit

This is what happens when I disconnect and reconnect the mouse:

[   74.243725] usb 5-3: USB disconnect, device number 2




[   84.162232] usb 5-3: new full-speed USB device number 3 using xhci_hcd
[   84.306736] usb 5-3: New USB device found, idVendor=3938, idProduct=1031, bcdDevice= 1.36
[   84.306739] usb 5-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[   84.306740] usb 5-3: Product: 2.4G Wireless Mouse
[   84.306741] usb 5-3: Manufacturer: MOSART Semi.
[   84.320883] input: MOSART Semi. 2.4G Wireless Mouse as /devices/pci0000:00/0000:00:08.1/0000:0c:00.3/usb5/5-3/5-3:1.0/0003:3938:1031.0005/input/input26
[   84.320989] input: MOSART Semi. 2.4G Wireless Mouse as /devices/pci0000:00/0000:00:08.1/0000:0c:00.3/usb5/5-3/5-3:1.0/0003:3938:1031.0005/input/input27
[   84.321066] hid-generic 0003:3938:1031.0005: input,hiddev96,hidraw0: USB HID v1.10 Mouse [MOSART Semi. 2.4G Wireless Mouse] on usb-0000:0c:00.3-3/input0

And the keyboard:

[  125.285227] usb 1-3: USB disconnect, device number 2
[  129.542917] usb 1-3: new full-speed USB device number 10 using xhci_hcd
[  129.685986] usb 1-3: New USB device found, idVendor=04b4, idProduct=6001, bcdDevice= 1.03
[  129.685989] usb 1-3: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[  129.709122] input: HID 04b4:6001 as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1-3/1-3:1.0/0003:04B4:6001.0006/input/input28
[  129.760820] hid-generic 0003:04B4:6001.0006: input,hidraw2: USB HID v1.11 Keyboard [HID 04b4:6001] on usb-0000:07:00.1-3/input0
[  129.775496] input: HID 04b4:6001 Mouse as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1-3/1-3:1.1/0003:04B4:6001.0007/input/input29
[  129.775847] input: HID 04b4:6001 System Control as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1-3/1-3:1.1/0003:04B4:6001.0007/input/input30
[  129.827832] input: HID 04b4:6001 Consumer Control as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1-3/1-3:1.1/0003:04B4:6001.0007/input/input31
[  129.827998] input: HID 04b4:6001 as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1-3/1-3:1.1/0003:04B4:6001.0007/input/input32
[  129.828073] input: HID 04b4:6001 Keyboard as /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:07:00.1/usb1/1-3/1-3:1.1/0003:04B4:6001.0007/input/input33
[  129.828158] hid-generic 0003:04B4:6001.0007: input,hiddev98,hidraw3: USB HID v1.11 Mouse [HID 04b4:6001] on usb-0000:07:00.1-3/input1

Just a shot in the dark, but in the past, when I had similar issues, it turned out that the Linux kernel’s USB autosuspend feature was involved and the devices apparently could not properly handle the autosuspend.

You can search directories under /sys/bus/usb/devices for your affected USB devices. Subsequently, you could check the contents of a file named power/control stored in the respective directory. The file may contain the string auto, which instructs the kernel to use USB autosuspend when the devices are not in use. You can then manually disable auto-suspend by writing on to these files instead, as in: echo on | sudo tee /sys/bus/usb/devices/…/power/control.

When your problem no longer occurs after disabling USB autosuspend, you could configure things so that in the future, USB autosuspend will be automatically disabled for these devices. E.g., see Power management - ArchWiki or compare the NixOS documentation on setting up udev rules.

Hello!

The suggestion @eigengrau gave me was right I think! I spend a couple of hours fighting against udev. I didn’t figure out how to write the rule I was hoping to write (the one who re-writes power/control for a specific device because as soon as I add filters per idProduct and idVendor it stops working). But I managed to deplay autosuspend to 120 minutes.

I hope it will be enough for now.
Thanks a lot to both of you for your help here!

I had the same problem you described. The problem source was the autosuspend feature from the usbcore module.

However, as the documentation says if the module is compiled in the kernel disabling suspend needs to be passed in the kernel boot parameter usbcore.autosuspend=-1.

It sounds that in your case you had the behavior only when the device was attached at boot which suggests that these parameters were inititated at boot. Looks like these parameters may be updated after boot somehow resulting in this inconsistent behavior.

Currently such device is not in a state where I can test this but i will try as soon as possible! Thanks

I had the same issue and the thread above helped me to resolve it, so I wanted just to add some additional input.

The USB devices that are connected during boot get their /sys/bus/usb/devices/<usb-id>/power/control set to ‘auto’ which apparently leads the USB device to get suspended excessively quickly in the case of a USB keyboard or a USB mouse by default.

In case you have a laptop and an external keyboard connected, you can for example use the laptop integrated keyboard to check the power/runtime_status of the affected external keyboard. It is likely in suspended mode in case you haven’t used it for 2 seconds, and then if you press a key on the internal keyboard and check the same file it should now be in active state. After 2 seconds it goes to suspended again. As previously mentioned, setting power/control to on prevent the device to go to suspended mode. In case you want to have the suspended mode for the USB device, you can adjust the power/autosuspend_delay_ms value to a the duration you want.

In my case as well, if the USB devices are connected before boot, the control file is set to auto, but if connected or re-connected after boot then it gets set to on.

I haven’t tested @pati-ni suggestion as I’d rather have the autosuspend working for my devices and extend the timer instead of having autosuspend turned off.

Also, as a I side note, I’m using powertop for power management, which I’m not sure if it is related or not.

Useful Linux Kernel documentations about USB Power Management may be found here. The warning chapter is an interesting read about some context on this.