Ubuntu – Laptop wakes up by itself a few seconds after suspend or lidclose

network-managerpower-managementsuspendwakeup

I am running an Ubuntu 18.04.1 with kernel 4.15.0-29-generic, and my laptop (Macbookpro retina 15inch, mid 2015, MacBookPro11,5) wakes up automatically a few seconds after sleep. When I look at the logs in \var\log\syslogs the wakeup event shows up as: Aug 6 15:51:53 Shire NetworkManager[7444]: <info> [1533595913.5200] manager: sleep: wake requested (sleeping: yes enabled: yes).

I have already looked at all the other questions and answers for this, but my problem still persists as follows:

Following this question and its answers, the output of cat /proc/acpi/wakeup is

Device  S-state   Status   Sysfs node
PEG0      S3    *disabled  pci:0000:00:01.0
GFX0      S3    *disabled  pci:0000:01:00.0
PEG1      S3    *disabled  pci:0000:00:01.1
PEG2      S3    *disabled  pci:0000:00:01.2
EC        S4    *disabled  platform:PNP0C09:00
GMUX      S3    *disabled  pnp:00:03
HDEF      S3    *disabled  pci:0000:00:1b.0
RP03      S3    *disabled  pci:0000:00:1c.2
ARPT      S4    *enabled   pci:0000:04:00.0
RP04      S3    *disabled  pci:0000:00:1c.3
XHC1      S3    *enabled   pci:0000:00:14.0
ADP1      S4    *disabled  platform:ACPI0003:00
LID0      S4    *enabled   platform:PNP0C0D:00

and I have isolated the problem to be the ARPT entry. If I lookup the pci for this entry via lspci I get 04:00.0 Network controller: Broadcom Limited BCM43602 802.11ac Wireless LAN SoC (rev 01), which matches the log info that the wake-up is caused by network.

Here is the weird part: I use sudo sh -c "echo ARPT > /proc/acpi/wakeup" to disable the wakeup functionality of ARPT, and it changes the status to disabled correctly, but when I put the laptop to sleep it still wakes up after just a few seconds! More surprisingly, when it wakes up and I check the /proc/acpi/wakeup I see that the ARPT entry has returned to enabled by itself! Note that this does not happen after a restart, but just immediately after disabling the wakeup entry and suspending. It seems that some other script keeps changing this while the laptop is in sleep.

Other things I tried with NO result:

  • Stopped network manager via sudo service netwrok-manager stop, but the laptop still wakes up.
  • Disabled power management of wifi by using sudo iwconfig wlan0 power off
  • Made sure Wake on WLAN (WoWLAN) is off by following this article
  • Made \proc\acpi\wakeup read-only.

Update:

I tried disabling both the ARPT and XHC1 and only leaving LID0 enabled (laptop lid), and the system still wakes up after a few seconds. But this time when it wakes up the settings in /proc/acpi/wakeup is kept as it was and is not automatically reverted.

Update 08/17/2018:

With the new kernel 4.15.0-32 the laptop does not wake anymore when the lid is closed, but it still wakes up by itself when the lid is open and it has gone to sleep. At least now I can put my laptop in my backpack without worrying to run out of battery, and also apparently this is a Kernel problem and I doubt I can hack my way around it without spending significant time.

Best Answer

August 8, 2018 Update

Kernel 4.15.0-30 has been released. The resume immediately after suspend problem persists. Kernel 4.13.0-36 still works reliably.

Additional steps to try

I have the same problem on 4.15.0-29-generic. I had just installed nVidia driver 384.130 and assumed it was related to that. I went through all your steps plus I modified:

$ paste <(ls /sys/bus/usb/devices/*/power/wakeup) <(cat /sys/bus/usb/devices/*/power/wakeup) | column -s $'\t' -t
/sys/bus/usb/devices/1-1.4.3/power/wakeup  disabled
/sys/bus/usb/devices/1-1.4/power/wakeup    disabled
/sys/bus/usb/devices/1-1/power/wakeup      disabled
/sys/bus/usb/devices/1-4/power/wakeup      disabled
/sys/bus/usb/devices/1-5/power/wakeup      enabled
/sys/bus/usb/devices/1-9/power/wakeup      disabled
/sys/bus/usb/devices/usb1/power/wakeup     disabled
/sys/bus/usb/devices/usb2/power/wakeup     disabled
/sys/bus/usb/devices/usb3/power/wakeup     disabled
/sys/bus/usb/devices/usb4/power/wakeup     disabled

USB 1-5 is the WiFi / Bluetooth card:

$ lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 009: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 007: ID 1bcf:2b8c Sunplus Innovation Technology Inc. 
Bus 001 Device 005: ID 0cf3:e301 Atheros Communications, Inc. 
Bus 001 Device 003: ID 187c:0528 Alienware Corporation 
Bus 001 Device 008: ID 413c:9016 Dell Computer Corp. 
Bus 001 Device 006: ID 2109:2812 VIA Labs, Inc. VL812 Hub
Bus 001 Device 004: ID 0764:0501 Cyber Power System, Inc. CP1500 AVR UPS
Bus 001 Device 002: ID 2109:2812 VIA Labs, Inc. VL812 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

You can check this as well.

Unplug everything

Intel recommends unplugging everything-- All USBs, Network cable, etc to debug suspending. There are other things to try listed in Intel's article.

Kernel 4.13.0-36 works!

I recompiled my nvhda.ko under kernel 4.13.0-36-generic and discovered that suspend through the menu at least works now.

  • If you have an older kernel version like 4.15.0-24 in your Advanced Grub menu boot with that.
  • If you have 4.13.0-36 boot with that.
  • If you don't have an older version you can install it with sudo apt install linux-image-4.15.0-24*
  • If you use DKMS you also need to use sudo apt install linux-headers-4.15.0-24*
  • I don't see kernels 4.15.0-25 through 4.15.0-28 available in the repository.