My problem is that after installing Ubuntu 12.04 on my laptop, suspend did not work. Through this training, I solved the suspend problem. But after resume from suspend my USB ports become unavailable.
-
Could u pls go through this post and find any useful info? http://askubuntu.com/questions/19356/how-to-diagnose-usb-issue – beeju May 03 '12 at 06:58
-
Have the same problem on a Lenovo Thinkpad x201. Would prefer any solution that does not require me to re-compile the kernel every time there is an update! – Pedro May 23 '12 at 07:54
3 Answers
I had a similar problem. And after a week of searching, I discovered what the problem was for me. In the Ubuntu kernel, the USB drivers are built-in. Therefore, upon suspend and resume, the drivers could not be unloaded and then reloaded as modules. So I had to compile the Linux kernel from source and made sure that the USB drivers (xhci_hcd
and ehci_hcd
) were made to be loadable modules.
From there, I created a file named 20_custom-ehci_hcd
in /etc/pm/sleep.d/
.
#!/bin/sh
# Inspired by http://art.ubuntuforums.org/showpost.php?p=9744970&postcount=19
#...and http://thecodecentral.com/2011/01/18/fix-ubuntu-10-10-suspendhibernate-not-working-bug
# Tidied by tqzzaa :)
VERSION=1.1
DEV_LIST=/tmp/usb-dev-list
DRIVERS_DIR=/sys/bus/pci/drivers
DRIVERS="ehci xhci" # ehci_hcd, xhci_hcd
HEX="[[:xdigit:]]"
MAX_BIND_ATTEMPTS=2
BIND_WAIT=0.1
unbindDev() {
echo -n > $DEV_LIST 2>/dev/null
for driver in $DRIVERS; do
DDIR=$DRIVERS_DIR/${driver}_hcd
for dev in `ls $DDIR 2>/dev/null | egrep "^$HEX+:$HEX+:$HEX"`; do
echo -n "$dev" > $DDIR/unbind
echo "$driver $dev" >> $DEV_LIST
done
done
}
bindDev() {
if [ -s $DEV_LIST ]; then
while read driver dev; do
DDIR=$DRIVERS_DIR/${driver}_hcd
while [ $((MAX_BIND_ATTEMPTS)) -gt 0 ]; do
echo -n "$dev" > $DDIR/bind
if [ ! -L "$DDIR/$dev" ]; then
sleep $BIND_WAIT
else
break
fi
MAX_BIND_ATTEMPTS=$((MAX_BIND_ATTEMPTS-1))
done
done fi
rm $DEV_LIST 2>/dev/null
}
case "$1" in
hibernate|suspend) unbindDev;;
resume|thaw) bindDev;;
esac
I hope this works for you. I might have made another file somewhere, but I can't find it right now.
I found that other file. In /etc/pm/config.d/
, I created a file called modules
.
modules
SUSPEND_MODULES="xhci ehci_hcd xhci_hcd xhci-hcd ehci-hcd"

- 15,657

- 1
- 2
There is a simpler solution than rebuilding the kernel at http://ubuntuforums.org/showthread.php?t=1460790 I only needed the unbind/bind on my Asus N53SV

- 1
-
1Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – fossfreedom Jun 09 '12 at 18:09
Thanks that helped.
For me, I had to a) unbind the usb devices, and b) manually off the wifi.
In case somebody finds it useful, here is a):
root@tosh:~# cat /etc/pm/sleep.d/20_usb_suspend_fix
#!/bin/sh
LOGTAG=PwrUsbFix
UNDO=/var/run/pm-utils/pm-suspend/storage/rebind_usb.sh
# check am root
[ "$(id -u)" = 0 ] || {
echo "$LOGTAG : must be run as root!"
exit 1
}
case "${1}" in
hibernate|suspend)
: > ${UNDO}
find /sys/bus/pci/drivers -maxdepth 2 -path \*\[eu\]hci\* -name unbind | cut -d\/ -f -6 | \
while read BUS ; do
find ${BUS} -maxdepth 1 -type l -name 00\* | \
while read DEVPATH ; do
DEVICE=`basename $DEVPATH`
echo "$LOGTAG : echo ${DEVICE} > ${BUS}/unbind"
echo -n "${DEVICE}" > ${BUS}/unbind
echo "echo \"${LOGTAG} ${DEVICE} > ${BUS}/bind\"" >> ${UNDO}
echo "echo -n \"${DEVICE}\" > ${BUS}/bind" >> ${UNDO}
done
done
;;
resume|thaw)
. ${UNDO}
;;
esac
exit 0
and b)
root@tosh# cat /etc/pm/sleep.d/30_wifi_off
#! /bin/sh
MODULES="ath9k ath9k_common ath9k_hw ath"
case "${1}" in
hibernate|suspend)
# Switch wireless off
nmcli nm sleep true
rfkill block 0
rmmod ${MODULES}
;;
resume|thaw)
# Switch wireless on
modprobe ${MODULES}
rfkill unblock 0
nmcli nm sleep false
;;
esac
finally - sys info..
http://www.toshiba.co.uk/discontinued-products/satellite-pro-p300-28e/
root@tosh:~# uname -a
Linux tosh 3.13.0-31-generic #55~precise2-Ubuntu SMP Wed Jul 2 17:02:56 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
root@tosh:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.5 LTS
Release: 12.04
Codename: precise

- 131