7

How can I use the recent beta of the 302 version of the nvidia driver (which finally supports the RandR extension!) with a realtime kernel in Precise?

This question contains information on enabling the current 295 version for the 3.4 kernel with the RT patch. But I'm looking for an answer that installs the nvidia driver using the package manager rather than nvidia's installer (whose installations break every so often due to the package management system overwriting files).

1 Answer 1

4

Warning

The patch in this question is for kernel 3.4, and so is the one below; a realtime-patched kernel 3.4 is required.

The new nvidia 302 driver requires the video ABI that xorg-server 1.12 provides, and unfortunately Precise comes with xorg-server 1.11. The following instructions involve adding the xorg-edgers PPA as a software source to provide xorg-server 1.12, and this poses a certain risk of breakage. The uninstallation instructions are at the bottom, but read them through for possible hiccups there.

Instructions

Modifying the packaged nvidia driver

  • Create a temporary directory and change into it with:


    mkdir -p ~/tmp/nvidia_302_fixrt && cd ~/tmp/nvidia_302_fixrt
    
  • Download the nvidia-current_302*.deb from the xorg-edgers PPA by browsing the packages for Precise under nvidia-graphics-driver_302* here. At the moment of this writing, a direct download can be performed with:

    wget https://launchpad.net/~xorg-edgers/+archive/ppa/+files/nvidia-current_302.17-0ubuntu1~xedgers~precise1_amd64.deb
    
  • Extract the .deb with:

    dpkg-deb -x nvidia-current_*.deb deb_contents && dpkg-deb --control nvidia-current_*.deb deb_contents/DEBIAN
    
  • Add the patch to the deb_contents/usr/src/nvidia-current*/patches directory by pasting the following in a terminal:

    d=$(echo deb_contents/usr/src/nvidia-current*/patches) ; cat > $d/buildfix_kernel_rt_3.4.patch <<'EOF'
    diff -u a/conftest.sh b/conftest.sh
    --- a/conftest.sh       2012-05-03 09:49:19.582854050 +0100
    +++ b/conftest.sh       2012-05-03 09:52:58.524101586 +0100
    @@ -95,7 +95,7 @@
             fi
         fi
    
    -    CFLAGS="$CFLAGS $OUTPUT_CFLAGS -I$HEADERS $AUTOCONF_CFLAGS"
    +    CFLAGS="$CFLAGS $OUTPUT_CFLAGS -I$HEADERS -I$OUTPUT/arch/x86/include/generated $AUTOCONF_CFLAGS"
    
         test_xen
    
    @@ -965,11 +965,12 @@
                 #
                 echo "$CONFTEST_PREAMBLE
                 #include <linux/acpi.h>
    +            #include <acpi/acpixf.h>
                 void conftest_acpi_walk_namespace(void) {
                     acpi_walk_namespace();
                 }" > conftest$$.c
    
    -            $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
    +            #CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
                 rm -f conftest$$.c
    
                 if [ -f conftest$$.o ]; then
    @@ -980,6 +981,7 @@
    
                 echo "$CONFTEST_PREAMBLE
                 #include <linux/acpi.h>
    +            #include <acpi/acpixf.h>
                 void conftest_acpi_walk_namespace(void) {
                     acpi_walk_namespace(0, NULL, 0, NULL, NULL, NULL, NULL);
                 }" > conftest$$.c
    @@ -1604,6 +1606,9 @@
                 fi
             fi
    
    +        RET=0
    +        SELECTED_MAKEFILE=Makefile.kbuild
    +
             if [ "$RET" = "0" ]; then
                 ln -s $SELECTED_MAKEFILE Makefile
                 exit 0
    diff -u a/nv-linux.h b/nv-linux.h
    --- a/nv-linux.h        2012-05-03 09:49:19.622853547 +0100
    +++ b/nv-linux.h        2012-05-03 09:56:12.045668690 +0100
    @@ -291,7 +291,18 @@
     #endif
     #endif
    
    -#if defined(CONFIG_PREEMPT_RT)
    +#if defined(CONFIG_PREEMPT_RT_FULL)
    +typedef raw_spinlock_t            nv_spinlock_t;
    +#define NV_SPIN_LOCK_INIT(lock)   raw_spin_lock_init(lock)
    +#define NV_SPIN_LOCK_IRQ(lock)    raw_spin_lock_irq(lock)
    +#define NV_SPIN_UNLOCK_IRQ(lock)  raw_spin_unlock_irq(lock)
    +#define NV_SPIN_LOCK_IRQSAVE(lock,flags) raw_spin_lock_irqsave(lock,flags)
    +#define NV_SPIN_UNLOCK_IRQRESTORE(lock,flags) \
    +   raw_spin_unlock_irqrestore(lock,flags)
    +#define NV_SPIN_LOCK(lock)        raw_spin_lock(lock)
    +#define NV_SPIN_UNLOCK(lock)      raw_spin_unlock(lock)
    +#define NV_SPIN_UNLOCK_WAIT(lock) raw_spin_unlock_wait(lock)
    +#elif defined(CONFIG_PREEMPT_RT)
     typedef atomic_spinlock_t         nv_spinlock_t;
     #define NV_SPIN_LOCK_INIT(lock)   atomic_spin_lock_init(lock)
     #define NV_SPIN_LOCK_IRQ(lock)    atomic_spin_lock_irq(lock)
    @@ -954,7 +965,9 @@
         return ret;
     }
    
    -#if defined(CONFIG_PREEMPT_RT)
    +#if defined(CONFIG_PREEMPT_RT_FULL)
    +#define NV_INIT_MUTEX(mutex) sema_init(mutex,1)
    +#elif defined(CONFIG_PREEMPT_RT)
     #define NV_INIT_MUTEX(mutex) semaphore_init(mutex)
     #else
     #if !defined(__SEMAPHORE_INITIALIZER) && defined(__COMPAT_SEMAPHORE_INITIALIZER)
    EOF
    
  • Add the patch to dkms.conf by pasting this in a terminal:

    d=$(echo deb_contents/usr/src/nvidia-current*) ; cat >> $d/dkms.conf <<'EOF'
    PATCH_MATCH[1]="^3\.4.*(rt|realtime)"
    PATCH[1]="buildfix_kernel_rt_3.4.patch"
    EOF
    
  • Modify the version number in deb_contents/DEBIAN/control by issuing:

    
