# Patching nvidia-drivers-325.15 for kernel 3.11

## Jaglover

Just made a fresh install ... as usual, nvidia-drivers didn't build with new kernel. Didn't want to downgrade after spending an hour configuring my kernel. 

Found it on the net, works for me.

```
--- a/kernel/nv-linux.h

+++ b/kernel/nv-linux.h

@@ -957,7 +957,11 @@ static inline int nv_execute_on_all_cpus

 #endif

 

 #if !defined(NV_VMWARE)

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

+#define NV_NUM_PHYSPAGES                get_num_physpages()

+#else

 #define NV_NUM_PHYSPAGES                num_physpages

+#endif

 #define NV_GET_CURRENT_PROCESS()        current->tgid

 #define NV_IN_ATOMIC()                  in_atomic()

 #define NV_LOCAL_BH_DISABLE()           local_bh_disable()
```

----------

## ser666

helped, thanks

----------

## drescherjm

Worked for me as well. I created a file (with the contents above) in /etc/portage/x11-drivers/nvidia-drivers and the unmodified portage ebuild picked up the patch on the emerge (making use of epatch_user).

----------

## frank9999

It seems i´m doing something wrong, but i did not work for me.

When i save the above patch under /etc/portage/x11-drivers/nvidia-drivers as written by @drescherjm, it did not even get applied.

Then I saved the above patch as nv311.patch under /etc/portage/patches/x11-drivers/nvidia-drivers 

it now gets applied from portage.

But i get the following output:

```
***** nv311.patch *****

PWD: /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work

=======================

PATCH COMMAND:  patch -p0 -g0 -E --no-backup-if-mismatch  < '/etc/portage/patches//x11-drivers/nvidia-drivers/nv311.patch'

=======================

can't find file to patch at input line 3

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:

--------------------------

|--- a/kernel/nv-linux.h 

|+++ b/kernel/nv-linux.h 

--------------------------

No file to patch.  Skipping patch.

1 out of 1 hunk ignored

patch program exited with status 1

=======================

PATCH COMMAND:  patch -p1 -g0 -E --no-backup-if-mismatch  < '/etc/portage/patches//x11-drivers/nvidia-drivers/nv311.patch'

=======================

patching file kernel/nv-linux.h

Hunk #1 FAILED at 957.

1 out of 1 hunk FAILED -- saving rejects to file kernel/nv-linux.h.rej

patch program exited with status 1

=======================

PATCH COMMAND:  patch -p2 -g0 -E --no-backup-if-mismatch  < '/etc/portage/patches//x11-drivers/nvidia-drivers/nv311.patch'

=======================

can't find file to patch at input line 3

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:

--------------------------

|--- a/kernel/nv-linux.h 

|+++ b/kernel/nv-linux.h 

--------------------------

No file to patch.  Skipping patch.

1 out of 1 hunk ignored

patch program exited with status 1

=======================

PATCH COMMAND:  patch -p3 -g0 -E --no-backup-if-mismatch  < '/etc/portage/patches//x11-drivers/nvidia-drivers/nv311.patch'

=======================

can't find file to patch at input line 3

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:

--------------------------

|--- a/kernel/nv-linux.h 

|+++ b/kernel/nv-linux.h 

--------------------------

No file to patch.  Skipping patch.

1 out of 1 hunk ignored

patch program exited with status 1

=======================

PATCH COMMAND:  patch -p4 -g0 -E --no-backup-if-mismatch  < '/etc/portage/patches//x11-drivers/nvidia-drivers/nv311.patch'

=======================

can't find file to patch at input line 3

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:

--------------------------

|--- a/kernel/nv-linux.h 

|+++ b/kernel/nv-linux.h 

--------------------------

No file to patch.  Skipping patch.

1 out of 1 hunk ignored

patch program exited with status 1

```

Could someone please explain what i need to do, to get this working?

----------

## drescherjm

Oops. 

The correct path was 

/etc/portage/patches/x11-drivers/nvidia-drivers

