As of recently, this is handled in the kernel directly. I have been
running the patch + this script for some time and couldn't notice any
regressions.
Signed-off-by: Dorian Stoll <dorian.stoll@tmsp.io>
In some instances, bluetooth devices can prevent the device from going
to sleep or cause spurious wake-ups. Add a note to the sleep script on
how bluetooth can be turned off completely during suspend.
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.
If bluetooth is disabled in the BIOS, the bluetoothd process won't be
running. bluetoothctl waits for that process to launch, which means it
timeouts indefinitly, breaking suspend entirely.
By checking if bluetoothd is running before calling bluetoothctl suspend
works fine even if bluetooth is disabled in the BIOS.
Signed-off-by: Dorian Stoll <dorian.stoll@tmsp.io>
By using nmcli, users who don't use a systemd based distribution (Gentoo etc.),
can run the sleep script manually, or hook it up to their service manager manually.
This also removes the forced restart if people willingly disabled NetworkManager.
Signed-off-by: Dorian Stoll <dorian.stoll@tmsp.io>
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>
Using the old script I regulary had the problem, that after resuming
from suspend (or hibernate) the wifi would just break. The only way
to fix it was to restart network manager, or disable it in the GNOME
network settings.
I am not a 100% sure *why*, but this change greatly improved the wifi
stability after resume. I am running this for like 5 days now and
didn't see the wifi breaking once. I suppose, that `modprobe` vs
`modprobe -i` is what makes the difference.
Signed-off-by: Dorian Stoll <dorian.stoll@tmsp.io>
Integrate the changes discussed in [1] as proposed by @kitakar5525 in
[2]. The IPTS suspend/resume mechanism should work without the need for
unloading/reloading the corresponding modules, so we comment-out and
update the workaround and will handle any issues coming from that via
the IPTS drivers. The workaround is not completely removed yet as want
to provide an easy-to-apply temporary fix in case anything goes wrong.
[1]: https://github.com/jakeday/linux-surface/issues/544
[2]: https://github.com/jakeday/linux-surface/issues/544#issuecomment-519126757