Keyboard and mouse not working after suspend

It needs to be run as root, not a user.

If you get it working please post the contents on my systemd thread. :+1:

Hope it works.

What, ah boooo. Now you took all my fun away, I think you do like the sound of your own keyboard. :heart_eyes:

1 Like

If you're stuck here's an alternate version you may try.

Summary
[Unit]
Description=usb-reset service
After=gdm.service
Wants=gdm.service

[Service]
Type=oneshot
ExecStart=/path/to/usb_reset.sh

I have it working but it only seems to find and reset the keyboard, maybe the script needs something? Still investigating..... I want to see if there is a better log than journalctl for these units too.

ah, maybe the GDM call will work better not sure it matter though.

So, you cheated and peeked. :smile:

Your not using a PS/2 old school mouse?

Or a Bluetooth mouse.

No its exactly like the OP.
I am still checking to make sure it is working, how do I get output from the script to stout?

So far I know it is working from systemd end.

[lee@Z77M ~]$ systemctl status reset-usb.service
● reset-usb.service - Reset USB on Resume
   Loaded: loaded (/etc/systemd/system/reset-usb.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Oct 15 08:49:37 Z77M systemd[1]: Starting Reset USB on Resume...
Oct 15 08:49:37 Z77M systemd[1]: Started Reset USB on Resume.
Oct 15 09:03:29 Z77M systemd[1]: Starting Reset USB on Resume...
Oct 15 09:03:29 Z77M systemd[1]: Started Reset USB on Resume.
[lee@Z77M ~]$ ls -l /usr/sbin/resetUSB
-rwxr-xr-x 1 root root 193 15.10.2018 07:38 /usr/sbin/resetUSB*

Little more trouble shooting It is working but still no logitech mouse detected since boot, hmmm. This is the tail end of dmesg after the script runs and then a grep for the specific hardware and it does not show up as far as I can tell (only on boot).

[ 1285.607199] xhci_hcd 0000:00:14.0: remove, state 4
[ 1285.607210] usb usb4: USB disconnect, device number 1
[ 1285.607563] xhci_hcd 0000:00:14.0: USB bus 4 deregistered
[ 1285.607571] xhci_hcd 0000:00:14.0: remove, state 1
[ 1285.607577] usb usb3: USB disconnect, device number 1
[ 1285.607579] usb 3-1: USB disconnect, device number 2
[ 1285.607581] usb 3-1.2: USB disconnect, device number 3
[ 1285.607583] usb 3-1.2.2: USB disconnect, device number 4
[ 1285.781375] xhci_hcd 0000:00:14.0: Slot 3 endpoint 2 not removed from BW list!
[ 1285.781379] xhci_hcd 0000:00:14.0: Slot 3 endpoint 4 not removed from BW list!
[ 1285.781756] xhci_hcd 0000:00:14.0: Slot 2 endpoint 2 not removed from BW list!
[ 1285.782164] xhci_hcd 0000:00:14.0: Slot 1 endpoint 2 not removed from BW list!
[ 1285.783712] xhci_hcd 0000:00:14.0: USB bus 3 deregistered
[ 1285.784409] xhci_hcd 0000:00:14.0: xHCI Host Controller
[ 1285.784421] xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 3
[ 1285.881394] xhci_hcd 0000:00:14.0: hcc params 0x20007181 hci version 0x100 quirks 0x000000000000b930
[ 1285.881400] xhci_hcd 0000:00:14.0: cache line size of 64 is not supported
[ 1285.881539] usb usb3: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 4.18
[ 1285.881540] usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1285.881541] usb usb3: Product: xHCI Host Controller
[ 1285.881542] usb usb3: Manufacturer: Linux 4.18.12-1-MANJARO xhci-hcd
[ 1285.881543] usb usb3: SerialNumber: 0000:00:14.0
[ 1285.881681] hub 3-0:1.0: USB hub found
[ 1285.881689] hub 3-0:1.0: 4 ports detected
[ 1285.882027] xhci_hcd 0000:00:14.0: xHCI Host Controller
[ 1285.882030] xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 4
[ 1285.882033] xhci_hcd 0000:00:14.0: Host supports USB 3.0  SuperSpeed
[ 1285.882060] usb usb4: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 4.18
[ 1285.882061] usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1285.882062] usb usb4: Product: xHCI Host Controller
[ 1285.882063] usb usb4: Manufacturer: Linux 4.18.12-1-MANJARO xhci-hcd
[ 1285.882064] usb usb4: SerialNumber: 0000:00:14.0
[ 1285.882185] hub 4-0:1.0: USB hub found
[ 1285.882193] hub 4-0:1.0: 4 ports detected
[ 1286.210767] usb 3-1: new high-speed USB device number 2 using xhci_hcd
[ 1286.351035] usb 3-1: New USB device found, idVendor=03f0, idProduct=2512, bcdDevice= a.a0
[ 1286.351039] usb 3-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 1286.351669] hub 3-1:1.0: USB hub found
[ 1286.351725] hub 3-1:1.0: 2 ports detected
[ 1286.634107] usb 3-1.2: new high-speed USB device number 3 using xhci_hcd
[ 1286.732685] usb 3-1.2: New USB device found, idVendor=05ac, idProduct=1006, bcdDevice=94.15
[ 1286.732689] usb 3-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1286.732691] usb 3-1.2: Product: Keyboard Hub
[ 1286.732693] usb 3-1.2: Manufacturer: Apple, Inc.
[ 1286.732695] usb 3-1.2: SerialNumber: 000000000000
[ 1286.733286] hub 3-1.2:1.0: USB hub found
[ 1286.733314] hub 3-1.2:1.0: 3 ports detected
[ 1287.010811] usb 3-1.2.2: new low-speed USB device number 4 using xhci_hcd
[ 1287.107450] usb 3-1.2.2: New USB device found, idVendor=05ac, idProduct=0220, bcdDevice= 0.69
[ 1287.107454] usb 3-1.2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1287.107456] usb 3-1.2.2: Product: Apple Keyboard
[ 1287.107459] usb 3-1.2.2: Manufacturer: Apple, Inc
[ 1287.116084] input: Apple, Inc Apple Keyboard as /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1.2/3-1.2.2/3-1.2.2:1.0/0003:05AC:0220.000B/input/input25
[ 1287.171232] apple 0003:05AC:0220.000B: input,hidraw2: USB HID v1.11 Keyboard [Apple, Inc Apple Keyboard] on usb-0000:00:14.0-1.2.2/input0
[ 1287.173694] input: Apple, Inc Apple Keyboard as /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1.2/3-1.2.2/3-1.2.2:1.1/0003:05AC:0220.000C/input/input26
[ 1287.227699] apple 0003:05AC:0220.000C: input,hidraw3: USB HID v1.11 Device [Apple, Inc Apple Keyboard] on usb-0000:00:14.0-1.2.2/input1
[lee@Z77M ~]$ dmesg | grep logitek
[lee@Z77M ~]$ dmesg | grep logitec
[    1.422089] logitech-djreceiver 0003:046D:C52B.0003: hiddev0,hidraw0: USB HID v1.11 Device [Logitech USB Receiver] on usb-0000:00:1a.0-1.1/input2
[    1.550841] logitech-hidpp-device 0003:046D:1025.0004: input,hidraw1: USB HID v1.11 Mouse [Logitech M510] on usb-0000:00:1a.0-1.1:1
[   11.684658] logitech-hidpp-device 0003:046D:1025.0004: HID++ 1.0 device connected.
[lee@Z77M ~]$ dmesg | grep 046d
[    1.413597] usb 1-1.1: New USB device found, idVendor=046d, idProduct=c52b, bcdDevice=12.07
[lee@Z77M ~]$