```
jmd0 nvidia-drivers # cat /etc/portage/patches/x11-drivers/nvidia-drivers/linux-sources-3.11.patch

--- a/kernel/nv-linux.h

+++ b/kernel/nv-linux.h

@@ -957,7 +957,11 @@ static inline int nv_execute_on_all_cpus

 #endif

 #if !defined(NV_VMWARE)

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

+#define NV_NUM_PHYSPAGES                get_num_physpages()

+#else

 #define NV_NUM_PHYSPAGES                num_physpages

+#endif

 #define NV_GET_CURRENT_PROCESS()        current->tgid

 #define NV_IN_ATOMIC()                  in_atomic()

 #define NV_LOCAL_BH_DISABLE()           local_bh_disable()

```

----------

## albright

wouldn't work for me until (  :Embarassed:   ) I set the path

to 

```
/etc/portage/patches/x11-drivers/nvidia-drivers-325.15
```

----------

## billium

thanks drescherjm worked for me

----------

## sPHERE911

I get the following error trying to compile nvidia-325.15 with the aforementioned patch:

 *Quote:*   

> 
> 
> Applying user patches from /etc/portage/patches//x11-drivers/nvidia-drivers-325.15 ...
> 
>  *   linux-sources-3.11.patch ...
> ...

 

Also, I have no idea why it says /etc/portage/patches// with 2 slashes?

My patch looks like this:

 *Quote:*   

> 
> 
> --- a/kernel/nv-linux.h 
> 
> +++ b/kernel/nv-linux.h 
> ...

 

uname -r

 *Quote:*   

> 
> 
> 3.11.1-pf
> 
> 

 

----------

## drescherjm

The patch worked for me for pf-sources. 

```
>>> Verifying ebuild manifests

>>> Running pre-merge checks for x11-drivers/nvidia-drivers-325.15

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Found sources for kernel version:

 *     3.11.1-pf-jmd0

 * Gentoo supports kernels which are supported by NVIDIA

 * which are limited to the following kernels:

 * <sys-kernel/gentoo-sources-3.11

 * <sys-kernel/vanilla-sources-3.11

 *

 * You are free to utilize epatch_user to provide whatever

 * support you feel is appropriate, but will not receive

 * support as a result of those changes.

 *

 * Do not file a bug report about this.

 * Checking for suitable kernel configuration options...                                                   [ ok ]

>>> Emerging (1 of 1) x11-drivers/nvidia-drivers-325.15

 * NVIDIA-Linux-x86_64-325.15.run SHA256 SHA512 WHIRLPOOL size ;-) ...                                     [ ok ]

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Found sources for kernel version:

 *     3.11.1-pf-jmd0

>>> Unpacking source...

>>> Unpacking NVIDIA-Linux-x86_64-325.15.run to /auto/temp_data/var_tmp/portage/x11-drivers/nvidia-drivers-325.15/work

>>> Source unpacked in /auto/temp_data/var_tmp/portage/x11-drivers/nvidia-drivers-325.15/work

>>> Preparing source in /auto/temp_data/var_tmp/portage/x11-drivers/nvidia-drivers-325.15/work ...

 * Applying user patches from /etc/portage/patches//x11-drivers/nvidia-drivers ...

 *   linux-sources-3.11.patch ...                                                                          [ ok ]

 * Done with patching

>>> Source prepared.

>>> Configuring source in /auto/temp_data/var_tmp/portage/x11-drivers/nvidia-drivers-325.15/work ...

>>> Source configured.

>>> Compiling source in /auto/temp_data/var_tmp/portage/x11-drivers/nvidia-drivers-325.15/work ...

 * Preparing nvidia module

```

How did you save the patch file? I selected the text of the patch from this page in firefox and copied and pasted into nano and just saved the result.

John

----------

## sPHERE911

The same as you did. Do I have to make the patch executable or something?

And also, did you modify this line?

 *Quote:*   

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

 

----------

## albright

 *Quote:*   

> The same as you did. Do I have to make the patch executable or something? 

 

well ... worth a try

----------

## Jaglover

```
-#define NV_NUM_PHYSPAGES                num_physpages 

+#define NV_NUM_PHYSPAGES                get_num_physpages 
```

In fact, the only change needed is above, it will not work with older kernels any more of course. You can even do it by hand.

----------

## sPHERE911

Didnt help.

But this is the ouput of /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/temp/linux-sources-3.11.patch.out

 *Quote:*   

