linux-surface/root/lib/systemd/system-sleep/sleep
Dorian Stoll b74befa0ca
Disable bluetooth when suspending without anything connected.
On Surface Book 2 it is not possible to archive stable S0ix while bluetooth is
enabled but no device is connected. Either S0ix fails completely, or the
residency is pretty bad. When bluetooth is disabled, or a device such as the pen
is connected, S0ix works fine and residency is great again.

By disabling bluetooth when no device is connected, we get proper S0ix in all
situations. And since no device is connected, the reset won't really matter.

Signed-off-by: Dorian Stoll <dorian.stoll@tmsp.io>
2019-09-28 03:27:10 +02:00

54 lines
1.6 KiB
Bash

#!/bin/bash
case $1 in
pre) # unload the modules before going to sleep
# Disable bluetooth if no device is connected
if ! bluetoothctl info; then
bluetoothctl power off
fi
# handle wifi issues
modprobe -r mwifiex_pcie;
modprobe -r mwifiex;
modprobe -r cfg80211;
## IPTS: see notes below
## > Remove IPTS from ME side
#modprobe -r intel_ipts
#modprobe -r mei_hdcp
#modprobe -r mei_me
#modprobe -r mei
## > Remove IPTS from i915 side
#for i in $(find /sys/kernel/debug/dri -name i915_intel_ipts_cleanup); do echo 1 > $i; done
;;
post) # re-load modules after resume
## IPTS: see notes below
## > Load IPTS from i915 side
#for i in $(find /sys/kernel/debug/dri -name i915_intel_ipts_init); do echo 1 > $i; done
## > Load IPTS from ME side
#modprobe mei
#modprobe mei_me
#modprobe mei_hdcp
#modprobe intel_ipts
# Restart bluetooth
bluetoothctl power on
# handle wifi issues: complete cycle
modprobe cfg80211;
modprobe mwifiex;
modprobe mwifiex_pcie;
echo 1 > /sys/bus/pci/rescan
systemctl restart NetworkManager.service
;;
esac
# Notes:
# - For IPTS, see
# > https://github.com/jakeday/linux-surface/issues/544#issuecomment-519126757
# for an explanation/discussion. We do not unload/reload modules for now as
# the IPTS drivers should be able to resume/suspend without this. If you
# experience any issues on suspend/resume, please file an appropriate issue or
# join the discussion linked above so that we can fix it. As a temporary
# workaround, you may want to uncomment the IPTS-related lines above.