警告

警告

如何將 nvidia 驅動程式 302 版本的最新測試版(最終支援 RandR 擴充功能!)與 Precise 中的即時核心一起使用?

這個問題包含有關使用 RT 補丁為 3.4 核心啟用目前 295 版本的資訊。但我正在尋找使用套件管理器安裝 nvidia 驅動程式的答案,而不是 nvidia 的安裝程式(由於套件管理系統覆蓋文件,其安裝經常中斷)。

答案1

警告

補丁在這個問題適用於內核 3.4,以下的也是如此;需要即時修補的核心 3.4。

新的 nvidia 302 驅動程式需要 xorg-server 1.12 提供的視訊 ABI,不幸的是 Precise 隨 xorg-server 1.11 一起提供。以下說明涉及添加xorg-edgers PPA作為軟體來源提供xorg-server 1.12,這會帶來一定的破損風險。卸載說明位於底部,但請通讀它們以防止可能出現的問題。

指示

修改打包好的nvidia驅動

  • 建立一個臨時目錄並更改為:


    mkdir -p ~/tmp/nvidia_302_fixrt && cd ~/tmp/nvidia_302_fixrt
    
  • 透過瀏覽 nvidia-graphics-driver_302* 下的 Precise 軟體包,從 xorg-edgers PPA 下載 nvidia-current_302*.deb這裡。在撰寫本文時,可以透過以下方式執行直接下載:

    wget https://launchpad.net/~xorg-edgers/+archive/ppa/+files/nvidia-current_302.17-0ubuntu1~xedgers~precise1_amd64.deb
    
  • 使用以下命令提取 .deb:

    dpkg-deb -x nvidia-current_*.deb deb_contents && dpkg-deb --control nvidia-current_*.deb deb_contents/DEBIAN
    
  • deb_contents/usr/src/nvidia-current*/patches透過在終端機中貼上以下內容將補丁新增至目錄:

    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
    
  • 透過將以下內容貼到終端機中,將補丁新增至 dkms.conf:

    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
    
  • 發出以下指令修改 deb_contents/DEBIAN/control 中的版本號:

    
sed -i 's/^\(Version: .*\)$/\1+rtfix/' deb_contents/DEBIAN/control
    
  • 重新打包驅動程式:

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

安裝 PPA 和修改後的驅動程式

  • 新增 xorg-edgers PPA:

    
sudo add-apt-repository ppa:xorg-edgers/ppa && sudo apt-get update && sudo apt-get dist-upgrade
    
  • 使用以下命令安裝本地修改的 .deb:


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

保持最新狀態

xorg-edgers PPA 將隨著 nvidia 驅動程式的新版本發布而更新;您將需要對每個新版本重複上面的重新打包說明。

解除安裝

應該能夠nouveau透過以下方式恢復到驅動程式:

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

就我而言,這個過程涉及wine與一些 i386 軟體包一起卸載(這些軟體包應該被降級)。ppa-purge如果您使用的是 amd64,請小心,因為它與多架構相處不好(如 PPA 警告所示);就我而言,結果不是問題(我只是重新安裝wine),但其他人可能最終會嚴重破壞依賴關係,這取決於他們安裝的內容。

相關內容