You are not logged in.

#1 2020-03-15 20:45:24

b1inki
Member
Registered: 2018-12-03
Posts: 12

[SOLVED] USB Keyboard powers off after suspend

I have Chinese USB keyboard from a semi-unknown brand (HAVIT HV-KB390L) that gets powered down after suspend.
If I then press any key on the keyboard the PC gets resumed but the keyboard stays powered down and
I have to unplug/plug it in for it to work again.
Any idea how I might even start diagnosing the issue ?

Edit:
The keyboard still shows on 'lsusb' after resume even though it is powered off.
dmesg shows no errors when plugging/unplugging the keyboard during normal operation, or during the suspend/resume phase.

Last edited by b1inki (2020-03-16 19:06:41)

Offline

#2 2020-03-16 19:06:27

b1inki
Member
Registered: 2018-12-03
Posts: 12

Re: [SOLVED] USB Keyboard powers off after suspend

So as per my edit in my original comment, I came to the conclusion that the problem is probably within the keyboard itself.
Using https://wiki.archlinux.org/index.php/Po … leep_hooks I created a custom post-sleep service that
unbinds/binds the USB driver to the keyboard port which, although a hack, does the trick.

I plan on testing the keyboard itself on other hardware and OS'es, but for now I'll mark this issue as solved.

Offline

#3 2021-02-10 11:31:38

bulletmark
Member
From: Brisbane, Australia
Registered: 2013-10-22
Posts: 582

Re: [SOLVED] USB Keyboard powers off after suspend

@b1inki, I have a Havit HV-KB395L keyboard which has exactly the same problem. I tried using a post-sleep service to run a script as you say (and a few other approaches) but can't resolve this issue. Would you mind please sharing your script which does the unbind/bind?

Offline

#4 2021-02-18 13:26:24

b1inki
Member
Registered: 2018-12-03
Posts: 12

Re: [SOLVED] USB Keyboard powers off after suspend

@bulletmark
Sure thing - I'm using a systemd service tied to the sleep.target:

/etc/systemd/system/keyboard-resume.service:

[Unit]
Description=Powercycle the keyboard on system resume
Before=sleep.target
StopWhenUnneeded=yes

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStop=-/bin/bash -c "/usr/bin/echo '1-1' > /sys/bus/usb/drivers/usb/unbind"
ExecStop=-/bin/bash -c "/usr/bin/echo '1-1' > /sys/bus/usb/drivers/usb/bind"

[Install]
WantedBy=sleep.target

The '1-1' is the address of the keyboard - you have to find your own (note: unplugging/replugging the keyboard will almost certainly change that address),
have a look at the 'lsusb' output and how linux handles usb bus addresses for more info about that.

Offline

#5 2021-02-18 22:05:40

bulletmark
Member
From: Brisbane, Australia
Registered: 2013-10-22
Posts: 582

Re: [SOLVED] USB Keyboard powers off after suspend

Yes, I tried that and a few other ideas but it doesn't work for me because my keyboard is attached via a dock, unlike yours which I presume is attached directly to your PC. So for the last week I have I used a resume service which unbinds/binds my dock device in /sys/bus/pci/drivers/xhci_hcd. That resets the entire dock USB controller which sounds crude but it has certainly solved the annoying problem for me and works well.

Offline

Board footer

Powered by FluxBB