# FYI: nvidia-drivers-325.15 and gentoo-sources-3.11.0 patch

## username234

In case you haven't guessed, there's a small compatibility issue with nvidia-drivers-325.15 and gentoo-sources-3.11.0

I got the drivers to compile by making the following change.

```
--- kernel/nv-linux.h   2013-09-03 22:46:51.397145404 -0400

+++ kernel/nv-linux.h   2013-09-03 22:53:45.112478362 -0400

@@ -956,11 +956,15 @@ static inline int nv_execute_on_all_cpus

         *(mutex) = __mutex;                        \

     }

 #endif

 

 #if !defined(NV_VMWARE)

+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)

 #define NV_NUM_PHYSPAGES                num_physpages

+#else

+#define NV_NUM_PHYSPAGES                (get_num_physpages())

+#endif

 #define NV_GET_CURRENT_PROCESS()        current->tgid

 #define NV_IN_ATOMIC()                  in_atomic()

 #define NV_LOCAL_BH_DISABLE()           local_bh_disable()

 #define NV_LOCAL_BH_ENABLE()            local_bh_enable()

 #define NV_COPY_TO_USER(to, from, n)    copy_to_user(to, from, n)
```

No problems as of yet, but it's still early.  If I encounter anything I'll post to this thread.

Thanks.

----------

## n00berry

x11-drivers/nvidia-drivers-325.15 failed to emerge against sys-kernel/gentoo-sources-3.11.0.

There is a patch available on the nvidia forums:

https://devtalk.nvidia.com/default/topic/549532/linux/linux-3-10-solved-3-11-solved-incompatibility-in-function-lsquo-nv_i2c_del_adapter-rsquo-error/2/

The patch is on pastebin, here:

http://pastebin.com/qV30u23p

After applying the patch, x11-drivers/nvidia-drivers-325.15 emerges successfully.

----------

## ulenrich

https://bugs.gentoo.org/show_bug.cgi?id=482168

----------

## Fred Krogh

Note this patch should be stored in *Quote:*   

> /etc/portage/patches/x11-drivers/nvidia-drivers-325.15/Linux-3.11.patch

 and then emerge nvidia-drivers.  Seems to be working for me too.

----------

## Fred Krogh

Whoops!  I was assuming this patch was the same as the one I used.  This one does not compile for me.  The one I used is cited at https://forums.gentoo.org/viewtopic-t-969118.html.Last edited by Fred Krogh on Wed Sep 04, 2013 3:43 pm; edited 2 times in total

----------

## username234

 *Fred Krogh wrote:*   

> Note this patch should be stored in *Quote:*   /etc/portage/patches/x11-drivers/nvidia-drivers-325.15/Linux-3.11.patch and then emerge nvidia-drivers.  Seems to be working for me too.

 Interesting.  I didn't test that method, but I thought it would have worked from there, too.  I'll have to take a look at my local repository and see where I put the epatch line in the ebuild. *Fred Krogh wrote:*   

> Whoops! I was assuming this patch was the same as the one I used. This one does not compile for me. The one I used is cited at https://forums.gentoo.org/viewtopic-t-969118.html.

 I didn't find any patches when I looked around yesterday, that's why I posted here.  I also get a 404 error when I click the link.

----------

## Fred Krogh

Sorry, I fixed the link, it had a "." at the end.

----------

## Xywa

 *n00berry wrote:*   

> x11-drivers/nvidia-drivers-325.15 failed to emerge against sys-kernel/gentoo-sources-3.11.0.
> 
> There is a patch available on the nvidia forums:
> 
> https://devtalk.nvidia.com/default/topic/549532/linux/linux-3-10-solved-3-11-solved-incompatibility-in-function-lsquo-nv_i2c_del_adapter-rsquo-error/2/
> ...

 

How to apply this patch?

----------

## enkil

 *Xywa wrote:*   

> How to apply this patch?

 

Put it in /etc/portage/patches/x11-drivers/nvidia-drivers-325.15

----------

## gerard27

I upgraded gentoo-sources from 3.10.5-gentoo-r1 to 3.11.1.

I can't get nvidia-325-15 to emerge.

Tried the patch in Xywa's post and uhlenrich's.

