Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 98859 - Patch to make nvidia-kernel work with software suspend 2
Summary: Patch to make nvidia-kernel work with software suspend 2
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: X11 External Driver Maintainers
Keywords: Inclusion
Depends on:
Reported: 2005-07-13 02:26 UTC by Gerry
Modified: 2006-11-09 02:16 UTC (History)
7 users (show)

See Also:
Package list:
Runtime testing required: ---

nvidia-kernel-swsusp-fix.patch (nvidia-kernel-swsusp-fix.patch,392 bytes, patch)
2005-07-13 02:28 UTC, Gerry
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gerry 2005-07-13 02:26:18 UTC
The nvidia kernel driver as-is currently doesn't work with software suspend (as
used in sys-kernel/suspend2-sources).  I found the solution to this problem in a
link at the software suspend 2 howto at the wiki
(, so I don't know why it
hasn't been reported here in the bugzilla yet (at least I couldn't find any
dupes -- bug 67574 is something else).  The link leads to, which describes the
patch needed to nv.c.  I did this and tested it with nvidia-kernel 1.0.7667, and
it worked great (lucky the line numbers were identical..).  I'll attach a patch.

Reproducible: Always
Steps to Reproduce:
1. Remove nvidia from /etc/hibernate/blacklisted-modules
2. hibernate

Actual Results:  
System hangs on resume (without the patch).

Expected Results:  
Resume =).  With the patch, this works perfectly.
Comment 1 Gerry 2005-07-13 02:28:48 UTC
Created attachment 63298 [details, diff]

This patch was made using nvidia-kernel 1.0.7667, but it should work with
1.0.7664 and possibly some older versions as well.
Comment 2 Roger 2005-07-21 21:05:40 UTC
This patch can probably be easily included into the main nvidia-kernel ebuild by
simply doing something like the following:

if kernel = suspend2 ; then
    einfo "Applying patch for Suspend2"
    epatch ${NV_PATCH_PREFIX//7167}-nv.patch

The function "if" should check to see if /usr/src/linux-2.6.12-suspend2* sources
are being used.  If so, patch with the above patch.

(I think nvidia-kernel 1.0.7667 needs an updated patch - I noticed the offset is
quite a bit on the newer version of nv.c)

(This patch is going to be quite popular with laptop users because it actually
works now!)
Comment 3 Roger 2005-07-21 22:01:44 UTC
Here's something that should work:

	# My patch to make nvidia play nice with SWSUSP2
	if [ ${KV_EXTRA} = "-suspend2-r3" ] ; then
		einfo "Applying patch for Suspend2"
		epatch ${NV_PATCH_PREFIX//7167}-nv.patch
		einfo "NOT applying patch for Suspend2"

(Customize as needed :-)

To create this patch:

# ebuild
/usr/local/portage/media-video/nvidia-kernel/nvidia-kernel-1.0.7667.ebuild digest

# ebuild
/usr/local/portage/media-video/nvidia-kernel/nvidia-kernel-1.0.7667.ebuild unpack

# cd

# /usr/bin/diff -uprN nv/nv.c nv/ >
Comment 4 Roger 2005-07-21 22:46:29 UTC
Ok.  Tested several times here and suspending X with nvidia works now.

Almost forgot, before applying this patch in the ebuild, we should check for AGP
not being set!

Do something like this:

pkg_setup() {

(I've yet to test this bit of scripting.  I've also seen this test function
simply in the head of the ebuild with all the rest of the variables.  As I
collect notes here, and if nobody gets around to completing this stuff, I'll
eventually gather enough info to attach a complete ebuild. :-)
Comment 5 Roger 2005-07-21 23:19:27 UTC
CONFIG_CHECK="!AGP" only seems to be working within the top (variable
definitions) of the ebuild.

When I try to stick the CONFIG_CHECK within the if/then KV_EXTRA check, it
doesn't work.
Comment 6 Jan Girlich 2005-10-09 11:06:44 UTC
Did anyone made a upstream bug-report?
Like writing a mail to
If not, I'll do so after I confirmed it working.
But this might take a while, 'cause I'm very busy.
Comment 7 Pal Illes 2006-02-12 06:55:06 UTC
I just installed gentoo's suspend2 and latest nvidia driver 8178 for my nv 6600. The driver's ebuild contains the required patches to make it work. Still if using NVidia driver's AGPGART I am unable to resume as it freezes. With kernel's AGPGART its working fine (except my vga console is garbled on resume) X is usable. (Still I have to use driver's internal AGPGART because kernel's AGPGART is not stabile and is too slow compared to internal.)

So anyone else got a solution?

Mobo: ABIT NF7
AMD 2500+
kernel 2.6.15-suspend2-r4
msi nx6600 + nvidia driver 8178 installed with latest ebuild.
Comment 8 Roger 2006-02-16 09:24:04 UTC
Typical of Nvidia's driver?

I haven't used suspend for quite some time since I've created this ebuild.

I might dable with the suspend with my Geforce2 Mobile when I get some free time to see how things have progressed.
Comment 9 Pal Illes 2006-02-16 09:41:32 UTC
I've tried it with my new Nvidia 6800. The same result. Using NVagp freezes the system.
Comment 10 Roger 2006-02-17 22:04:43 UTC
( Sorry.  Eek.  Looks like Gerry created this one. :-/ )
Comment 11 Roger 2006-03-19 15:24:16 UTC
Just tried Suspend2 with my laptop.

I believe I'm using sys-kernel/suspend2-sources-2.6.15-r8 and 

$ fgrep /usr/portage/media-video/nvidia-kernel -r -e "PM_SUSPEND_STANDBY" still shows this patch has yet to be integrated.

I've personnally tried Suspend2 on my laptop and all works flawlessly.  I can even disable AGP with the nvidia module still loaded (un-blacklist nvidia) and be able to easily stop xdm before suspend without almost any problems.

However, if I try suspending while xdm is started, suspend2 hangs just prior to turning off.  I'm guessing this is because this patch is not integrated yet?

Well, I'm off shortly to manually hack this piece of code into the ebuild within my /usr/local/portage.  I'll report back with my results.
Comment 12 Roger 2006-03-19 21:33:42 UTC
Rumor has it, this patch is no longer needed with nvidia-kernel version 8178.
(From what I see too, nv.c SUSPEND functions have been rewritten.) 

noapic might or might not be needed w/i lilo.conf / grub.conf

Comment 13 Jakub Moc (RETIRED) gentoo-dev 2006-11-09 02:16:54 UTC
(In reply to comment #12)
> Rumor has it, this patch is no longer needed with nvidia-kernel version 8178.

Closing an obsolete bug, the patch is irrelevant for uptodate nvidia-drivers (>=1.0.8756 per suspend2 wiki).