> 
> 
> ***** linux-sources-3.11.patch *****
> 
> PWD: /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work
> ...

 

----------

## albright

I see sphere911's patch has a blank first line. It's hard to

believe that is important but it is the only difference I

can see ...  :Confused: 

----------

## TomWij

 *sPHERE911 wrote:*   

> Didnt help.
> 
> But this is the ouput of /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/temp/linux-sources-3.11.patch.out
> 
>  *Quote:*   ***** linux-sources-3.11.patch *****
> ...

 

That is not the full output, this patch needs to apply with -p1 due to the a/ and b/ prefixes; so, we are missing details on why -p1 fails.

----------

## sPHERE911

Oh, sorry about that!

http://pastebin.com/tc6AAdxE

----------

## sPHERE911

Anyone?

----------

## darkphader

 *sPHERE911 wrote:*   

> Anyone?

 

Use this patch:

```
--- kernel/nv-linux.h.orig      2013-09-24 13:14:30.023159426 -0400

+++ kernel/nv-linux.h   2013-09-24 13:17:23.105718632 -0400

@@ -958,7 +958,11 @@

 #endif

 #if !defined(NV_VMWARE)

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

+#define NV_NUM_PHYSPAGES                get_num_physpages()

+#else

 #define NV_NUM_PHYSPAGES                num_physpages

+#endif

 #define NV_GET_CURRENT_PROCESS()        current->tgid

 #define NV_IN_ATOMIC()                  in_atomic()

 #define NV_LOCAL_BH_DISABLE()           local_bh_disable()
```

----------

## sPHERE911

Same problem with this patch..:(

----------

## croutch

I use this patch.

```
--- a/kernel/nv-linux.h

+++ b/kernel/nv-linux.h

@@ -957,7 +957,11 @@ static inline int nv_execute_on_all_cpus

 #endif

 

 #if !defined(NV_VMWARE)

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

+#define NV_NUM_PHYSPAGES                get_num_physpages()

+#else

 #define NV_NUM_PHYSPAGES                num_physpages

+#endif

 #define NV_GET_CURRENT_PROCESS()        current->tgid

 #define NV_IN_ATOMIC()                  in_atomic()

 #define NV_LOCAL_BH_DISABLE()           local_bh_disable() 
```

and i use this "guide" change the numbers to you liking - from user n00berry post 3 https://forums.gentoo.org/viewtopic-t-963230-highlight-patch+nvidia.html

Steps (as root): 

1) Copy contents of text into txt file: 

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

2) Convert version number to the relevant version: 

perl -pi -e "s/319.17/319.32/g" /etc/portage/patches/x11-drivers/nvidia-drivers/Linux-3.11.patch 

3) Make sure /etc/portage/bashrc contains the lines: 

post_src_unpack() { 

if type epatch_user >& /dev/null; then 

cd "${S}" 

epatch_user 

fi 

} 

4) Emerge: 

emerge -av x11-drivers/nvidia-drivers 

croutch

----------

## darkphader

 *sPHERE911 wrote:*   

