# Nvidia and software suspend 2

## Maranza

I'm trying to make this software suspend thing work, it looks very interesting. basically it's working: if i kill x and unload the nvidia and emu10k1 modules manually, resuming works and i can load them back into a fully working operating system. But i wouldn't get much of a speed increase by leaving X out of the suspension/resume cycle. Also X is loaded through xdm (kdm really, but here in gentoo the xdm service handles all), and the hibernate script can't shut it down properly: if i put xdm as a service to restart in hibernate.conf and blacklist the nvidia kernel module, on resuming it freezes on the nvidia logo. Anyone had a similar problem? Anyway, i've found a few solutions for the problem:

1. the case PM_SET_WAKEUP: hack looks very dirty to me. according to the wiki, it has to be inserted after line 3677 in nv.c, but i'm splitting up a function  declaration here! i tried anyway, but i've got syntax errors of course.

2. i found another patch on the forums that might work.. but this one requires NvAgp to be set to 0, which means disabling agp support. I don't play 3d games, i think the most agp-aware application that i run is xcompmgr.. will i experience slowdowns without agp?

Running a 2.6.10 kernel with the 2.1.5.14 swsusp2 patch

----------

## yoyo

I'm currently using swsup2 with nvidia (with X and composite enabled).

Answers are in the swsup FAQ Section 4 Compatibility issues (parts 6 & 7) : http://softwaresuspend.berlios.de/FAQ-4.html#ss4.6.

To make it works, you have to use nvagp (nvidia agp support) by disabling agpgart in your kernel config.

Don't forget to re-emerge nvidia-kernel once you have your new kernel compiled.

After reboot, you've got to have something like this : 

```
cat /proc/driver/nvidia/agp/status

Status:          Enabled

Driver:          NVIDIA  <--- LOOK HERE (it's not agpgart)
```

With this, swsup may works (comment nvidia in the hibernate blacklist file : "/etc/hibernate/blacklisted-modules").