Not sure really. You could use:

StandardOutput=journal

I hate to say it but I am stumped. :confounded::disappointed:
Must be something simple I am missing.

Nothing seems to work to get the mouse back after a suspend from the login window.

The systemd unit is working and so is the script as far as I can tell from logs but the Mouse or even the manufacture is not recognized like it is on the first boot and therefore never works again until reboot. (still checking some things)

What I tried and methods. -- This may get long so I will try and condense it.

This was tried with kernels 4.18, 4.17, 4.9. and the suspend method was from the GDM login screen at first and then from the GUI and then logout and let the computer auto suspend after 15 minutes.

  1. If I logout and then use the upper right power button to suspend (looks like a pause symbol) I can hear the pc goto sleep.
    Then, keyboard wakes it to the login screen but the mouse does not work.

  2. If I logout and then leave the pc auto sleep via the desktop power settings of 15 minutes, it goes into suspend.
    Then, keyboard wakes it to the login screen but the mouse does not work.

  3. If I suspend the pc from the GUI directly via the launcher (no logout, just suspend).
    Then Everything works when it wakes up.

Things I have done extra:

Remove TLP, no difference except I think it may be responsible for the cool suspend button in the GDM instead of just shutdown.

Add the Logitech drivers logitech-hidpp-device to the kernel load modules via mkinitcpio and rebuild the kernels.