> Same problem with this patch..:(

 

Odd. I had the same problem as you with the original posted patch but when I rolled my own it worked just fine. Have you examined the patch to make sure you overwrote the previous one and that it's the only patch in the /etc/portage/patches/x11-drivers/nvidia-drivers-325.15/ directory? And that you are indeed emerging nvidia-drivers-325.15?

Also make sure you don't have an /etc/portage/patches/x11-drivers/nvidia-drivers/ directory that you may pulling a previous patch from.

----------

## sPHERE911

Im beginning to think my kernel is the problem or something.

I have done all of the steps:

The only file(patch) I have, is in /etc/portage/patches/x11-drivers/nvidia-drivers-325.15/linux-3-11.patch

My /etc/portage/bashrc looks like this:

 *Quote:*   

> 
> 
> post_src_unpack() { 
> 
> if type epatch_user >& /dev/null; then 
> ...

 

And I have tried all of the different patches. Im thinking of changing to another kernel where I actually dont need the patch...

----------

## darkphader

 *sPHERE911 wrote:*   

> My /etc/portage/bashrc looks like this:
> 
> ```
> post_src_unpack() { 
> 
> ...

 

I don't have that file at all. It may be causing you a problem as I don't think it is needed for this ebuild.

----------

## sPHERE911

 *darkphader wrote:*   

>  *sPHERE911 wrote:*   My /etc/portage/bashrc looks like this:
> 
> ```
> post_src_unpack() { 
> 
> ...

 

Removed /etc/portage/bashrc, copied the patch a couple of posts above into /etc/portage/patches/x11-drivers/nvidia-drivers/Linux-3.11.patch

emerge -av nvidia-drivers

 *Quote:*   

> 
> 
> Failed Patch: Linux-3.11.patch !
> 
>  *  ( /etc/portage/patches//x11-drivers/nvidia-drivers/Linux-3.11.patch )
> ...

 

----------

## darkphader

/etc/portage/patches/x11-drivers/nvidia-drivers-325.15/ is the proper path. Mine is named kernel.patch but anything.patch should work just fine.

----------

## devzero_DE

Maybe there is something wrong with your copy & paste

You can download directly from pastebin with wget, there is a buton raw which gives you this:

http://pastebin.com/raw.php?i=qV30u23p

You can wget this link.

As sPHERE911 said, right path is /etc/portage/patches/x11-drivers/nvidia-drivers-325.15 for the patchfile (your path is also ok, but it is then for *ALL* nvidia-driver versions (it would be used also for upcoming release where its hopefully fixed)

Delete it in /etc/portage/patches/x11-drivers/nvidia-drivers and move to /etc/portage/patches/x11-drivers/nvidia-drivers-325.15

Maybe you have it put in both? That might also fail!

----------

## darkphader

 *devzero_DE wrote:*   

> http://pastebin.com/raw.php?i=qV30u23p

 

Oddly enough that version of the patch fails on my system (~amd64 & sys-apps/portage-2.2.7 & sys-devel/patch-2.7.1-r2). The version I posted works just fine (at least here).

----------

## sPHERE911

 *devzero_DE wrote:*   

> Maybe there is something wrong with your copy & paste
> 
> You can download directly from pastebin with wget, there is a buton raw which gives you this:
> 
> http://pastebin.com/raw.php?i=qV30u23p
> ...

 

It now fails at the compile phase, not prepare phase.

Im gonna try the previous patches again now

----------

## sPHERE911

FINALLY!

It now compiled and installed successfully. I guess it must have had something to do with the naming of the directories or the patch.

Anyway, it's now solved!

Thanks everyone!

As a long time Arch user, recently moved to Gentoo, I must say that the community here is much better (aswell as the distribution itself).

----------

## bwakkie

I check my dir and even /etc/portage/patches does not exist on my system... I just create it bottum up?

----------

## Jaglover

Yup, mkdir and touch are your friends.

----------

## bwakkie

thx compiled now...

I just had problems copy-pasting the patch  :Wink:    vim skewed the layout up... and while correcting this I removed the first spaces of all lines which made the patch invalid I guess...

----------

## darkphader

 *bwakkie wrote:*   

> I just had problems copy-pasting the patch ;-)   vim skewed the layout up

 

Put vim in paste mode - :set paste - before pasting and that wont happen.

----------

## pavel_prochazka

I followed this advise:

 *darkphader wrote:*   

> /etc/portage/patches/x11-drivers/nvidia-drivers-325.15/ is the proper path. Mine is named kernel.patch but anything.patch should work just fine.

 

that is 

```

pajin@nemo:~$ cat /etc/portage/patches/x11-drivers/nvidia-drivers-325.15/kernel.patch 

--- a/kernel/nv-linux.h

+++ b/kernel/nv-linux.h

@@ -957,7 +957,11 @@ static inline int nv_execute_on_all_cpus

 #endif

 

 #if !defined(NV_VMWARE)

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

+#define NV_NUM_PHYSPAGES                get_num_physpages()

+#else

 #define NV_NUM_PHYSPAGES                num_physpages

+#endif

 #define NV_GET_CURRENT_PROCESS()        current->tgid

 #define NV_IN_ATOMIC()                  in_atomic()

 #define NV_LOCAL_BH_DISABLE()           local_bh_disable()pajin@nemo:~$

```

and then compiling of the nvidia-drivers fails with some wrong permissions, i.e.

```

emerge -av nvidia-drivers

These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild     U ~] x11-drivers/nvidia-drivers-325.15 [319.49] USE="X (multilib) tools -acpi -pax_kernel" 0 kB

Total: 1 package (1 upgrade), Size of downloads: 0 kB

Would you like to merge these packages? [Yes/No] 

>>> Verifying ebuild manifests

>>> Running pre-merge checks for x11-drivers/nvidia-drivers-325.15

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Found kernel object directory:

 *     /lib/modules/3.11.2-gentoo/build

 * Found sources for kernel version:

 *     3.11.2-gentoo

 * Gentoo supports kernels which are supported by NVIDIA

 * which are limited to the following kernels:

 * <sys-kernel/gentoo-sources-3.11

 * <sys-kernel/vanilla-sources-3.11

 * 

 * You are free to utilize epatch_user to provide whatever

 * support you feel is appropriate, but will not receive

 * support as a result of those changes.

 * 

 * Do not file a bug report about this.

 * Checking for suitable kernel configuration options...                                   [ ok ]

>>> Emerging (1 of 1) x11-drivers/nvidia-drivers-325.15

 * NVIDIA-Linux-x86_64-325.15.run SHA256 SHA512 WHIRLPOOL size ;-) ...                     [ ok ]

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Found kernel object directory:

 *     /lib/modules/3.11.2-gentoo/build

 * Found sources for kernel version:

 *     3.11.2-gentoo

>>> Unpacking source...

>>> Unpacking NVIDIA-Linux-x86_64-325.15.run to /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work

>>> Source unpacked in /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work

>>> Preparing source in /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work ...

 * Applying user patches from /etc/portage/patches//x11-drivers/nvidia-drivers-325.15 ...

 *   kernel.patch ...                                                                      [ ok ]

 * Done with patching

>>> Source prepared.

>>> Configuring source in /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work ...

>>> Source configured.

>>> Compiling source in /var/tmp/portage/x11-drivers/nvidia-drivers-325.15/work ...

some compiling ....

/usr/src/linux-3.11.2-gentoo/Makefile:1422: .vmlinux.cmd: Permission denied

test -e include/generated/autoconf.h -a -e include/config/auto.conf || (                \

echo >&2;                                                       \

echo >&2 "  ERROR: Kernel configuration is invalid.";           \

echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\

echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";      \

echo >&2 ;                                                      \

/bin/false)

some compiling ....

compilation failure

```

Note that the advised "Run 'make oldconfig && make prepare' " did not change anything. The kernel was build conventionally by taking .config from my previous kernel, loading it into "make menuconfig" followed by "make && make modules_install". I also tried to set-up the kernel from scratch (make mrproper + make menuconfig) with the same result.

It is often written in the compilation (maybe also the reason of the failure)

```

/usr/src/linux-3.11.2-gentoo/include/linux/kconfig.h:4:32: fatal error: /usr/src/linux-3.11.2-gentoo/include/generated/autoconf.h: Permission denied

```

Corresponding permitions:

```

nemo src # l /usr/src/linux/include/generated/autoconf.h 

-rw-r----- 1 root root 36207 Oct  1 13:14 linux/include/generated/autoconf.h

```

any suggestions, what is wrong?

Kernel configuration is http://pastebin.com/L4gscjEQ, 

Thanks, Pavel

----------

## darkphader

I've seen that kernel message forever and just ignore it.

----------

## pavel_prochazka

 *darkphader wrote:*   

> I've seen that kernel message forever and just ignore it.

 

ok, but the problem is that the nvidia-drivers compilation results in failure. The kernel message was my suggestion about the reason of the failure. 

Pavel

----------

## darkphader

 *pavel_prochazka wrote:*   

> ok, but the problem is that the nvidia-drivers compilation results in failure. The kernel message was my suggestion about the reason of the failure. 
> 
> Pavel

 

It's not that kernel message. I posted my patch earlier as well, you might want to try that one. The patch in the pastebin didn't apply properly for me.

Also I get this:

```
sartre ~ # cat /etc/portage/patches/x11-drivers/nvidia-drivers-325.15/kernel.patch 

--- kernel/nv-linux.h.orig      2013-09-24 13:14:30.023159426 -0400

+++ kernel/nv-linux.h   2013-09-24 13:17:23.105718632 -0400

@@ -958,7 +958,11 @@

 #endif

 

 #if !defined(NV_VMWARE)

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

+#define NV_NUM_PHYSPAGES                get_num_physpages()

+#else

 #define NV_NUM_PHYSPAGES                num_physpages

+#endif

 #define NV_GET_CURRENT_PROCESS()        current->tgid

 #define NV_IN_ATOMIC()                  in_atomic()

 #define NV_LOCAL_BH_DISABLE()           local_bh_disable()

sartre ~ # 
```

In your output it looks like your shell prompt is part of your patch (last line at the end).

----------

## pavel_prochazka

The patch you wrote also does not help. 

```

nemo pajin # cat /etc/portage/patches/x11-drivers/nvidia-drivers-325.15/kernel.patch 

--- kernel/nv-linux.h.orig      2013-09-24 13:14:30.023159426 -0400

+++ kernel/nv-linux.h   2013-09-24 13:17:23.105718632 -0400

@@ -958,7 +958,11 @@

 #endif

 

 #if !defined(NV_VMWARE)

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

+#define NV_NUM_PHYSPAGES                get_num_physpages()

+#else

 #define NV_NUM_PHYSPAGES                num_physpages

+#endif

 #define NV_GET_CURRENT_PROCESS()        current->tgid

 #define NV_IN_ATOMIC()                  in_atomic()

 #define NV_LOCAL_BH_DISABLE()           local_bh_disable()

nemo pajin # 

```

The bash prompt was not part of the patch, I just wget the patch, which was not terminated by the line-break. I have resigned and switched to the noveau driver in kernel...

Pavel

----------

## pavel_prochazka

I finally compiled. I uninstalled the dev-util/nvidia-cuda-toolkit package (as I found on some nvidia forums - didn't work alone) and tried to avoid the wrong permissions by 

```

chmod -R o+r /usr/src/linux

chmod -R o+r /lib/modules/3.11.2-gentoo/build/arch/x86/include/generated

```

and the compilation with the aforementioned patch works. Is there anything to corrupt by allowing to read the kernel settings for everybody excepting some potential security hacks?

----------

## darkphader

 *pavel_prochazka wrote:*   

> I finally compiled. I uninstall the dev-util/nvidia-cuda-toolkit package (as I found on some nvidia forums - didn't work alone) and tried to avoid the wrong permissions by 
> 
> ```
> 
> chmod -R o+r /usr/src/linux
> ...

 

That's the way my kernel (source and module) perms have always been - directories are 755 and files are 644. For the source that's what an emerge  of gentoo-sources produces. Did you change them for some reason?

----------

## pavel_prochazka

 *darkphader wrote:*   

> 
> 
> That's the way my kernel (source and module) perms have always been - directories are 755 and files are 644. For the source that's what an emerge  of gentoo-sources produces. Did you change them for some reason?

 

I'm not aware about any manual change of the perms in the usr/src/linux directory, I just 

```

emerge -av gentoo-sources

eselect kenel set ...

cd /usr/src/linux

make menuconfig ...

make && make modules_install

```

Its fact that on my home laptop, I have the perms set correctly (directories 755 and files 644). I have really no idea why and when the perms were changed...

----------

## jathlon

Just a quick heads up.  The patch mentioned in the latter part of the thread seems to work allowing driver 331.13 to compile with linux-3.11.3. Of course you have to rename your patch directory under /etc/portage

later,

joe

----------

## Tolstoi

Just want to confirm that the patch worked here with kernel 3.11.5 and nvidia-drivers-331.13. 

Thanks.

----------

## musv

Would be nice if someone files a bug report. This error occures in 325 and in 331. Should be fixed.

----------

## mv

 *musv wrote:*   

> Should be fixed.

 

Won't happen. The maintainer insists on supporting only those kernels which nvidia explicitly declares as supported.

----------

## chromaf

Ok, I think I'm missing something here ... I make the dir and the patch on /etc/portage but when I emerge the drivers again it doesn't build. Do I need to do something else ? Like executing the patch ?

----------

## TomWij

Which directory did you make? Can you provide the exact path to the file? Maybe there's a typo? There is no need to execute it manually.

----------

## chromaf

I created : /etc/portage/patches/nvidia-drivers/Linux-3.11.patch

And the patch itself contains : 

```

--- a/kernel/nv-linux.h 

+++ b/kernel/nv-linux.h 

@@ -957,7 +957,11 @@ static inline int nv_execute_on_all_cpus 

 #endif 

  

 #if !defined(NV_VMWARE) 

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

+#define NV_NUM_PHYSPAGES                get_num_physpages() 

+#else 

 #define NV_NUM_PHYSPAGES                num_physpages 

+#endif 

 #define NV_GET_CURRENT_PROCESS()        current->tgid 

 #define NV_IN_ATOMIC()                  in_atomic() 

 #define NV_LOCAL_BH_DISABLE()           local_bh_disable()

```

----------

## TomWij

 *chromaf wrote:*   

> I created : /etc/portage/patches/nvidia-drivers/Linux-3.11.patch

 

This misses the category x11-drivers, try /etc/portage/patches/x11-drivers/nvidia-drivers/Linux-3.11.patch

----------

## chromaf

Ups ... sorry ! Thank you  :Smile: 

----------

## chromaf

Hi, now it tries to apply the patch but I get this on the prepare stage ... 

```

speed cf # cat nvidiaerr.log 

 * Package:    x11-drivers/nvidia-drivers-319.49

 * Repository: gentoo

 * Maintainer: jer@gentoo.org xarthisius@gentoo.org

 * USE:        X acpi amd64 elibc_glibc kernel_linux multilib tools userland_GNU

 * FEATURES:   preserve-libs sandbox userpriv usersandbox

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Found kernel object directory:

 *     /lib/modules/3.11.5-gentoo/build

 * Found sources for kernel version:

 *     3.11.5-gentoo

>>> Unpacking source...

>>> Unpacking NVIDIA-Linux-x86_64-319.49.run to /var/tmp/portage/x11-drivers/nvidia-drivers-319.49/work

>>> Source unpacked in /var/tmp/portage/x11-drivers/nvidia-drivers-319.49/work

>>> Preparing source in /var/tmp/portage/x11-drivers/nvidia-drivers-319.49/work ...

 * Converting /kernel/Makefile.kbuild to use M= instead of SUBDIRS= ...  [ ok ]

 * Applying user patches from /etc/portage/patches//x11-drivers/nvidia-drivers-319.49 ...

 *   Linux-3.11.patch ...

 * Failed Patch: Linux-3.11.patch !

 *  ( /etc/portage/patches//x11-drivers/nvidia-drivers-319.49/Linux-3.11.patch )

 * 

 * Include in your bugreport the contents of:

 * 

 *   /var/tmp/portage/x11-drivers/nvidia-drivers-319.49/temp/Linux-3.11.patch.out

 * ERROR: x11-drivers/nvidia-drivers-319.49::gentoo failed (prepare phase):

 *   Failed Patch: Linux-3.11.patch!

 * 

 * Call stack:

 *     ebuild.sh, line   93:  Called src_prepare

 *   environment, line 4184:  Called epatch_user

 *   environment, line 1602:  Called epatch

 *   environment, line 1575:  Called die

 * The specific snippet of code:

 *               die "Failed Patch: ${patchname}!";

 * 

 * If you need support, post the output of `emerge --info '=x11-drivers/nvidia-drivers-319.49::gentoo'`,

 * the complete build log and the output of `emerge -pqv '=x11-drivers/nvidia-drivers-319.49::gentoo'`.

 * The complete build log is located at '/var/tmp/portage/x11-drivers/nvidia-drivers-319.49/temp/build.log'.

 * The ebuild environment file is located at '/var/tmp/portage/x11-drivers/nvidia-drivers-319.49/temp/environment'.

 * Working directory: '/var/tmp/portage/x11-drivers/nvidia-drivers-319.49/work'

 * S: '/var/tmp/portage/x11-drivers/nvidia-drivers-319.49/work/'

```

By the way I realized I am using the 319.49 ... that's probably why they don't build ... can you tell me how to emerge the nvidia-drivers-325.15 ?

Thank you

----------