Maybe you have to disable FW and SBA in your "/etc/modules.d/nvidia" (don't forget to run "modules-update" after that modification). My Xorg locks if I let them on.   :Sad: 

The emu10k1 modules seems to be blacklisted too. You can try to comment the line in "blacklisted-modules" file and check if it works.

If it doesn't, uncomment the line and add in the "/etc/hibernate/hibernate.conf" file something like : 

```
UnloadModules emu10k1
```

If emu10k1 is in your "/etc/modules.autoload.D/kernel-2.6" uncomment line "GentooModulesAutoload yes"; the emu10k1 will be load on reboot.

If it is loaded by alsasound rc-script you can add 

```
RestartServices alsasound
```

 in "/etc/hibernate/hibernate.conf".

Hope this helps !

EDIT : Imho you may disable xdm on startup ("rc-update del xdm") for testing nvidia changes (a little "startx" is sufficient to check if your config is OK).

EDIT2 : Don't forget to edit your xorg.conf to change the "NvAGP" option (device section). Put it to "3" will be a good solution (try to use agpgart if present then use nvagp; with that you can have different kernel config without X problems).

----------

## Maranza

ok, i've cut off the agpgart support from the kernel and added nvagp... it's working nicely  :Smile: 

i've still got a couple of problems tough:

1. is the image invalidated after each resume? i mean, can i safely try to resume an image even if i haven't suspended last time (swsusp2 will then skip resuming)?

2. the console is blank, would help using a framebuffer console?

3. after a few seconds, the video output goes crazy: the video is shifted of about 40% the lenght of my monitor. The part that would go out of the screen   appears on the other side of the screen. Switching to the (blank) console and back to X solves the problem, but it's annoying nonetheless..

anyway, thank you  :Smile: 

----------

## yoyo

 *Maranza wrote:*   

> ok, i've cut off the agpgart support from the kernel and added nvagp... it's working nicely  

   :Cool: 

 *Maranza wrote:*   

> i've still got a couple of problems tough:
> 
> 1. is the image invalidated after each resume? i mean, can i safely try to resume an image even if i haven't suspended last time (swsusp2 will then skip resuming)?

 I'm not sure but I think it's possible if the image is still saved. Check in hibernate config files. And of course in swsusp FAQ.

 *Maranza wrote:*   

> 2. the console is blank, would help using a framebuffer console?
> 
> 3. after a few seconds, the video output goes crazy: the video is shifted of about 40% the lenght of my monitor. The part that would go out of the screen   appears on the other side of the screen. Switching to the (blank) console and back to X solves the problem, but it's annoying nonetheless..

 I don't have these problems here; so sorry to rtfm  :Rolling Eyes:   :

- FAQ : http://softwaresuspend.berlios.de/FAQ.html

- bootsplash : http://softwaresuspend.berlios.de/options.html

- gentoo wiki : http://gentoo-wiki.com/HOWTO_Software_Suspend_v2

----------

## Maranza

 *Quote:*   

> I'm not sure but I think it's possible if the image is still saved. Check in hibernate config files. And of course in swsusp FAQ

 

If you don't know that, how do you use swsusp2 on a regular basis? do you pass noresume2 (ore resume2=swap:/dev/hdx) to the kernel at every boot?

----------

## yoyo

 *Maranza wrote:*   

> If you don't know that, how do you use swsusp2 on a regular basis? do you pass noresume2 (ore resume2=swap:/dev/hdx) to the kernel at every boot?

 I pass "resume2=swap:/dev/hdx" at every boot.

If there's no image stored, kernel starts like if this option doesn't exist.

In case of problems, I use  the edit function of grub (  :Very Happy:  ) to modify my kernel command line and add the "noresume2" argument.

Then, swapoff, mkswap and swapon to erase the bad stored image and have a clean swap space (I'm not sure you have to do all this stuff).

----------

## Maranza

 *Quote:*   

> 
> 
> If there's no image stored, kernel starts like if this option doesn't exist. 
> 
> 

 

Then you DID know the answer to my question  :Wink: 

thanks

I'm already appending resume=swap:/dev/hdx through lilo, but i feared booting without noresume2 when booting a non-suspended system (i don't suspend every time). you're implying that this is safe?

----------

## yoyo

 *Maranza wrote:*   

>  *Quote:*   
> 
> If there's no image stored, kernel starts like if this option doesn't exist. 
> 
>  
> ...

 Misunderstood !!!   :Mr. Green: 

I thought that you want to resume an old saved suspended session :  *Maranza wrote:*   

> i mean, can i safely try to resume an image even if i haven't suspended last time

   :Rolling Eyes: 

 *Maranza wrote:*   

> I'm already appending resume=swap:/dev/hdx through lilo, but i feared booting without noresume2 when booting a non-suspended system (i don't suspend every time). you're implying that this is safe?

 I've put the "resume=:/dev/hdx" kernel argument on every grub.conf kernel line (without noresume of course).

Booting without image stored (non-suspended system) never complained here ...

I think 2 big problems can occurs with swsup2 :

1 - system has been suspended but on next boot kernel doesn't have the swsusp feature : this can produce a corruption swap. So you have to swapoff + mkswap + swapon before your system needs swap.

2 - system has been suspended and rebooted on an other OS which can access to suspended partitions (example : fat32 partition for Linux/windows common datas). In this case, suspend image and real system aren't the same and I think you have to use the noresume2 argument to boot again on Linux ...

So you may have to have a noresume2 entry on your lilo.conf (no need with grub : edit function is really a great feature) ...

----------

## niin

I got a huge problem with swsuspend2 in X.

I followed what you said :

- I de-activated agpgart and re-emerged nvidia to use the NvAGP driver

- I configure xorg.conf as well

- I uncommented the unload nvidia module in the blacklisted-modules file

- I de-activated FW and SBA in the /etc/modules.d/nvidia

But still my computer can't store the image and freeze, while my screen has been shut down. So my monitor is off but my computer stays on undefinitely ; when i reboot (with reset button), it does a usual boot.

nb : it happens only in X ; when i'm still in console, the hibernate works well.

----------

## pennac

Good news, I have finally managed to get suspend2 works with nvidia module.

I have tried a couple of setup, but here's the last one which made it possible.

First, I did it with this kernel version :

```
sys-kernel/gentoo-sources-2.6.16-r2
```

this suspend2 version :

```
suspend2-2.2.4-for-2.6.16
```

and this nvidia-kernel module version :

```
media-video/nvidia-kernel-1.0.8756
```

Now, here's the hibernate options i had to tweak, which can be found in /etc/hibernate/hibernate.conf:

