Friday, November 13, 2015

Compiling Nvidia driver 340.xx for latest kernels

Updates (2015-11-30): Nvidia driver 340.96 seems to fixed the issue.  Also, it now works with xserver ABI 20 (x-server 1.18)

One of my PCs has openSUSE Tumbleweed installed.  The machine has a Nvidia 9300 graphic chip on the motherboard and so I was using the legacy driver NVIDIA-Linux-x86_64-340.93.

After upgrading the kernel to 4.3.x, the Nvidia driver failed to compile.  The error is something like this:

error: void value not ignored as it ought to be
return seq_printf(s, "Binary: \"%s\"\n", registry_keys);

After some digging, seems that the Linux kernel has changed and seq_* family now return void instead of an integer.

Here is a quick fix.  First extract the Nvidia driver by running

./  -x

Then modify the file NVIDIA-Linux-x86_64-340.93/kernel/nv-procfs.c:

<     return seq_printf(s, "Binary: \"%s\"\n", registry_keys);
>     seq_printf(s, "Binary: \"%s\"\n", registry_keys);
>     return 0;
<     return seq_puts(s, s->private);
>     seq_puts(s, s->private);
>     return 0;

Then run the installer to compile and install the driver:

sudo NVIDIA-Linux-x86_64-340.93/nvidia-installer

No comments: