# nvidia-drivers-340.96 and kernel 4.6.0

## brahici

Hi

Here's a patch to compile nvidia-drivers-340.96 with kernel 4.6.x . Please notice that there are no kernel version checks (improvement to come).

The patch is available at https://zerobin.net/?ae22f4178dc9ce13#Jo9LWsDJchqEQonQzh9cRjC7douzReIulw1Nm8uHYDU= .

Save it in /etc/portage/patches/x11-drivers/nvidia-drivers under name 01-kernel-4.6.0.patch (or any other relevant name).

Run emerge nvidia-drivers (or emerge @module-rebuild).

----------

## brahici

Patch updated with kernel version checks. Tested with sys-kernel/gentoo-sources 4.5.4 and 4.6.0 .

https://zerobin.net/?b523bac5834ac4b4#pV2jeQ4DuzmIsmdLf2N8WlUHh2IWJ3sEZ+CIXzJzaUU= .

----------

## therealpete

Thanks very much!! Very much appreciated!!

----------

## drbrezner

hi

thanks for your work. usually those patches worked for me, too, in the past. but now 

```
emerge =nvidia-driver-340.96-r5
```

still breaks:

```
/var/tmp/portage/x11-drivers/nvidia-drivers-340.96-r5/work/kernel/uvm/nvidia_uvm_lite.c:788:20: error: â undeclared (first use in this function)

         retValue = VM_FAULT_MINOR;
```

i compiled gentoo-sources-4.6.0 and use gcc-5.3.0. According to emerge output the patch is being applied. What could be wrong?

----------

## hurricane

```

/var/tmp/portage/x11-drivers/nvidia-drivers-340.96-r5/work/kernel/uvm/nvidia_uvm_lite.c:788:20: Error: »VM_FAULT_MINOR« not declared (first usage in this function)

         retValue = VM_FAULT_MINOR;

                    ^
```

Same problem here too.

It seems to me, like VM_FAULT_MINOR is deprecated and was always 0 anyway: 

RE: [PATCH 03/12] mm: Remove VM_FAULT_MINOR

But I don’t know enough to be secure enough to just set 

```
retValue = 0
```

 …

Anyone…?

----------

## hurricane

Ok, in case it makes sense to replace VM_FAULT_MINOR by 0, I made this little additional patch:

VM_FAULT_MINOR=0.patch

It compiled here. But of course, I don’t make any guarantees that it won’t eat your children, found a church, or vote for the Trump-Cheney-Putin-Koch-Blankfein-Dragi-Kim-Yong-Un alliance  :Very Happy: 

----------

## brahici

You may also disable uvm USE flag in case you don't need it.

This patch https://zerobin.net/?27df430e0cf437f6#7oQ8gEknTBY4Dor37ZwkASik6Prhtk4oe2f3N82fCx0= does the same as hurricane's one, but also checks kernel version (a bit overkill in this case).

----------

## drbrezner

Now the emerge works perfectly with both patches -- thanks a lot, guys!

----------

## cfgauss

Thanks go to brahici and hurricane. I can confirm that nvidia-drivers-340.96-r5 emerges without error under kernel gentoo-sources-4.6.0 using both patches above.

----------

## thunderrd

Yeah, thanks for the patches; I am using ck-sources:4.6.2 and they patched the driver and built fine.

----------

## Buffoon

Thanks! I have a Zotac box that cannot use nouveau because of lack of HDMI audio support.

----------

## Buffoon

Spoke too soon. Paste is here, just in case https://bpaste.net/show/18c63e089d6c

----------

## Jaglover

This worked with 4.6.2 kernel: https://git.archlinux.org/svntogit/packages.git/plain/trunk/linux-4.6.patch?h=packages/nvidia-340xx

----------