```
SwitchToTextMode yes

ProcSetting extra_pages_allowance 7500

UnloadBlacklistedModules yes

LoadModules auto
```

The specified ProcSetting was reported to fix problems with the ATI fglrx video driver, but hibernate could not suspend without it on my laptop. Here's the error it was reporting :

```
Pageset1 has grown by 353 pages. Only 100 growth is allowed for!
```

Setting the value to 7500 fixed this problem.

To skip nvidia unloading, i had to comment out the nvidia line in the /etc/hibernate/blacklisted-modules file.

I have completly removed agpart supports from the kernel and added the following option to /etc/X11/xorg.conf

```
Section "Device"

   Driver "nvidia"

   ...

   Option NvAGP "1"

   ...

EndSection
```

Here's some stats about the laptop for google search :

```
Toshiba M40

nVidia Corporation NV43 [GeForce Go 6600]

2.6.16-gentoo
```

Hibernate, cpufreq and sata suspend now make this laptop very interesting with linux.

Hope this can help some of you.

----------

## no4b

I can't get suspend2 working with nvidia (geforce4 mx). After resume I always see blackscreen, the machine (it's desktop pc, not laptop) seems to be hanged. I do not have agpgart in kernel/module. I do not use framebuffer. "SwitchToTextMode yes" does not help. I dunno how to fix it ;>

----------

## pennac

 *no4b wrote:*   

> I can't get suspend2 working with nvidia (geforce4 mx). 

 

What does /var/log/hibernate.log have to say about its operation ?

Did you try to hibernate without having Xorg running and nvidia module unloaded ?

----------

## no4b

```
Starting suspend at pi± kwi 14 00:35:26 CEST 2006

hibernate: [01] Executing CheckLastResume ...

hibernate: [01] Executing LockFileGet ...

hibernate: [01] Executing NewKernelFileCheck ...

hibernate: [10] Executing EnsureSwsusp2Capable ...

hibernate: [50] Executing FilesystemsUnmount ...

Unmounting /home/abaddon/dane ...

Unmounting /mnt/c ...

hibernate: [89] Executing SaveKernelModprobe ...

hibernate: [91] Executing ModulesUnloadBlacklist ...

hibernate: [97] Executing ChangeToSwsuspVT ...

hibernate: [98] Executing Swsusp2ConfigSet ...

hibernate: [99] Executing DoSwsusp2 ...

hibernate: Activating suspend ...

hibernate: [97] Executing ChangeFromSwsuspVT ...

hibernate: [91] Executing GentooModulesAutoload ...

Loading modules listed /etc/modules.autoload.d/kernel-2.6

Loading bttv

Loading ip_conntrack_ftp

hibernate: [89] Executing RestoreKernelModprobe ...

hibernate: [70] Executing ClockRestore ...

hibernate: [20] Executing MiscLaunchAuxFunc1 ...

Executing mount /home/abaddon/dane...

hibernate: [01] Executing NoteLastResume ...

hibernate: [01] Executing LockFilePut ...

Resumed at pi± kwi 14 00:36:11 CEST 2006

```

 *Quote:*   

> Did you try to hibernate without having Xorg running and nvidia module unloaded ?

 

Yes, I did. The pure console hibernates ok (xorg + nv instead of nvidia too).

----------

## pennac

 *no4b wrote:*   

> Yes, I did. The pure console hibernates ok (xorg + nv instead of nvidia too).

 

I forgot to mention that i had to emerge this version of nvidia-kernel before any successful hibernation :

```
media-video/nvidia-kernel-1.0.8756
```

It seems that you can't resume, but did your get through the full suspend, having the computer shut down ?

If so, when resuming, did you try to switch to console with CTRL-ALT-F1 ? I'm asking because on my laptop, when resuming, the screen goes black for a while before finally resuming to X.

Does the previous "dmesg" output tell you something strange after a successful reboot ?

----------

## XioXouS

no4b,

I was having similar problems where I could suspend in text mode but X would hang with a black screen on resume.  I found out today that I had to disable AGP entirely.  ie: in xorg.conf add 

```
"Option" "NvAGP" "0"
```

 under the Device subsection.  You could always run X with AGP disabled most of the time and then reload it with AGP turned on whenever you wanted to play games.  Kind of annoying, but it works.

----------

## Phlogiston