Here's the last part of /var/log/portage/x11-drivers/nvidia-drivers-325-15

```

In file included from /usr/src/linux-3.11.1-gentoo/arch/x86/include/asm/uaccess.h:539:0,

                 from /usr/src/linux-3.11.1-gentoo/include/linux/poll.h:11,

                 from /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/nv-linux.h:97,

                 from /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/os-interface.c:15:

/usr/src/linux-3.11.1-gentoo/arch/x86/include/asm/uaccess_64.h: In function 'copy_from_user':

/usr/src/linux-3.11.1-gentoo/arch/x86/include/asm/uaccess_64.h:62:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

  x86_64-pc-linux-gnu-gcc -Wp,-MD,/var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/.os-usermap.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include -I/usr/src/linux-3.11.1-gentoo/arch/x86/include -Iarch/x86/include/generated  -I/usr/src/linux-3.11.1-gentoo/include -Iinclude -I/usr/src/linux-3.11.1-gentoo/arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I/usr/src/linux-3.11.1-gentoo/include/uapi -Iinclude/generated/uapi -include /usr/src/linux-3.11.1-gentoo/include/linux/kconfig.h   -I/var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -Wno-maybe-uninitialized -m64 -march=k8 -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -Wframe-larger-than=2048 -fno-stack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -DCC_HAVE_ASM_GOTO   -I/var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel -Wall -MD -Wsign-compare -Wno-cast-qual -Wno-error -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"325.15\" -Wno-unused-function -Wuninitialized -mno-red-zone -mcmodel=kernel -UDEBUG -U_DEBUG -DNDEBUG -D__linux__  -DMODULE  -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(os_usermap)"  -D"KBUILD_MODNAME=KBUILD_STR(nvidia)" -c -o /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/os-usermap.o /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/os-usermap.c

In file included from /usr/src/linux-3.11.1-gentoo/include/linux/kernel.h:10:0,

                 from /usr/src/linux-3.11.1-gentoo/include/linux/sched.h:15,

                 from /usr/src/linux-3.11.1-gentoo/include/linux/utsname.h:5,

                 from /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/nv-linux.h:44,

                 from /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/os-usermap.c:15:

/usr/src/linux-3.11.1-gentoo/include/linux/bitops.h: In function 'hweight_long':

/usr/src/linux-3.11.1-gentoo/include/linux/bitops.h:66:41: warning: signed and unsigned type in conditional expression [-Wsign-compare]

In file included from /usr/src/linux-3.11.1-gentoo/arch/x86/include/asm/uaccess.h:539:0,

                 from /usr/src/linux-3.11.1-gentoo/include/linux/poll.h:11,

                 from /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/nv-linux.h:97,

                 from /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/os-registry.c:15:

/usr/src/linux-3.11.1-gentoo/arch/x86/include/asm/uaccess_64.h: In function 'copy_from_user':

/usr/src/linux-3.11.1-gentoo/arch/x86/include/asm/uaccess_64.h:62:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

In file included from /usr/src/linux-3.11.1-gentoo/arch/x86/include/asm/uaccess.h:539:0,

                 from /usr/src/linux-3.11.1-gentoo/include/linux/poll.h:11,

                 from /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/nv-linux.h:97,

                 from /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/os-smp.c:15:

/usr/src/linux-3.11.1-gentoo/arch/x86/include/asm/uaccess_64.h: In function 'copy_from_user':

/usr/src/linux-3.11.1-gentoo/arch/x86/include/asm/uaccess_64.h:62:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

/var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/os-interface.c: In function 'os_get_system_memory_size':

/var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/os-interface.c:244:21: error: 'num_physpages' undeclared (first use in this function)

/var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/os-interface.c:244:21: note: each undeclared identifier is reported only once for each function it appears in

In file included from /usr/src/linux-3.11.1-gentoo/arch/x86/include/asm/cpumask.h:4:0,

                 from /usr/src/linux-3.11.1-gentoo/arch/x86/include/asm/msr.h:10,

                 from /usr/src/linux-3.11.1-gentoo/arch/x86/include/asm/processor.h:20,

                 from /usr/src/linux-3.11.1-gentoo/arch/x86/include/asm/thread_info.h:22,

                 from /usr/src/linux-3.11.1-gentoo/include/linux/thread_info.h:54,

                 from /usr/src/linux-3.11.1-gentoo/include/linux/preempt.h:9,

                 from /usr/src/linux-3.11.1-gentoo/include/linux/spinlock.h:50,

                 from /usr/src/linux-3.11.1-gentoo/include/linux/seqlock.h:29,

                 from /usr/src/linux-3.11.1-gentoo/include/linux/time.h:5,

                 from /usr/src/linux-3.11.1-gentoo/include/uapi/linux/timex.h:56,

                 from /usr/src/linux-3.11.1-gentoo/include/linux/timex.h:56,

                 from /usr/src/linux-3.11.1-gentoo/include/linux/sched.h:17,

                 from /usr/src/linux-3.11.1-gentoo/include/linux/utsname.h:5,

                 from /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/nv-linux.h:44,

                 from /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/os-usermap.c:15:

/usr/src/linux-3.11.1-gentoo/include/linux/cpumask.h: In function 'cpumask_parse':

/usr/src/linux-3.11.1-gentoo/include/linux/cpumask.h:603:26: warning: signed and unsigned type in conditional expression [-Wsign-compare]

/var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/os-interface.c:245:1: warning: control reaches end of non-void function [-Wreturn-type]

make[3]: *** [/var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/os-interface.o] Error 1

make[3]: *** Waiting for unfinished jobs....

In file included from /usr/src/linux-3.11.1-gentoo/arch/x86/include/asm/uaccess.h:539:0,

                 from /usr/src/linux-3.11.1-gentoo/include/linux/poll.h:11,

                 from /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/nv-linux.h:97,

                 from /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel/os-usermap.c:15:

/usr/src/linux-3.11.1-gentoo/arch/x86/include/asm/uaccess_64.h: In function 'copy_from_user':

/usr/src/linux-3.11.1-gentoo/arch/x86/include/asm/uaccess_64.h:62:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

make[2]: *** [_module_/var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel] Error 2

make[1]: *** [sub-make] Error 2

make[1]: Leaving directory `/usr/src/linux-3.11.1-gentoo'

