Friday, June 3, 2016

Compiling Nvidia driver 340.96 for Linux 4.6.x kernel

Updates Oct 2016: The latest Nvidia driver should support kernel 4.6.x, 4.7.x, and 4.8.x.  There is no need to use this patch anymore.

Updates 2016-08-13: The patch works for Linux kernel 4.7.x too.

With the latest Linux 4.6.x kernel, the Nvidia 340.96 driver won't compile.  Here is a quick fix to compile and install the driver until Nvidia releases a new version.

First, download extract the driver package:

./NVIDIA-Linux-x86_64-340.96 -x

Then patch the files accordingly:

diff -r NVIDIA-Linux-x86_64-340.96/kernel/os-mlock.c NVIDIA-Linux-x86_64-340.96.mod/kernel/os-mlock.c
48c48
<     ret = get_user_pages(current, mm, (unsigned long)address,
---
>     ret = get_user_pages_remote(current, mm, (unsigned long)address,
61c61,62
<             page_cache_release(user_pages[i]);
---
>             //page_cache_release(user_pages[i]);
>             put_page(user_pages[i]);
88c89,90
<         page_cache_release(user_pages[i]);
---
>         //page_cache_release(user_pages[i]);
>         put_page(user_pages[i]);

diff -r NVIDIA-Linux-x86_64-340.96/kernel/uvm/nvidia_uvm_lite.c NVIDIA-Linux-x86_64-340.96.mod/kernel/uvm/nvidia_uvm_lite.c
788c788,789
<         retValue = VM_FAULT_MINOR;
---
>         //retValue = VM_FAULT_MINOR;
>         retValue = 0;


Finally, compile and install:

./nvidia-installer

5 comments:

babaei said...

Thanks! This really helped me get back up and running in Fedora 24.

Anonymous said...

Thank you as well, had the same issue and this fixed it.
Can you report it to nvidia?

wef said...

Thanks from me too - worked a treat on 4.6.7-300 fedora-24 !!!

Unknown said...
This comment has been removed by the author.
Unknown said...

I have long been a regular user of Windows. Now I realized that I need to build an operating system for my own needs with my preferences. Thanks for the advice, since it's very difficult to do such things without experience and necessary knowledge. Who needs a driver, you can find them here, this is the best resource cuz you may download the necessary number of different drivers, and just to make the correct setting.