Touchpad not working after suspending laptop

This bug is reported in launchpad: Elantech touchpad stops working after suspend. After suspend the OP tries # modprobe -r psmouse and # modprobe psmouse and it doesn't work. But what if psmouse was removed before suspend and inserted after suspend?

If this works manually then you can automate by creating a new file in the /lib/systemd/system-sleep/ directory containing:

#!/bin/sh

case $1/$2 in
  pre/*)
    echo "Going to $2..."
    # Place your pre suspend commands here, or `exit 0` if no pre suspend action required
    modprobe -r psmouse
    ;;
  post/*)
    echo "Waking up from $2..."
    # Place your post suspend (resume) commands here, or `exit 0` if no post suspend action required
    sleep 2
    modprobe psmouse
    ;;
esac

It is known after a suspend the psmouse module can't be removed. We also know it can be removed and inserted before a suspend. So this technique removes it before suspend. After resume insert it and hopefully the kernel won't reject it.

The sleep 2 command is from my own problems where systemd and kernel (via gnome or APM) were both sleeping and waking up. I needed to redirect pulseaudio sound back to the TV due to a bug introduced in Ubuntu 16.04/pulseaudio 8.0. The 2 second delay was necessary for kernel and systemd to finish waking up. Still haven't figured out the dual suspend and dual resume yet....


It was recommended that I post my workaround as an answer:

I found that hibernate (sudo pm-hibernate) did not experience the same problems with touchpad restarting, therefore I just set all relevant power options to hibernate instead of suspend. This requires a little bit of effort since hibernate is disabled by default. Here's what needs to happen

  • Make sure that you have adequate swap space (swap memory > RAM). I have an adequate swap partition on my SSD but you can add swap memory without re-partioning your drive.

  • Follow the steps here to enable hibernate

  • Set additional power options to evoke hibernate instead of suspend. I did this using the dconf Editor (sudo apt-get install dconf-editor). To change relevant settings, open dconf Editor and navigate to: org > gnome > settings-daemon > plugins > power


I deal with two simple approaches with this issue. The first, which not always works (as you mentioned) just restarts the mouse module after the suspend action.

sudo rmmod psmouse ; sudo modprobe psmouse

Here is a nice discussion on how to do this "automatically": how to execute a command after resume from suspend?

An alternative approach is to kill the module before suspend, avoiding to lock of the module after the resume (which apparently is what generates the issue, as WinEunuuchs2Unix underlined).

To do that I use a simple command line to suspend the laptop instead of just closing the lid "manually". Of course this is not fancy at all, but works and it is a straigh forward solution. No time to hack involved.

sudo rmmod psmouse ; sudo pm-suspend

And then, after resuming the laptop, you should re-enable the module by typing:

sudo modprobe psmouse

You can always hack the default pm-suspend script, but I won't recommend it. It is simple and safer to generate these ad-hoc small command sequences.

Last, an easy, fast way to quickly do the "killing/suspend" and the "re-enable" of the mouse module is to associate those steps with keyboard shortcuts: How can I change what keys on my keyboard do? (How can I create custom keyboard commands/shortcuts?).

Hope it works, it does for me, although is really uncomfortable to deal with this in such way. I have this issue in both, HP and Asus Laptops.