Skip to content

Instantly share code, notes, and snippets.

@fcicq
Created July 27, 2019 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fcicq/276307132849ec7c89ecb7d53fc6aeda to your computer and use it in GitHub Desktop.
Save fcicq/276307132849ec7c89ecb7d53fc6aeda to your computer and use it in GitHub Desktop.
cat <<'EOF' > /lib/systemd/system-sleep/custom-xhci_hcd
#!/bin/bash
# Original script was using /bin/sh but shellcheck reporting warnings.
# 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
TMPLIST=/tmp/xhci-dev-list
# Original script was: case "${1}" in hibernate|suspend)
case $1/$2 in
pre/*)
echo "$0: Going to $2..."
rfkill block bluetooth || :
echo -n '' > $TMPLIST
for i in `ls /sys/bus/pci/drivers/xhci_hcd/ | egrep '[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..."
rfkill unblock bluetooth || :
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
EOF
chmod +x /lib/systemd/system-sleep/custom-xhci_hcd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment