2018-06-24 17:28:16 +00:00
|
|
|
#!/bin/bash
|
|
|
|
case $1 in
|
2019-08-07 15:13:57 +00:00
|
|
|
pre) # unload the modules before going to sleep
|
2019-09-23 15:54:42 +00:00
|
|
|
|
|
|
|
# Disable bluetooth if no device is connected
|
2019-10-11 22:21:25 +00:00
|
|
|
if ps cax | grep bluetoothd && ! bluetoothctl info; then
|
2019-09-23 15:54:42 +00:00
|
|
|
bluetoothctl power off
|
|
|
|
fi
|
|
|
|
|
2019-12-22 14:56:41 +00:00
|
|
|
## Disable bluetooth regardless if devices are connected (see notes below)
|
|
|
|
#if ps cax | grep bluetoothd; then
|
|
|
|
# bluetoothctl power off
|
|
|
|
#fi
|
|
|
|
|
2019-08-07 15:13:57 +00:00
|
|
|
# handle wifi issues
|
2019-02-07 12:58:07 +00:00
|
|
|
modprobe -r mwifiex_pcie;
|
|
|
|
modprobe -r mwifiex;
|
|
|
|
modprobe -r cfg80211;
|
2019-08-07 15:13:57 +00:00
|
|
|
|
|
|
|
## IPTS: see notes below
|
|
|
|
## > Remove IPTS from ME side
|
sleep-script: IPTS: fix module unloading on newer kernels
On a recent version of kernels, "intel_ipts" module will be used by companion
driver "ipts_surface". So, unload the module first on unloading whole IPTS
modules and load the module last on loading whole IPTS modules.
Otherwise, unloading "intel_ipts" will fail.
Unloading the module will automatically unload "intel_ipts" module but
I did not remove the line for clarity and for kernels that don't have
the companion driver ("ipts_surface").
On my 5.3 kernel:
$ lsmod | grep -e "Used by" -e "ipts"
Module Size Used by
ipts_surface 16384 0
intel_ipts 45056 1 ipts_surface
hid 143360 6 i2c_hid,usbhid,hid_multitouch,hid_sensor_hub,intel_ipts,hid_generic
mei 122880 5 mei_hdcp,intel_ipts,mei_me
i915 2273280 18 intel_ipts
Tested on kernel 5.3.12 and 4.19.85 that use the "ipts_surface" companion driver with IPTS lines
uncommented on sleep script.
2019-12-02 20:25:48 +00:00
|
|
|
#modprobe -r ipts_surface
|
2019-08-07 15:13:57 +00:00
|
|
|
#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
|
2018-06-24 17:28:16 +00:00
|
|
|
;;
|
2019-08-07 15:13:57 +00:00
|
|
|
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
|
sleep-script: IPTS: fix module unloading on newer kernels
On a recent version of kernels, "intel_ipts" module will be used by companion
driver "ipts_surface". So, unload the module first on unloading whole IPTS
modules and load the module last on loading whole IPTS modules.
Otherwise, unloading "intel_ipts" will fail.
Unloading the module will automatically unload "intel_ipts" module but
I did not remove the line for clarity and for kernels that don't have
the companion driver ("ipts_surface").
On my 5.3 kernel:
$ lsmod | grep -e "Used by" -e "ipts"
Module Size Used by
ipts_surface 16384 0
intel_ipts 45056 1 ipts_surface
hid 143360 6 i2c_hid,usbhid,hid_multitouch,hid_sensor_hub,intel_ipts,hid_generic
mei 122880 5 mei_hdcp,intel_ipts,mei_me
i915 2273280 18 intel_ipts
Tested on kernel 5.3.12 and 4.19.85 that use the "ipts_surface" companion driver with IPTS lines
uncommented on sleep script.
2019-12-02 20:25:48 +00:00
|
|
|
#modprobe ipts_surface
|
2019-08-07 15:13:57 +00:00
|
|
|
|
2019-09-23 15:54:42 +00:00
|
|
|
# Restart bluetooth
|
2019-10-11 22:21:25 +00:00
|
|
|
if ps cax | grep bluetoothd; then
|
|
|
|
bluetoothctl power on
|
|
|
|
fi
|
2019-09-23 15:54:42 +00:00
|
|
|
|
2019-08-07 15:13:57 +00:00
|
|
|
# handle wifi issues: complete cycle
|
2019-08-12 19:16:13 +00:00
|
|
|
modprobe cfg80211;
|
|
|
|
modprobe mwifiex;
|
|
|
|
modprobe mwifiex_pcie;
|
2019-02-07 12:58:07 +00:00
|
|
|
echo 1 > /sys/bus/pci/rescan
|
2019-10-01 10:13:59 +00:00
|
|
|
|
|
|
|
if [ -x "$(command -v nmcli)" ] && [ "$(nmcli net)" = "enabled" ]; then
|
|
|
|
nmcli net off
|
|
|
|
nmcli net on
|
|
|
|
fi
|
2018-06-24 17:28:16 +00:00
|
|
|
;;
|
|
|
|
esac
|
2019-08-07 15:13:57 +00:00
|
|
|
|
|
|
|
# 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.
|
2019-12-22 14:56:41 +00:00
|
|
|
# - For bluetooth: If you have spontaneous wakeups, you may want to disable
|
|
|
|
# bluetooth completely, regardless if any devices are connected or not, by
|
|
|
|
# removing the `! bluetoothctl info;` part as indicated in the comment (e.g.
|
|
|
|
# comment-out the original check and comment-in the one below). Note that you
|
|
|
|
# may be required to re-connect your devices after resume if you choose this
|
|
|
|
# change.
|