Created
December 2, 2021 15:52
-
-
Save liamato/55fd7faf601fcabc562ff8fa8c739339 to your computer and use it in GitHub Desktop.
Script to suspend the USB adapter on the ZBook 17 G3 when systemd supends the computer avoiding errors like: "pci_pm_suspend(): hcd_pci_suspend+0x0/0x30 returns -16" and "dpm_run_callback(): pci_pm_suspend+0x0/0x150 returns -16"
This file contains 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/bash | |
# NAME: custom_xhci_hcd | |
# PATH: /lib/systemd/system-sleep | |
# CALL: Called from systemd automatically | |
# DESC: Suspend broken for USB3.0 as of Oct 25/2018 various kernels all at once | |
# DATE: Oct 28 2018 | |
# NOTE: From comment #61 at: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/522998 | |
# and modified like: https://www.enmimaquinafunciona.com/pregunta/160960/despierta-de-suspender-inmediatamente-cuando-el-dispositivo-bluetooth-desconectado | |
TMPLIST=/tmp/xhci-dev-list | |
case $1/$2 in | |
pre/*) | |
echo "$0: Going to $2..." | |
echo -n '' > $TMPLIST | |
for i in $(ls /sys/bus/pci/drivers/xhci_hcd/ | grep -E '[0-9a-z]+\:[0-9a-z]+\:.*$'); do | |
# Unbind xhci_hcd for first device XXXX:XX:XX.X: | |
echo -n "$i" | tee /sys/bus/pci/drivers/xhci_hcd/unbind | |
echo "$i" >> $TMPLIST | |
done | |
;; | |
post/*) | |
echo "$0: Waking up from $2..." | |
for i in $(cat $TMPLIST); do | |
# Bind xhci_hcd for first device XXXX:XX:XX.X: | |
echo -n "$i" | tee /sys/bus/pci/drivers/xhci_hcd/bind | |
done | |
rm $TMPLIST | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment