Last active
June 20, 2023 04:31
-
-
Save rjshrjndrn/3a5b2b63a90a5c1a0b11e0610ac57382 to your computer and use it in GitHub Desktop.
fix suspend to ram not wake up properly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Ref: https://gist.github.com/ioggstream/8f380d398aef989ac455b93b92d42048 | |
# Steps to identify: | |
# 1. `journalctl` | |
# 2. `/sleep` | |
# 3. Check for pci_pm_supend | |
# 4. For example: xhci_hcd 0000:00:14.0: PM: failed to suspend async: error -16 | |
# 5. to get the device details: take `14.0` and run `sudo lspci -k -nn -v -s 14.0` | |
# 6. Check for the `kernel_module` in this case, its xhci_pci, and disable it | |
# | |
# Ref How to check the module: https://github.com/NixOS/nixpkgs/issues/78286#issuecomment-579452772 | |
# | |
# This script should prevent the following suspend errors | |
# which freezes the Dell Inspiron laptop. | |
# | |
# Put it in /usr/lib/systemd/system-sleep/xhci.sh | |
# | |
# The PCI 00:14.0 device is the usb xhci controller. | |
# | |
# kernel: [67445.560610] pci_pm_suspend(): hcd_pci_suspend+0x0/0x30 returns -16 | |
# kernel: [67445.560619] dpm_run_callback(): pci_pm_suspend+0x0/0x150 returns -16 | |
# kernel: [67445.560624] PM: Device 0000:00:14.0 failed to suspend async: error -16 | |
# kernel: [67445.886961] PM: Some devices failed to suspend, or early wake event detected | |
#if [ "${1}" == "pre" ]; then | |
# # Do the thing you want before suspend here, e.g.: | |
# echo "Disable broken xhci module before suspending at $(date)..." > /tmp/systemd_suspend_test | |
# grep XHC.*enable /proc/acpi/wakeup && echo XHC > /proc/acpi/wakeup | |
#elif [ "${1}" == "post" ]; then | |
# # Do the thing you want after resume here, e.g.: | |
# echo "Enable broken xhci module at wakeup from $(date)" >> /tmp/systemd_suspend_test | |
# grep XHC.*disable /proc/acpi/wakeup && echo XHC > /proc/acpi/wakeup | |
#fi | |
mods=( xhci_pci ) | |
case $1 in | |
pre) | |
for mod in ${mods[@]}; do | |
rmmod $mod | |
done | |
;; | |
post) | |
for mod in ${mods[@]}; do | |
modprobe $mod | |
done | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment