Ubuntu Computer not seeing keyboard once it goes to sleep

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

CJRoss

Member
May 31, 2017
91
6
8
This is a really weird situation that I can't seem to find happening to anyone else. I'll see if I can explain it.

I built a Ryzen 3600 machine back when they first came out and everything worked great except for my USB DAC. For some reason upon resuming from sleep the machine just wouldn't see it. If I moved the plug to another port it would recognize the DAC. This never happened on my old Intel system. Assuming it was USB issue I switched to using the optical out on my motherboard. But then the weirdest thing happened. It would lose the built in sound card. I eventually found out that I could just run the following to reload the service.

pulseaudio -k && sudo alsa force-reload

Fortunately the problem happens less frequently than it used to. Not sure if it's due to driver updates or the move to optical instead of USB.

Recently I had to replace my old keyboard with a Das Keyboard Prime 13. Everything was going great except that the machine will stop recognizing the keyboard when it's asleep. Lately it's been much more frequent. The only way to get the machine to pick up the keyboard is to restart it. If I plug a different USB keyboard in that works but the Das Keyboard doesn't even if I unplug it and plug it back in. I've updated the BIOS to the latest version and looked through it for any related settings but I haven't found anything.

Any thoughts or ideas as to what would be causing this and how to fix it?

Thanks.
 

EffrafaxOfWug

Radioactive Member
Feb 12, 2015
1,394
511
113
Any thoughts or ideas as to what would be causing this and how to fix it?
On the face of it it sounds like some over-zealous power-saving setting but not working even after unplugging it and re-inserting seems really odd... does anything show up in dmesg at all relating to USB when you resume from sleep? Do lsusb and friends show the keyboard (or any other device on the same USB address) at all on resume from sleep? Have you tried re-inserting it in to a different port (especially one that comes from a different USB controller)?

Searching about finds a few people who've had similar issues but not really done any digging in to it; I found a couple that said "reinstalling the input drivers" helped - I can't see why it would unless there was a bug in the installer somewhere (broken udev rule maybe) so I'm not convinced it'll work, but it should be harmless enough to try it:
Code:
aptitude reinstall xserver-xorg-input-all
(Assuming ubuntu uses the same package name as my debian systems)

On a more detailed level, I've seen a couple of keyboards in days of yore not play nice with sleep and there was a usbhid module parameter called "quirks" (or alternatively use the usbhid.quirks kernel parameter) you could use to fix them - usually used when a particular controller doesn't behave properly (lots of USB peripherals will often rely on a driver "switching" them to a certain USB mode in order to work - I used to have the opposite problem in the past where, on resume from sleep my USB DVB-T adapter would be detected as a keyboard). It's a bitmask so messing with it is some fairly complicated trial and error but documentation for it can be found in the hid.h source file.
 

CJRoss

Member
May 31, 2017
91
6
8
On the face of it it sounds like some over-zealous power-saving setting but not working even after unplugging it and re-inserting seems really odd... does anything show up in dmesg at all relating to USB when you resume from sleep? Do lsusb and friends show the keyboard (or any other device on the same USB address) at all on resume from sleep? Have you tried re-inserting it in to a different port (especially one that comes from a different USB controller)?
I've tried changing all of the power setting options in the BIOS I can find and none seem to make a difference. I forgot to run lsusb but dmesg doesn't show anything when I change the keyboard plug but does show when I insert a different keyboard.

Searching about finds a few people who've had similar issues but not really done any digging in to it; I found a couple that said "reinstalling the input drivers" helped - I can't see why it would unless there was a bug in the installer somewhere (broken udev rule maybe) so I'm not convinced it'll work, but it should be harmless enough to try it:
Code:
aptitude reinstall xserver-xorg-input-all
(Assuming ubuntu uses the same package name as my debian systems)
What's weird is that I never had this issue with my previous keyboard. The only thing that changed is replacing the Prime 13. Although I also moved my mouse to the port on the keyboard, but that's a separate cable, not a hub. May have to try changing it back anyways.

On a more detailed level, I've seen a couple of keyboards in days of yore not play nice with sleep and there was a usbhid module parameter called "quirks" (or alternatively use the usbhid.quirks kernel parameter) you could use to fix them - usually used when a particular controller doesn't behave properly (lots of USB peripherals will often rely on a driver "switching" them to a certain USB mode in order to work - I used to have the opposite problem in the past where, on resume from sleep my USB DVB-T adapter would be detected as a keyboard). It's a bitmask so messing with it is some fairly complicated trial and error but documentation for it can be found in the hid.h source file.
Would that affect the keyboard while the machine is asleep? It's not just that it doesn't get recognized once it resumes, but it's completely dead while the machine is asleep.

The weirdest part is that it's not consistent. Sometimes it'll work great and then others it won't work at all. I've not been able to find a rhyme or reason as to the difference.
 

CJRoss

Member
May 31, 2017
91
6
8
Okay, I ran lsusb and this is the result.

Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 003: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 005 Device 002: ID 24f0:0105 Metadot Das Keyboard 4
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 002: ID 0b05:18f3 ASUSTek Computer, Inc. AURA LED Controller
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 046d:c31c Logitech, Inc. Keyboard K120
Bus 001 Device 003: ID b58e:9e84 Blue Microphones Yeti Stereo Microphone
Bus 001 Device 002: ID 0764:0501 Cyber Power System, Inc. CP1500 AVR UPS
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I then tried swapping the keyboard with a complete different set of ports than I normally do and it started working. However, now my mic and UPS no longer show up. So something is happening with the USB controllers. Here is the new lsusb.

Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 003: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 005 Device 002: ID 24f0:0105 Metadot Das Keyboard 4
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 002: ID 0b05:18f3 ASUSTek Computer, Inc. AURA LED Controller
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 046d:c31c Logitech, Inc. Keyboard K120
Bus 001 Device 005: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 006: ID 24f0:0105 Metadot Das Keyboard 4
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 
Last edited:

CJRoss

Member
May 31, 2017
91
6
8
Another interesting thing I noticed about this machine. I only have the keyboard and mouse plugged in but the BIOS says there are 3 keyboards and 2 mice connected when I boot it up. Any ideas why?