sed -i 's/^\(Version: .*\)$/\1+rtfix/' deb_contents/DEBIAN/control
    
  • Repackage the driver with:

    
dpkg -b deb_contents nvidia-current_$(sed -n 's/^\(Version: *\)//p' deb_contents/DEBIAN/control)_amd64.deb
    

Installing the PPA and the modified driver

  • Add the xorg-edgers PPA:

    
sudo add-apt-repository ppa:xorg-edgers/ppa && sudo apt-get update && sudo apt-get dist-upgrade
    
  • Install the locally-modified .deb with:


    sudo dpkg -i nvidia-current_*+rtfix_*.deb
    

Keeping up to date

The xorg-edgers PPA will update with newer versions of the nvidia driver as they come out; you will need to repeat the re-packaging instructions above with each new release.

Uninstalling

You should be able to revert to the nouveau driver with the following:

    sudo apt-get remove nvidia-current
    sudo apt-get install ppa-purge
    sudo ppa-purge ppa:xorg-edgers/ppa

In my case, this process involved uninstalling wine along with some i386 packages (which should have been downgraded instead). Be wary of ppa-purge if you are on amd64 since it does not get along well with multiarch (as indicated in the PPA warnings); in my case the outcome was a non-issue (I simply reinstalled wine), but other people might end up with badly broken dependencies depending on what they have installed.

2
  • Does this actually require a 3.4 kernel, or would a 3.2 kernel patched with the realtime extensions suffice? Struggling to find relevant mention in the release notes... Jul 15, 2012 at 19:56
  • 2
    The patch to get the nvidia kernel interface playing nicely with an RT-patched kernel works for 3.4 but not for 3.2. It should be possible to adapt the patch for 3.2, but I haven't tried, and I don't know how non-trivial that might get. In short, you don't need 3.4 for its features, it's just that an nvidia+RT patch is not available (as in "I haven't found one with google") for 3.2.
    – pablomme
    Jul 16, 2012 at 6:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .