Comment 35 for bug 952080

Revision history for this message
B&M (tryingubuntu) wrote :

Same problem with a desktop computer : after suspend, the computer wakes up immediately (this seems related to kernel version : see my post above)
None of the solutions above disabling usb worked.
The only solution that worked for me is the one given by *M* in http://ubuntuforums.org/showthread.php?t=1969615 : create a script in /etc/pm/sleep.d containing :

#!/bin/bash
# Disables echi / ohci / uhci ports on suspend and reenables them on resume.
# Place this script in /etc/pm/sleep.d

function unbind_usb {
    for driver in ehci ohci uhci; do
        cd "/sys/bus/pci/drivers/${driver}_hcd";
        ids=$(ls | grep :);
        echo $ids > /tmp/DISABLED_$driver;
        for id in $ids; do
            echo "Unbinding $id";
            echo -n "$id" > unbind;
            disabled="$disabled $id";
        done;
    done;
}

function bind_usb {
    for driver in ehci ohci uhci; do
        cd "/sys/bus/pci/drivers/${driver}_hcd";
        for id in $(cat /tmp/DISABLED_$driver); do
            echo "Binding $id";
            echo -n "$id" > bind;
        done;
        rm /tmp/DISABLED_$driver;
    done;
}

case "$1" in
    hibernate|suspend)
        unbind_usb;
    ;;
    thaw|resume)
        bind_usb;
        # Uncomment the following two lines if USB devices stutter after resume
        # unbind_usb;
        # bind_usb;
    ;;
    *)
    exit 1;
    ;;
esac;
exit 0;

And it workd perfectly in my case.