Categories
Linux / Gentoo Linux

Ubuntu Kernel 3.8 and NVidia Drivers

While playing around with various mainline kernels I found out that the vanilla NVidia driver (310.xx and 313.xx) do not compile on the linux 3.8.0-rc3 kernel. Testing the xorg-edgers and ubuntu-x-swat versions of the NVidia driver package did not help either.

Until the NVidia driver officially supports the 3.8.0 kernel, this workaround will allow you to fix the NVidia driver using the DKMS source installation. This might also still apply for kernel 3.7.x. Begin by adding the ubuntu-x-swat repository to get at least version 304.60 of the NVidia driver:

sudo apt-add-repository ppa:ubuntu-x-swat/x-updates
sudo apt-get update
sudo apt-get install nvidia-current

Patch (by hand if you have to) the following 2 files: /usr/src/nvidia-current-304.64/conftest.sh and /usr/src/nvidia-current-304.64/nv-mmap.c. These patches are based on 310.xx but can be used for manual modification:

--- conftest.sh.dist    2012-10-11 19:18:22.704848496 -0400
+++ conftest.sh 2012-10-12 20:35:55.707213868 -0400
@@ -20,6 +20,7 @@
 ISYSTEM=`$CC -print-file-name=include 2> /dev/null`
 SOURCES=$4
 HEADERS=$SOURCES/include
+HEADERSA=$SOURCES/include/uapi
 OUTPUT=$5
 XEN_PRESENT=1
 
@@ -118,7 +119,7 @@
         fi
     fi
 
-    CFLAGS="$CFLAGS $OUTPUT_CFLAGS -I$HEADERS $AUTOCONF_CFLAGS"
+    CFLAGS="$CFLAGS $OUTPUT_CFLAGS -I$HEADERS -I$HEADERSA $AUTOCONF_CFLAGS"
 
     test_xen
 
@@ -146,10 +147,10 @@
         fi
     fi
 
-    CFLAGS="$BASE_CFLAGS $MACH_CFLAGS $OUTPUT_CFLAGS -I$HEADERS $AUTOCONF_CFLAGS"
+    CFLAGS="$BASE_CFLAGS $MACH_CFLAGS $OUTPUT_CFLAGS -I$HEADERS -I$HEADERSA $AUTOCONF_CFLAGS"
 
     if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]; then
-        CFLAGS="$CFLAGS -I$SOURCES/arch/x86/include -I$OUTPUT/arch/x86/include/generated"
+        CFLAGS="$CFLAGS -I$SOURCES/arch/x86/include -I$SOURCES/arch/x86/include/uapi -I$OUTPUT/arch/x86/include/generated -I$OUTPUT/arch/x86/include/generated/uapi"
     elif [ "$ARCH" = "arm" ]; then
         CFLAGS="$CFLAGS -I$SOURCES/arch/arm/include -I$OUTPUT/arch/arm/include/generated"
     fi
--- nv-mmap.c.dist 2012-08-08 22:52:53.000000000 -0400
+++ nv-mmap.c 2012-08-14 23:52:41.257235863 -0400
@@ -450,7 +450,7 @@
NV_PRINT_AT(NV_DBG_MEMINFO, at);
nv_vm_list_page_count(&at->page_table[i], pages);

- vma->vm_flags |= (VM_IO | VM_LOCKED | VM_RESERVED);
+ vma->vm_flags |= (VM_IO | VM_LOCKED | (VM_DONTEXPAND | VM_DONTDUMP));

Patches are taken from here After patching, the NVidia kernel module will not be built unless you install a new kernel or force an update using DKMS. To rebuild the kernel module for your currently running kernel, run this:

sudo dkms autoinstall -k $(uname -r)

Leave a Reply

Your email address will not be published. Required fields are marked *