2

When I suspend my Dell XPS 13 9379, NetworkManager wakes it again immediately if my bluetooth mouse is not connected:

# journalctl -ex
...
systemd-logind[653]: Operation 'sleep' finished.
NetworkManager[650]: <info>  [1541032616.6736] manager: sleep: wake requested (sleeping: yes  enabled: yes)
NetworkManager[650]: <info>  [1541032616.6739] device (enxa0cec8126450): state change: unavailable -> unmanaged (reason 'sleeping', sys-iface-state: 'managed')
NetworkManager[650]: <info>  [1541032616.7017] device (enxa0cec8126450): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'managed')
...

How can I prevent Bluetooth from waking my machine?


Apparently Bluetooth is either irrelevant or not the only source of the issue, as my machine woke (or rather, failed to sleep) with Bluetooth disabled. Based on the logs I found this time, my 00:14.0 USB controller: Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller (rev 21) it to blame:

kernel: PM: suspend entry (s2idle)
kernel: PM: Syncing filesystems ... done.
kernel: Freezing user space processes ... (elapsed 0.004 seconds) done.
kernel: OOM killer disabled.
kernel: Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
kernel: Suspending console(s) (use no_console_suspend to debug)
kernel: pci_pm_suspend(): hcd_pci_suspend+0x0/0x30 returns -16
kernel: dpm_run_callback(): pci_pm_suspend+0x0/0x150 returns -16
kernel: PM: Device 0000:00:14.0 failed to suspend async: error -16
kernel: PM: Some devices failed to suspend, or early wake event detected
kernel: rtc_cmos 00:01: Alarms can be up to one month in the future
kernel: OOM killer enabled.
kernel: Restarting tasks ... done.
kernel: [drm] RC6 on
kernel: thermal thermal_zone8: failed to read out thermal zone (-61)
kernel: PM: suspend exit
kernel: PM: suspend entry (s2idle)
kernel: PM: Syncing filesystems ... done.
kernel: Freezing user space processes ... (elapsed 0.002 seconds) done.
kernel: OOM killer disabled.
kernel: Freezing remaining freezable tasks ... (elapsed 0.056 seconds) done.
kernel: Suspending console(s) (use no_console_suspend to debug)
kernel: pci_pm_suspend(): hcd_pci_suspend+0x0/0x30 returns -16
kernel: dpm_run_callback(): pci_pm_suspend+0x0/0x150 returns -16
kernel: PM: Device 0000:00:14.0 failed to suspend async: error -16
kernel: PM: Some devices failed to suspend, or early wake event detected
kernel: rtc_cmos 00:01: Alarms can be up to one month in the future
kernel: OOM killer enabled.
kernel: Restarting tasks ... done.
kernel: [drm] RC6 on
kernel: thermal thermal_zone8: failed to read out thermal zone (-61)
systemd[1]: systemd-suspend.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: systemd-suspend.service: Failed with result 'exit-code'.
systemd[1]: Failed to start Suspend.

2 Answers2

3

My laptop which used to suspend OK most of the time started having problems last week. Perhaps due to a faulty cable. I created a bash script which suspends and resumes faster than before and more reliably.

Use this command:

sudo -H gedit /lib/systemd/system-sleep/custom-xhci_hcd

Copy and paste the following into the editor:

#!/bin/bash

# Original script was using /bin/sh but shellcheck reporting warnings.

# NAME: custom-xhci_hcd
# PATH: /lib/systemd/system-sleep
# CALL: Called from SystemD automatically
# DESC: Suspend broken for USB3.0 as of Oct 25/2018 various kernels all at once

# DATE: Oct 28 2018.

# NOTE: From comment #61 at: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/522998

TMPLIST=/tmp/xhci-dev-list

# Original script was: case "${1}" in hibernate|suspend)

case $1/$2 in
  pre/*)
    echo "$0: Going to $2..."
    echo -n '' > $TMPLIST
          for i in `ls /sys/bus/pci/drivers/xhci_hcd/ | egrep '[0-9a-z]+\:[0-9a-z]+\:.*$'`; do
              # Unbind xhci_hcd for first device XXXX:XX:XX.X:
               echo -n "$i" | tee /sys/bus/pci/drivers/xhci_hcd/unbind
           echo "$i" >> $TMPLIST
          done
        ;;
  post/*)
    echo "$0: Waking up from $2..."
    for i in `cat $TMPLIST`; do
              # Bind xhci_hcd for first device XXXX:XX:XX.X:
              echo -n "$i" | tee /sys/bus/pci/drivers/xhci_hcd/bind
    done
    rm $TMPLIST
        ;;
esac

Then save the file and exit gedit.

Mark the script as executable using:

sudo chmod a+x /lib/systemd/system-sleep/custom-xhci_hcd

Now your suspend/resume problems should go away. If not hopefully someone else posts their solution.

  • 1
    This worked great, but removing the echo "$0:... from each block seemed to help (I was seeing the echoed result when my screen woke and seeing odd behavior sometimes). Thanks for posting WinEunuuchs2Unix! – jnewman Sep 18 '19 at 05:31
  • 1
    Also worked for me, with a Samsung NP700z5B-s-1ub (for search reference!). Thank you! – Rmano Nov 10 '19 at 12:59
  • 1
    Thanks, works for Dell Precision 5550 on Pop OS 21.04 . Suspend broke when bluetooth was enabled and this solution fixed it. – Lari Hotari Jun 08 '21 at 06:17
3

Could be kernel bug 200039. Removing the btusb module would help in that case (rmmod btusb). If that is the case you could indeed load/unload the kernel module via a sleep script, much as the one posted here.