NVIDIA: left KBUILD.

nvidia.ko failed to build!

make: *** [module] Error 1

 [31;01m*[0m ERROR: x11-drivers/nvidia-drivers-325.15::gentoo failed (compile phase):

 [31;01m*[0m   emake failed

 [31;01m*[0m 

 [31;01m*[0m If you need support, post the output of `emerge --info '=x11-drivers/nvidia-drivers-325.15::gentoo'`,

 [31;01m*[0m the complete build log and the output of `emerge -pqv '=x11-drivers/nvidia-drivers-325.15::gentoo'`.

 [31;01m*[0m The complete build log is located at '/var/log/portage/x11-drivers:nvidia-drivers-325.15:20130915-180650.log'.

 [31;01m*[0m For convenience, a symlink to the build log is located at '/var/tmp/portage/x11-drivers/nvidia-drivers-325.15/temp/build.log'.

 [31;01m*[0m The ebuild environment file is located at '/var/tmp/portage/x11-drivers/nvidia-drivers-325.15/temp/environment'.

 [31;01m*[0m Working directory: '/var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/kernel'

 [31;01m*[0m S: '/var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work/'

```

Looks to me like 3.11.1 has somthing different in the source.

Any help will be greatly appreciated.

Gerard.

----------

## DawgG

you just have to patch the patch  :wink: 

since it is just one character i think it's not necessary to write a patch for that.

for 3.11.0 there is one line in the patch it that reads:

```
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
```

i changed the line to

```
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 1)
```

and nvidia-drivers emerged successfully on 3.11.1 on my box.

GOOD LUCK!

----------

## ulenrich

There is a slightly better patch than my own

which works well with minor linux-3.10 also:

https://forums.gentoo.org/viewtopic-t-969332-start-0-postdays-0-postorder-asc-highlight-.html

----------

## gerard27

Thanks for the replies.

Problem has been solved.

What happened was I forgot to put the .patch extension on the files.

This part of portage doc should mention that patch files should have the .patch extension.

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=3&chap=6#doc_chap6

Gerard.

----------

## tomk

Merged from here.

----------

