# KDE suspend how to unload xhci_hcd to not freeze [SOLVED]

## OPelerin

When I unload manually xhci_hcd I can suspend my lenovo W510 laptop without issues.

What script should I alter in order to force unloading of this module? [ I'm using the KDE interface to go in suspend mode ]

----------

## adramalech707

xhci_hcd is usb3 correct???  and so your having issues with suspending your laptop with say a usb 3.0 device mounted???

now do you use newest version of kde? 

you can do this to run make a script:   (i use vi(m) text editor, so i don't know if you use that if u don't just either open up a text file and type this in or you can run with nano text editor....

now copy and paste this on the desktop to unload_echi_hcd.sh and give file permissions to run as root...

```

#!/bin/sh

#This shell script will suspend your system to disk after xhci_hcd has been unloaded...

#User will need to make sure that this script has correct file permissions, and that the module is actually loaded or the script will fail.  

#For more details check man chmod.

# unload ehci_hcd

modprobe -r ehci_hcd

# discover video card's ID

ID=`lspci | grep VGA | awk '{ print $1 }' | sed -e 's@0000:@@' -e 's@:@/@'`

# securely create a temporary file

TMP_FILE=`mktemp /var/tmp/video_state.XXXXXX`trap 'rm -f $TMP_FILE' 0 1 15

# switch to virtual terminal 1 to avoid graphics

# corruption in X

chvt 1

# write all unwritten data (just in case)

sync

# dump current data from the video card to the

# temporary filecat 

/proc/bus/pci/$ID > $TMP_FILE

# suspend

echo -n mem > /sys/power/state

# restore video card data from the temporary file

# on resume

cat $TMP_FILE > /proc/bus/pci/$ID

# switch back to virtual terminal 7 (running X)chvt 7

# remove temporary filerm -f $TMP_FILE

```

now i believe this will work on gentoo systems...i haven't tried it on mine...

You should also add Option "VBERestore" "true" to your X server's configuration file (/etc/X11/xorg.conf or /etc/X11/XF86Config-4) in the video card device section

```

"VBERestore"    "true"

```

got most of the code from this site: http://www.linux.com/news/hardware/laptops/8253-how-to-suspend-and-hibernate-a-laptop-under-linux

just giving people the correct credit where credit is due...

----------

## OPelerin

In fact, the laptop hang trying to go to suspend. It never reaches that state [ WITHOUT any usb3 devices connected]

Indeed I use latest ~x86 sources for KDE - Kernel 2-6-35-r5 ~amd64.

and yes that's the kind of script I'm looking for. Now, in order to automate that in KDE, I wonder if anyone  knows what set of scripts are used by KDE when I close the lid or when I click on going to suspend.... That's the place where I would like to store the script.

----------

## ppurka

 *OPelerin wrote:*   

> In fact, the laptop hang trying to go to suspend. It never reaches that state [ WITHOUT any usb3 devices connected]
> 
> Indeed I use latest ~x86 sources for KDE - Kernel 2-6-35-r5 ~amd64.
> 
> and yes that's the kind of script I'm looking for. Now, in order to automate that in KDE, I wonder if anyone  knows what set of scripts are used by KDE when I close the lid or when I click on going to suspend.... That's the place where I would like to store the script.

 kde uses pm-utils as backend. So you will need to look into pm-utils docs to find out where you can place your rmmod script. If you are not using any usb-3 device, you might as well stop the module from loading by configuring your /etc/modprobe.d/blacklist.conf.

----------

## OPelerin

Thanks for your advice. 

I googled a bit and I've found this nice site.

http://wiki.archlinux.org/index.php/Pm-utils

I did the following:

 *Quote:*   

> 
> 
> sudo cp /usr/lib/pm-utils/defaults /etc/pm/config.d/defaults
> 
> 

 

Then I've edited the file in /etc/pm/config.d/defaults

with

 SUSPEND_MODULES="xhci_hcd"

Now it works. and xhci_hcd is even reloaded when the pc is back to live. 

All works!

----------

