After Suspend/Resume cycle Keyboard/Mouse are not working

Hi,

I have a real problem with suspend/resume not returning my pc into a workable state: My keyboard and mouse are not working anymore :angry: . Which is pretty 'sh i tty' as the only option is to use a forced power off.

Of course I tried some stuff myself, but after a week of troubleshooting I'm out of idea's.

I did manage a cumbersome workaround, it enables usb wakeup for mouse/keyboard, but that only lasts for 2+ of hours. After that, its a hard lockout.

I can remove keyboard and mouse, plug them into another USB-port and with some luck use them again. Plug them back in the original port and they are disabled again.

How can we get these basics working ?

Hi :slight_smile:
Can you share with us some dmesg after such input outage ?

Sure have a log ready, but how do I attach it ?

[   73.617947] PM: dpm_run_callback(): usb_dev_resume+0x0/0x20 returns -22
[   73.617966] PM: Device 3-2 failed to resume async: error -22
[   73.873891] PM: dpm_run_callback(): usb_dev_resume+0x0/0x20 returns -22
[   73.873919] PM: Device 3-1 failed to resume async: error -22
[   73.874509] fbcon: Taking over console
[   73.874584] OOM killer enabled.
[   73.874586] Restarting tasks ... 
[   73.874667] usb 3-1: USB disconnect, device number 2
[   73.874673] usb 3-1.1: USB disconnect, device number 3
[   73.878812] Console: switching to colour frame buffer device 240x67
[   73.893780] done.
[   73.893875] PM: suspend exit
[   73.933954] radeon_dp_aux_transfer_native: 242 callbacks suppressed
[   74.107423] usb 3-2: USB disconnect, device number 4
[   74.114221] Generic FE-GE Realtek PHY r8169-100:00: attached PHY driver [Generic FE-GE Realtek PHY] (mii_bus:phy_addr=r8169-100:00, irq=IGNORE)
[   74.225788] r8169 0000:01:00.0 enp1s0: Link is Down

You can clearly see those USB disconnects :thinking:

Guy, please try this fix :

Hi olek,

atkbd.reset did not work.
usbcore.autosuspend=-1, did not work either.

PM fails to resume and then disconnects those ports.

Its getting late, I found this one. Will try tomorrow:

Here's an idea: How about a simple app that allows you to install fixes from the forum ? :thinking:

Anyway, after some hours of $!%!£$"$£"%!%% :angry: I scripted a workaround: (because I'm awesome, but don't tell anyone)

It searches all usb device's for a keyboard or mouse string, then enables them for wakeup.

Create both files below, then:
systemctl enable suspendfix.service
systemctl start suspendfix.service

/etc/systemd/system/suspendfix.service

[Unit]
Description=enables mouse & keyboard after suspend/resume cycle

[Service]
Type=oneshot
ExecStart=/etc/init.d/suspendfix.sh start
ExecStop=/etc/init.d/suspendfix.sh stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

/etc/init.d/suspendfix.sh

#!/bin/bash
# workaround: enables mouse & keyboard after suspend/resume cycle

wakeup_mouse_keyb(){
  OLDIFS=$IFS;IFS=$'\n'
  PRODUCTLIST=$(grep -i 'mouse\|keyboard' /sys/bus/usb/devices/*/product)
  for p in $PRODUCTLIST;do
    devicename=${p#/*product:}
    product="${p%/product*}/product"
    wakeup="${p%/product*}/power/wakeup"
    echo "$1" 2>/dev/null > $wakeup
    printf "$devicename : $(cat $wakeup)\n"
  done
  IFS=$OLDIFS
}

case "$1" in
  start)
    wakeup_mouse_keyb enabled
    ;;
  stop)
    wakeup_mouse_keyb disabled
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
esac
1 Like

Congrats :slight_smile: Nice workaround :slight_smile:

Thanks to you others with similar HW / issue will be able to get back their devices after sleep.

Thanks @Guy :slight_smile:

You can also try to upgrade your kernel to latest - this solved many issues i got with my setups :slight_smile:

Someone else talked about this on itfoss.com forum. their solution was as follows;

sudo apt-get install --reinstall xserver-xorg-input-all

This was from a posting about 14.04, however it worked for me on 22.04 lts.

1 Like

Hi, @■■■■_Stephens and welcome to the Ubuntu MATE Community :slight_smile:

You wrote:

Thanks for the tip! :slight_smile: For other people seeing this topic, I believe ■■■■_Stephens is referring to the following article in the itsfoss.com web site:

1 Like