LWN.net Logo

Swsusp approaches readiness

Your editor recently replaced his venerable Sony 505-FX laptop. That machine had a nice feature - hitting a certain magic function key sequence would cause the APM BIOS to take over, save the contents of memory to disk, and suspend the system. The Linux APM code would let the kernel trap the events and do things like flush out disk buffers (before suspending) or reset the system clock (after). It all "just worked."

The new laptop has the same little "suspend" symbol on the same key, but it doesn't work. In the modern, ACPI world, it is the operating system which is responsible for suspending and resuming the system. This change is, somehow, presented as progress. The version of Windows shipped with the laptop is able to perform this operation, of course. Strangely, Sony does not support Linux to the same level. Your editor, it seems, was doomed to head off to the Kernel Summit and OLS with a non-suspending laptop.

Then came the announcement that software suspend for 2.4, v1.0, was available. LWN has covered the swsusp patch before, but swsusp has long been in the "almost works" category. For a long time, it appeared that not much was being done in that area. More recently, the swsusp effort has picked up steam (as more kernel hackers get new laptops, perhaps). Thus, the 1.0 release.

The swsusp tarball yielded a series of patches; the user has to decide which ones to apply depending on what other patches are of interest. For example, if the target (2.4.21) kernel has the ACPI patches in it (pretty much mandatory for many laptops), a separate swsusp "option" patch must be applied as well. The swsusp "Applying" file covers the necessary patches (and required order) reasonably well - for somebody who is comfortable messing with highly patched kernels.

The patch also comes with a "hibernate" script which is used to actually kick off a software suspend operation. This (lengthy) script tries to get everything into shape for a graceful suspend; in many ways, it behaves like a partial shutdown. Certain processes are killed off, as many modules as possible are unloaded, etc. On resume it restores the clock, reconfigures network interfaces, and, perhaps, engages in some complicated gymnastics in an effort to get X and the video hardware back in sync.

The bottom line is: it works. On your editor's laptop, an invocation of hibernate saves state and takes the system to a power-off state in 16 seconds. Returning to a full X display takes a little longer: 34 seconds, after the BIOS finishes its power-on ablutions. To say the least, this is a nice functionality to have in a laptop, especially when one is attempting to cover a conference.

The one bit of remaining difficulty is the laptop's Radeon video hardware, which refuses to come back into any sort of reasonable, useful state. There is, evidently, a patch for XFree86 which makes this problem go away. But your editor, who has no trouble with patching a kernel to a pulp, shies away from patching and installing XFree86. It was far simpler to tell X to run in the unaccelerated, dumb frame buffer mode, which works just fine.

For those who are interested in 2.4 software suspend, the first swsusp 1.1 release candidate was announced on August 5. There's a number of useful changes in this version, but the largest is probably the ability to save system state to swapfiles (previous versions only worked with swap partitions). Software suspend support in 2.6 is in more of a state of flux; the power management changes have still not been merged, and work is being done to make the swsusp support cleaner, more flexible, and more robust. 2.6 should eventually have a solid swsusp implementation, though it may still be stabilizing when 2.6.0 comes out. It is unclear whether swsusp will ever be merged into the 2.4 kernel; it is a somewhat invasive patch to apply to a stable series.


(Log in to post comments)

Re: radeon (was: Swsusp approaches readiness)

Posted Aug 7, 2003 1:39 UTC (Thu) by nirik (subscriber, #71) [Link]

Worth noting that you can find a handy script that will recompile just the radeon module and needed X modules at:
http://cpbotha.net/dri_resume.html

So, you don't need to patch/rebuild X from it's gigantic tree. ;)
Just run the install.sh script and it will do the right thing.

Swsusp works great for me with the above for my radeon card.

kevin@tummy.com

Re: radeon (was: Swsusp approaches readiness)

Posted Aug 7, 2003 22:21 UTC (Thu) by daenzer (subscriber, #7050) [Link]

Anyway, doesn't the problem only occur with DRI enabled (at least when switching to a VT for suspend, as hinted in an article below)? The radeon driver with DRI disabled is still much nicer than an unaccelerated driver. :)

Swsusp approaches readiness

Posted Aug 7, 2003 4:23 UTC (Thu) by judge (guest, #6234) [Link]

Out of curiosity.What's the new vaio model that the editor got?

Swsusp approaches readiness

Posted Aug 7, 2003 13:35 UTC (Thu) by corbet (editor, #1) [Link]

It's a V505-AX. It's been a bit of a challenge to make it all work, but it's a nice machine.

Suspending from X

Posted Aug 7, 2003 9:43 UTC (Thu) by mtk77 (subscriber, #6040) [Link]

I emailed this to Jon, but it may be of wider interest:

Have you tried adding "chvt 1" to the hibernate
script and "chvt 7" (or whatever) to the restore
one?

I have a laptop which can't even APM suspend
successfully under X, so I just wrapped the apm
command to switch to a text console first...

Suspending from X

Posted Aug 7, 2003 22:18 UTC (Thu) by daenzer (subscriber, #7050) [Link]

That's weird, as the X server basically emulates a VT switch on APM suspend. Is /dev/apm_bios available, and does the X server log contain a line

(II) Open APM successful

?

Swsusp approaches readiness

Posted Aug 8, 2003 0:04 UTC (Fri) by NCunningham (subscriber, #6457) [Link]

It should be noted that the actual time to suspend and resume will vary with the hardware and the specific state of memory when it's invoked. A computer with little memory in use may suspend in a couple of seconds. My 640MB laptop can take a lot longer when I have Win4Lin, Evolution and Opera all loaded so that the image is 500MB. There is an option to limit the size of images if you don't want all of your cache saved.

Encrypted software suspend

Posted Aug 9, 2003 23:24 UTC (Sat) by jc (subscriber, #5895) [Link]

Excellent.

But there is one thing that keeps many people from using Software Suspend or BIOS hibernation. Encrypted disks. If you handle sensitive data, or are just paranoid, you probably keep your swap and your most important filesystems encrypted. Then it won't make much sense writing everything in cleartext to disk when suspending. Fixing this problem in the BIOS just won't happen any time soon, but integrating something like loop-aes in Software Suspend shouldn't be impossible.

Swsusp approaches readiness

Posted Aug 11, 2003 16:50 UTC (Mon) by gswoods (guest, #37) [Link]

I've tried to use SWSUSP on both a Mitac 8170 laptop, and on a desktop. These are both Red Hat 9 systems, but using the vanilla 2.4.21 kernel source with SWSUSP/ACPI patches. It sort-of works. But I frequently run into problems where the amount of stuff to be written exceeds the swap space size (even though I've got 1GB of main memory and 2GB of swap). I've also had problems with resuming; sometimes it just silently crashes and reboots during an attempted resume. However, the ACPI part does work, in that I can run acpid and configure it to recognize when I push the sleep key and run the hibernate script. When it works, it's great (although a bit slow as Jon noted). Unfortunately, I find I can't depend on it, as it often fails to work for no apparent reason.

Swsusp approaches readiness

Posted Aug 14, 2003 17:17 UTC (Thu) by lothar (subscriber, #14052) [Link]

It is really the time for the big Linux distributors like Red Hat or SuSE to bring support for laptops. If these vendors (who do huge patches on their kernels anyway) would support SW-SUP, a large user base would use and test it therefore make it more usful in a shorter time.

I own a DELL Inspiron 8500 running Red Hat Linux 9. It took me quite a while to get it to work with ACPI, as Red Hat provides nothing there. Without the work on Linux for Laptops I wouldn't have the simplest support probably.

Lothar

Copyright © 2003, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds