Fixing suspend in Xiaomi Mi Notebook Air
The common issue in my notebooks: suspend (sleep to RAM) stops working every second time. I.e., the first time I close the lid, the laptop falls asleep, open lid awakens, but the second time is unsuccessful. Either no suspend, or no wakeup. The cure in C720 was to unload TPM manually.
Earlier I did this dropping a script into /usr/lib/systemd/system-sleep/
.
But manual page says this was a hack, there could be a nicer interface used
for that. Arch wiki
suggested creating a systemd unit to be executed prior suspend. So did I
in my Xiaomi Mi Notebook Air:
$ cat >/etc/systemd/system/root-suspend.service <<END
[Unit]
Description=Local system suspend actions
Before=sleep.target
[Service]
Type=simple
ExecStart=-/usr/bin/rmmod tpm_tis tpm_crb tpm_tis_core tpm
[Install]
WantedBy=sleep.target
END
$ systemctl daemon-reload
Seems to have helped.