Desktop wakes from suspend at random (14.04)

My desktop is waking up from suspend by itself. Sometimes it takes just a minute or two, other times hours.

I don't know where to start troubleshooting this. Any help would be greatly appreciated.


Solution 1:

The advice given by Jos and Rinzwind gave me a start, but did not fix the issue. I do not have an Ethernet cable connected, nor do I have WOL (this actually didn't exist as an option in the BIOS) or Wake On Keyboard enabled.

I tried unplugging the mouse, a Logitech wireless with a USB reciever, before putting the computer in suspend over the night - no wakeups!

Why didn't I think of this before? I always turn off my mouse when suspending the pc. I didn't think it would cause any more problems.

So, how can one prevent the mouse/reciever from causing wake ups? First, run the command cat /proc/acpi/wakeup. This will list devices that can cause a wake up.

$ cat /proc/acpi/wakeup 
Device  S-state     Status      Sysfs node
P0P1    S4          *disabled   pci:0000:00:1e.0
USB1    S3          *disabled
USB2    S3          *disabled
USB3    S3          *disabled
USB4    S3          *disabled
USB5    S3          *disabled
USB6    S3          *disabled
USB7    S3          *disabled
RP01    S4          *disabled   pci:0000:00:1c.0
PXSX    S4          *disabled   pci:0000:01:00.0
RP02    S4          *disabled
PXSX    S4          *disabled
RP03    S4          *disabled
PXSX    S4          *disabled
RP04    S4          *disabled
PXSX    S4          *disabled
RP05    S4          *disabled   pci:0000:00:1c.4
PXSX    S4          *enabled    pci:0000:02:00.0
RP06    S4          *disabled
PXSX    S4          *disabled
RP07    S4          *disabled
PXSX    S4          *disabled
RP08    S4          *disabled
PXSX    S4          *disabled
PEG0    S4          *disabled
PEGP    S4          *disabled
PEG1    S4          *disabled
PEG2    S4          *disabled
PEG3    S4          *disabled
GLAN    S4          *disabled
EHC1    S4          *enabled    pci:0000:00:1d.0
EHC2    S4          *enabled    pci:0000:00:1a.0
XHC     S4          *enabled    pci:0000:00:14.0
HDEF    S4          *disabled   pci:0000:00:1b.0
PWRB    S3          *enabled 

In the field Status you can see whether they can wake up the computer (enabled) or not (disabled).

EHC1, EHC2 and XHCrepresent USB controllers. Obivously USB1 - USB7 as well, but they are all disabled in my case. I can't go into specifics because I don't know much about it.

I would think that PWRB (last line) represents the power button. It would be a good idea to leave it enabled, since you probably want to be able to wake your computer up by using the power button.

By giving the command sudo sh -c "echo EHC1 > /proc/acpi/wakeup" you toggle the setting for EHC1. If you run the command to list the devices again you will see that the setting for EHC1 has changed.

I tried this with the controllers EHC1, EHC2, XHC since I don't know what controller controls what USB device.

For me, leaving EHC1 and XHCenabled and disabling EHC2 gives me the result I wanted. Now neither the keyboard or the mouse (even if turned on) can cause a wake up. I have to press the physical power button on the computer itself.

Unfortunately the setting will be reset when you reboot. To combat this, you can put the code below in your /etc/rc.local. It must be edited using elevated privilegies: sudo gedit /etc/rc.local for example.

for device in EHC2
do
    if grep -q "$device.*enabled" /proc/acpi/wakeup
    then
        echo $device > /proc/acpi/wakeup
    fi
done

You can add more devices by changing the first line in the code: for device in EHC1 EHC2 XHC USB1 and so on. I found the script, written by user toojays.

This solved my issue.