Hmm same problem here, is there an other solution for this? I'd like to use suspend2 + nvidia+ intel agpgart.

----------

## badgers

 *pennac wrote:*   

>  *no4b wrote:*   Yes, I did. The pure console hibernates ok (xorg + nv instead of nvidia too). 
> 
> I forgot to mention that i had to emerge this version of nvidia-kernel before any successful hibernation :
> 
> ```
> ...

 

My suspend to ram woks with the console. How do I use NV instead of Nvidia?

I followed the howto for Nvidia since I have a GF3 Ti

If I have to re-emerge Xorg that will take a whole day....

thanks

----------

## badgers

did the format of the hibernate script config files change?

I don't seem to have things the way that you have

```

DavidCPU linux # eix suspend

[I] sys-apps/suspend2-userui

     Available versions:  0.6.3-r1 0.6.4 0.6.4-r1

     Installed:           0.6.4-r1

     Homepage:            http://www.suspend2.net

     Description:         User Interface for Software Suspend 2

DavidCPU linux # cd /etc/hibernate/

DavidCPU hibernate # ls

total 44K

drwxr-xr-x  3 root root 4.0K Sep 19 05:51 .

drwxr-xr-x 86 root root 8.0K Sep 25 15:16 ..

-rw-r--r--  1 root root 1.8K Sep 25 15:07 blacklisted-modules

-rw-r--r--  1 root root 3.2K Sep 25 14:47 common.conf

-rw-r--r--  1 root root  345 Sep 19 05:51 disk.conf

-rw-r--r--  1 root root  542 Sep 19 05:51 hibernate.conf

-rw-r--r--  1 root root  631 Sep 20 06:57 ram.conf

drwxr-xr-x  2 root root   47 Sep 19 05:51 scriptlets.d

-rw-r--r--  1 root root 1.3K Sep 19 08:04 suspend2.conf

-rw-r--r--  1 root root  468 Sep 19 08:23 ususpend.conf

```

thanks

----------

## badgers

I have it working now.

I just issue the hibernate command and then push the power button for it to wake up.

is it possible to make it wake up when I hit the keyboard or move the mouse.

Idealy I would like it to WOL, but that is not a big issue.

thanks for this thread.

----------

## badgers

I have run glxgears and I get 19 FPS with a GF3 ti200

does that seem really low?

----------

## Thesee

I wanted to thank all of you for this post because I finally got this hibernate working (it was the NvAgp to be set to 0 that did the trick).

And therefore my question: any news about this? Will we always have to remove the AGP to hibernate?

----------

## stalker

I would like to re-iterate the fact that to get a nvidia chip to suspend with X that you need to have agpgart not installed. Or that is what I believed, it seems that having NvAGP set to 0 has the same effect, or not loading agpgart.

I would like to disagree with yoyo about setting NvAGP to 3. I told Thesee to set it to 1, instead of 3, and his system was them able to hibernate properly, and still have agp functionality.

The issue is that "3" tries to load agpgart first before attempting to use nvidia's agp. So if agpgart is on the system, then it will be loaded and then it won't hibernate. Using "1" skips that and ensures that nvidia's agp is loaded. Which is what allows us to continue.

And I should also recap that nvidia's binary driver (the later the better) is what is being used here, I don't think people should be using the NV driver instead of Nvidia's with hibernation. I'm not saying it won't work, I'm just saying that the results aren't as prevalent.

----------

## nejiron

Just wanted to let everyone know that I got it working fine with ~amd64 keywords and the following setup:

Linux 2.6.22-kamikaze6 #4 PREEMPT Wed Sep 5 19:41:25 EDT 2007 x86_64 AMD Athlon(tm) 64 Processor 3400+ AuthenticAMD GNU/Linux

VGA compatible controller: nVidia Corporation NV34 [GeForce FX 5200] (rev a1) w/ x11-drivers/nvidia-drivers-100.14.11 

Here is my hibernate.conf: 

FBSplash on

FBSplashTheme suspend2

ProcSetting full_pageset2 1

ProcSetting extra_pages_allowance 0

UnloadBlacklistedModules yes

LoadModules auto

GentooModulesAutoload yes

SwitchToTextMode yes

UseDummyXServer yes

(Note: I also have the framebuffer splash on and it works with hibernate)

and in xorg.conf I have:

Option      "NvAGP" "1"

Hope this helps someone...

----------

