Title photo
frugal technology, simple living and guerrilla large-appliance repair
Thu, 27 Nov 2014

The secret to successful suspend/resume in Linux on the HP Pavilion g6-2210us

After a year and half, I've finally cracked suspend/resume in Linux on the HP Pavilion g6-2210us laptop (AMD A4-4300M APU with AMD Radeon HD 7420G graphics) with the open-source Radeon driver.

I've been able to successfully suspend/resume for some time on this laptop with the closed-source AMD Catalyst driver, but two things have prompted me to give that driver up for the open Radeon driver:

1) AMD Catalyst hasn't been packaged for Fedora since Fedora 19, and we're about to see Fedora 21 released with no indication that things will change. There are at least a couple of workarounds that will get Catalyst/fglrx on your Fedora 20 system, both of which I've written about at length, but I'm tired of doing them. While the Catalyst/fglrx experience is somewhat smoother on distributions that are serious about packaging the driver (Debian and Ubuntu come to mind), breakage is inevitable on fast-moving distros like Fedora that get new Linux kernels all the time.

2) While AMD Catalyst allows the laptop to run cooler at idle (I'm pretty sure it runs at a similar temperature under load), the quality of video -- actual videos in applications like VLC, that is -- is better with the latest Radeon driver than with Catalyst. Briefly, when I'm watching something and the image is "moving," it breaks up horizontally in Catalyst, not at all in Radeon.

But suspend/resume trumps all. Having it with Catalyst kept me ... running Catalyst.

Now that I've cracked the code for successful suspend/resume without Catalyst, the infrequently updated, not-packaged-for-Fedora, closed-source driver is fading in my virtual rear-view mirror.

So how do you get suspend/resume working on this particular HP Pavilion g6 (or similarly equipped) laptop?

There are two changes you need to make in GRUB.

Test them by hitting the esc key early in the boot sequence to pause GRUB and adding them to your boot parameters. When you are sure they work, add them to your /etc/default/grub file and rebuild GRUB.

Note: From what little I understand, rebuilding GRUB in the GRUB 2 era is somewhat different for Fedora than it is in other distributions such as Debian and Ubuntu. For those distros (or others), look at the documentation (or helpful web pages) to determine exactly how you rebuild GRUB for your system. Or you can just modify /etc/default/grub and wait for your next kernel update, at which time GRUB will be rebuilt for you.

GRUB change No. 1: Add a "resume" line that points to your swap partition

Again, you can test this by pausing your boot sequence and modifying the boot line in GRUB

What you need here is a line something like this:

resume=/path/to/swap

Instead of "/path/to/swap," use the path to your actual swap partition. There is more than one way to figure out the path to your swap partition.

First, you can look in /etc/fstab. That's where I found the path/to/swap that I'm using now:

resume=/dev/mapper/fedora-swap

I get slightly different results from the other method, but it also works.

That second method is done in a terminal with the swapon command:

$ swapon -s
Filename                Type        Size    Used    Priority
/dev/dm-1

So on my Fedora system that uses LVM, I can choose either line: resume=/dev/mapper/fedora-swap or resume=/dev/dm-1. I am now using the "mapper" line, and it has never failed me.

GRUB Change No. 2. Add acpisleep=s3bios,s3_mode

I found this fix in a bug report to which I can't find the link. I think it was a Debian bug report (which I will link here if/when I find it.)

Wherever the fix came from (and thanks to those who provided it), for my recent AMD-running laptop, it works like butter.

Again, you can pair this acpi_sleep line with the resume line above, pausing the boot with esc and putting both in your main GRUB boot line.

You might not even need both. I think in Debian Jessie, for instance, you could get away with using only acpi_sleep=s3_bios,s3_mode and no resume line.

But in Fedora 20 on this hardware, you need both.

To make things completely clear, I add both of these to my GRUB boot line (and to the /etc/default/grub file when I know they work):

resume=/dev/mapper/fedora-swap acpi_sleep=s3_bios,s3_mode

When I add both of these to my GRUB boot line, I can successfully suspend/resume with my HP laptop in Fedora.

Note: Every once in awhile on resume, the laptop screen "lights up," but my desktop doesn't return. I think this has something to do with the screensaver. All I need to do in this case is close the lid, suspending the laptop again, then reopening it. I get my desktop back, and all is well.

Once you are convinced that adding these two parameters to your GRUB boot line allows you to successfully suspend/resume, it's time to make them "permanent." You do that by adding them to the GRUB_CMDLINE_LINUX section of the /etc/default/grub file. You need rootly privileges to do this. I generally use sudo, but you can just as easily su to root. As always use the text editor of your choice. Here I'm using gedit:

$ sudo gedit /etc/default/grub

I add the two parameters and save the file.

Here is what my /etc/default/grub looks like:

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_CMDLINE_LINUX="rd.lvm.lv=fedora/swap rd.md=0 rd.dm=0 $([ -x /usr/sbin/rhcrashkernel-param ] && /usr/sbin/rhcrashkernel-param || :) vconsole.keymap=us rd.lvm.lv=fedora/root rd.luks.uuid=luks-f87cd0dc-c2a5-4a18-913d-b0c9d0e7d18f rhgb resume=/dev/mapper/fedora-swap acpi_sleep=s3_bios,s3_mode quiet splash radeon.dpm=1"
GRUB_DISABLE_RECOVERY="true"
GRUB_THEME="/boot/grub2/themes/system/theme.txt"

Once you have saved your /etc/default/grub file with these two added parameters, you can rebuild GRUB as root. Note that this line is specific to Fedora installations with EFI; unless you're running a similar Fedora system, yours is very probably different, and you should consult the documentation or help pages for your distribution to successfully rebuild grub2:

# grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

This rebuilds the GRUB menu with our two little additions.

Note: For some reason, rebuilding the GRUB menu this way makes it looks a little different in Fedora than when the system rebuilds GRUB after a kernel update. However, the machine boots fine either way, and if you ARE running Fedora, it's only a matter of time before a new kernel is available to install via Yum, and the system will rebuild GRUB for you, complete with the two boot parameters that will continue allowing you to successfully suspend/resume laptops like mine.