So far it is looking like a GDM issue, I guess possible kernel but unlikely.

what have you got the mouse plugged into usb3 or usb2

Hmm, not sure. I guess I should open up the case and see where I routed the front case connector.

Wait is it in the dmesg, I think so. Is it usb1???
usb-0000:00:1a.0-1.1/input2

That is fine just tried suspend on arch everything works fine here but i had to use a cheat code to even use usb thanks to Ms the motherboard was blocking usb2 or 3 but not at the same time,

Turns out there is no emoji for WTF so anyhow, this is a normal motherboard.

Mb gigabyte 970 not linux friendly in normal mode so a nice dev worked out a grub cheat code for the users amd_iommu=on iommu=pt now it works just like using MS.

1 Like

I think I stumbled onto something, in may be a kernel bug I guess after all.

It happened because manjaro adopted recent Arch Linux changes to make usb drivers build-in in kernel which breaks mkinitcpio autodetection.

Perhaps an rmmod and modprobe of the USB modules are required.

You could add this to your USB reset script.

#!/bin/bash
#Reload USB drivers
rmmod xhci_pci
rmmod ehci_pci
modprobe xhci_pci
modprobe ehci_pci

You can also try adding this to your script. I think I have the right device ID for your mouse in this script. Logitech, Inc. Unifying Receiver 046d:c52b (I have the same). This should hopefully refresh your mouse specifically by it's ID nunmber.

#!/bin/bash
#reset device by ID
set -euo pipefail
IFS=$'\n\t'

VENDOR="046d"
PRODUCT="c52b"

for DIR in $(find /sys/bus/usb/devices/ -maxdepth 1 -type l); do
  if [[ -f $DIR/idVendor && -f $DIR/idProduct &&
        $(cat $DIR/idVendor) == $VENDOR && $(cat $DIR/idProduct) == $PRODUCT ]]; then
    echo 0 > $DIR/authorized
    sleep 0.5
    echo 1 > $DIR/authorized
  fi
done

I hope some of that helps @anika200

Wow thanks for the cool script (M510 specific) it works good and so does the systemd unit when run from the command line. See log below.
Unfortunately there is still no change when suspend from GDM is activated. :unamused:

Its a real β– β– β– β– β– β–  to trouble shoot because once you are in suspend the only way out is to power down and then there is nothing in the logs to see if systemd even ran the unit. I am assuming it is running the unit when the keyboard wakes up from sleep but who knows.

I am giving up for now and will just have to turn off suspend, wasting energy.

Thanks for all your help. :+1:

 Oct 16 15:43:57 Z77M systemd[1]: Started Reset USB on Resume.
Oct 16 15:43:57 Z77M audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=reset-usb comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Oct 16 15:43:57 Z77M audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=reset-usb comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Oct 16 15:43:57 Z77M kernel: audit: type=1130 audit(1539719037.975:58): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=reset-usb comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? >
Oct 16 15:43:57 Z77M kernel: audit: type=1131 audit(1539719037.975:59): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=reset-usb comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? >
Oct 16 15:43:57 Z77M polkitd[537]: Unregistered Authentication Agent for unix-process:4376:67378 (system bus name :1.318, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (discon>
Oct 16 15:43:59 Z77M kernel: input: Logitech M510 as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.2/0003:046D:C52B.0009/0003:046D:1025.000A/input/input21
Oct 16 15:43:59 Z77M kernel: logitech-hidpp-device 0003:046D:1025.000A: input,hidraw1: USB HID v1.11 Mouse [Logitech M510] on usb-0000:00:1a.0-1.2:1
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[572]: (II) config/udev: Adding input device Logitech M510 (/dev/input/mouse0)
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (II) config/udev: Adding input device Logitech M510 (/dev/input/mouse0)
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (II) No input driver specified, ignoring this device.
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (II) This device may have been added with another device file.
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[572]: (II) No input driver specified, ignoring this device.
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[572]: (II) This device may have been added with another device file.
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[572]: (II) config/udev: Adding input device Logitech M510 (/dev/input/event2)
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[572]: (**) Logitech M510: Applying InputClass "evdev pointer catchall"
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[572]: (**) Logitech M510: Applying InputClass "libinput pointer catchall"
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[572]: (II) Using input driver 'libinput' for 'Logitech M510'
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (II) config/udev: Adding input device Logitech M510 (/dev/input/event2)
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (**) Logitech M510: Applying InputClass "evdev pointer catchall"
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (**) Logitech M510: Applying InputClass "libinput pointer catchall"
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (II) Using input driver 'libinput' for 'Logitech M510'
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[572]: (II) systemd-logind: got fd for /dev/input/event2 13:66 fd 24 paused 1
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[572]: (II) systemd-logind: releasing fd for 13:66
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (II) systemd-logind: got fd for /dev/input/event2 13:66 fd 61 paused 0
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (**) Logitech M510: always reports core events
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (**) Option "Device" "/dev/input/event2"
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (**) Option "_source" "server/udev"
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (II) event2  - Logitech M510: is tagged by udev as: Mouse
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (II) event2  - Logitech M510: device set to 1000 DPI
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (II) event2  - Logitech M510: device is a pointer
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (II) event2  - Logitech M510: device removed
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (**) Option "config_info" "udev:/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.2/0003:046D:C52B.0009/0003:046D:1025.000A/input/input21/event2"
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (II) XINPUT: Adding extended input device "Logitech M510" (type: MOUSE, id 10)
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (**) Option "AccelerationScheme" "none"
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (**) Logitech M510: (accel) selected scheme none/0
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (**) Logitech M510: (accel) acceleration factor: 2.000
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (**) Logitech M510: (accel) acceleration threshold: 4
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (II) event2  - Logitech M510: is tagged by udev as: Mouse
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (II) event2  - Logitech M510: device set to 1000 DPI
Oct 16 15:43:59 Z77M /usr/lib/gdm-x-session[792]: (II) event2  - Logitech M510: device is a pointer

There is one other option you never tested, that is to use 2 systemd units. Perhaps shutting down the associated modules before suspend would help.

1 Like

I actually just added this script as a bash alias. Sometimes my mouse responsiveness seems to get sluggish and calling the script to reload the logitech module seems to help. So this is an unexpected benefit of this script .

Haven't read through everything but I had a similar issue. The reason was a BIOS version on my B350 MSI Krait Gaming MB. I believe the "bad" version was 1.0.0.4 c? had the issue and I downgraded to 1.0.0.4 b...then it worked again.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by