-
-
Save aslafy-z/afae8675b401fe77ff049941607fbd5b to your computer and use it in GitHub Desktop.
Disable broken xhci device before suspend and avoid freeze.
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 | |
# | |
# 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 | |
# | |
# Source https://gist.github.com/ioggstream/8f380d398aef989ac455b93b92d42048 | |
# Source https://askubuntu.com/questions/1089067/wakes-from-suspend-immediately-when-bluetooth-device-disconnected/1092933 | |
LOGFILE=/tmp/systemd_suspend_force.log | |
TEMPFILE=/tmp/systemd_suspend_force.save | |
case "${1}" in | |
pre) | |
# Reset files | |
echo -n > $LOGFILE | |
echo -n > $TEMPFILE | |
# Do the thing you want before suspend here, e.g.: | |
echo "[$(date)] Disable broken xhci module before suspending" >> $LOGFILE | |
grep XHC.*enable /proc/acpi/wakeup && echo XHC > /proc/acpi/wakeup | |
for dev in $(ls /sys/bus/pci/drivers/xhci_hcd/ | grep -E '[0-9a-z]+:[0-9a-z]+:.*$'); do | |
echo "[$(date)] Unbind xhci_hcd for first device ${dev}" >> $LOGFILE | |
echo -n "$dev" | tee /sys/bus/pci/drivers/xhci_hcd/unbind | |
echo "$dev" >> $TEMPFILE | |
done | |
;; | |
post) | |
# Do the thing you want after resume here, e.g.: | |
echo "[$(date)] Enable broken xhci module at wakeup" >> $LOGFILE | |
grep XHC.*disable /proc/acpi/wakeup && echo XHC > /proc/acpi/wakeup | |
for dev in $(cat $TEMPFILE); do | |
echo "[$(date)] Bind xhci_hcd for first device ${dev}" >> $LOGFILE | |
echo -n "$dev" | tee /sys/bus/pci/drivers/xhci_hcd/bind | |
done | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment