Sunday, March 1, 2009

Getting suspend-to-RAM working on my Lenovo T61p

I spent a bit of time this weekend trying to get suspend-to-ram (S3) working on my work-issued laptop. It works great. However, there are (as usual) some issues.

The first issue is that it I cannot use s2ram when I'm running X, because for whatever reason s2ram with the right options works great outside of X but when the NVidia driver is in use there is a conflict of sorts (I believe it has to do with POSTing the card after return from suspending). I have to use the NVidia driver because vesa is limited in geometry and the nv driver misdetects my display badly. I'll note that until openSUSE 11.1 the nv driver didn't work *at all*, just a hung laptop, so this is progress and I'm glad for it!

In any case, I had to force pm-utils not to use s2ram at all by removing /usr/sbin/s2ram. One package or another pulls in suspend (the package containing /usr/sbin/s2ram) as a dependancy and the pm-utils "functions" script checks to see if it exists and is executable - using it if possible. I don't want it to use s2ram so I simply removed /usr/sbin/s2ram. I filed a bug for a more elegant solution, which allows a config variable to simply specify "use the in-kernel method always".

As an aside, for those that might find this useful, using s2ram without the NVidia driver active works great with: --vbe_mode --vbe_post --acpi_sleep 2

With the NVidia driver active, using the "in-kernel" S3 mode works great:

echo -n "mem" > /sys/power/state

I ran into issues with the above failing if ksysguardd is running (probably related to ksysguardd checking the temp of my CPUs) - suspending simply fails. I've worked around this by using a script in /etc/pm/sleep.d to SIGSTOP ksysgardd and the SIGCONT upon wakeup, and this appears to work but it hasn't received much testing.

One thing that complicated things is the lack of documentation on where to configure things and what to put there. After I had determined that s2ram (with the aforementioned options) works fine when X is not running, I tried to make it work in X. pm-utils sometimes pulls it's options from s2ram, sometimes from /etc/pm/config.d/*, and other times from HAL. HAL was configured suboptimally for my laptop (a Lenovo T61p) so, but ultimately I determined that using s2ram wasn't going to work no matter what options I sent along, provided I was using the NVidia driver. Thus, the HAL config for my laptop (/usr/share/hal/fdi/information/10freedesktop/20-video-quirk-pm-lenovo.fdi) didn't get used at all, as far as I can tell.

If you want the HAL config it looks like this, more-or-less replicating the above s2ram config. THIS DOES NOT WORK with NVidia drivers loaded.

The best documentation I found was pm-utils' documentation which detailed (confusingly, however) the origination for each decision and config. Expanding and improving that document, as well as promoting it as the de-facto source of information, might have saved me a bunch of time.