patch nvidia driver for kernel 3.11

AGGIORNAMENTO DRIVER 331.13 e KERNEL 3.11-3-liquorix-amd64

Non che quanto scrivo sia molto utile ma a volte mi torna comodo lasciare sparsi i miei appunti.

Mi sono trovato ad affrontare l’installazione dei driver nvidia su kernel 3.11-1 che mi è appena saltato fuori dai repository di liquorix.

Mi sono imbattuto subito in un link molto interessante nella Nvidia Developer Zone .

Ho pure scoperto che per scaricare i driver per Linux non serve più compilare la scheda con le descrizioni del nostro HW e OS , ma è possibile trovare già tutto con le versioni più recenti (che a volte nella ricerca vengono omessi) in una pagina dedicata : http://www.nvidia.com/object/unix.html .

Nvidia_Logo_in_Green_Ice

Dopo aver prelevato i driver nella versione più recente o desiderata è pssibile seguire due strade per applicare la patch , entrambe danno lo stesso risultato , una richiede alcuni passaggi i più.

La mia condizione di partenza mi poneva in un ambiente di lavoro funzionante e seppure da konsole , mi trovavo in KDE4 con kernel 3.10-3 e i driver 325.15 appena installati .

Per fare le prove genero una dir apposita in cui metto una copia dei driver 325.15 e la kernel_v3.11.patch  , di cui ne lascio una copia nel caso il link si perda nel tempo :


--- a/kernel/nv-linux.h
+++ b/kernel/nv-linux.h
@@ -957,7 +957,11 @@ static inline int nv_execute_on_all_cpus
#endif

#if !defined(NV_VMWARE)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
+#define NV_NUM_PHYSPAGES                get_num_physpages()
+#else
#define NV_NUM_PHYSPAGES                num_physpages
+#endif
#define NV_GET_CURRENT_PROCESS()        current->tgid
#define NV_IN_ATOMIC()                  in_atomic()
#define NV_LOCAL_BH_DISABLE()           local_bh_disable()
— a/kernel/nv-drm.c
+++ b/kernel/nv-drm.c
@@ -106,7 +106,11 @@ static const struct file_operations nv_d
.unlocked_ioctl = drm_ioctl,
.mmap = drm_gem_mmap,
.poll = drm_poll,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)
+//  .fasync = drm_fasync,
+#else
.fasync = drm_fasync,
+#endif
.read = drm_read,
.llseek = noop_llseek,
};
@@ -202,12 +206,16 @@ RM_STATUS NV_API_CALL nv_alloc_os_descri
memset(&nv_obj->base, 0, sizeof(nv_obj->base));
nv_obj->pages = pages;

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)
+    drm_gem_private_object_init(nvl->drm, &nv_obj->base, size);
+#else
ret = drm_gem_private_object_init(nvl->drm, &nv_obj->base, size);
if (ret)
{
status = RM_ERR_OPERATING_SYSTEM;
goto done;
}
+#endif

ret = drm_gem_handle_create(file_priv, &nv_obj->base, handle);
if (ret)
— a/kernel/nv.c
+++ b/kernel/nv.c
@@ -16,8 +16,12 @@
#include “rmil.h”

#if defined(MODULE_LICENSE)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)
+MODULE_LICENSE(“GPL”);
+#else
MODULE_LICENSE(“NVIDIA”);
#endif
+#endif
#if defined(MODULE_INFO)
MODULE_INFO(supported, “external”);
#endif

salvare con il nome kernel_v3.11.patch nella stessa dir dove sta la copia del driver da patchare.

Ora il percorso più breve prevede un solo comando :

#sh NVIDIA-Linux-x86_64-325.15.run --apply-patch kernel_3.11.patch

in questo modo applichiamo la patch direttamente.

Se il terminale vi chiede dov’è il file da patchare , prestate attenzione che è indicato un paio di righe più su , come ad esempio kernel/nv-linux.h. ,kernel/nv-drm.c e kernel/nv.c dopo basta premere enter

Ora sarà possibile installare il solo modulo per il kernel 3.11-1 senza uscire dall’ambiente grafico sfruttando le opzioni dell’ installer .

#sh NVIDIA-Linux-x86_64-325.15.custom.run -K --kernel-name=3.11-1.dmz.1-liquorix-amd64

tramitre l’opzione  -K specifichiamo un kenrel diverso e con –kernel-name= mettiamo il nome del kernel in cui installare i driver..

Non ci resta che segurie da shell i vari passaggi dell’installazione come si fa solitamente.

L’ installer dei driver ha un suo help molto utile :

# sh NVIDIA-Linux-x86_64-325.15.run --help

NVIDIA-Linux-x86_64-325.15.run [options]

This program will install the NVIDIA Accelerated Graphics Driver for
Linux-x86_64 325.15 by unpacking the embedded tarball and executing
the ./nvidia-installer  installation utility.

Below are the most common options; for a complete list use
'--advanced-options'.

--info
  Print embedded info (title, default target directory) and exit.

--check
  Check integrity of the archive and exit.

-x, --extract-only
  Extract the contents of NVIDIA-Linux-x86_64-325.15.run, but do not
  run 'nvidia-installer'.

The following arguments will be passed on to the ./nvidia-installer
utility:

  -a, --accept-license
      Bypass the display and prompting for acceptance of the
      NVIDIA Software License Agreement.  By passing this option
      to nvidia-installer, you indicate that you have read and
      accept the License Agreement contained in the file
      'LICENSE' (in the top level directory of the driver
      package).

  --update
      Connect to the NVIDIA FTP server '
      ftp://download.nvidia.com ' and determine the latest
      available driver version.  If there is a more recent driver
      available, automatically download and install it.  Any
      other options given on the commandline will be passed on to
      the downloaded driver package when installing it.

  -v, --version
      Print the nvidia-installer version and exit.

  -h, --help
      Print usage information for the common command
      line options and exit.

  -A, --advanced-options
      Print usage information for the common commandline options
      as well as the advanced options, and then exit.

Volendo è possibile approfondire usando la lettera -A , –advanced-options ma qui la lista è lunga e lascio a voi la scoperta.

Passiamo ora al secondo metodo , dove andremo ad estrarre il driver , siamo sempre nella stessa dir dove è presente la copia del driver (possibilmente non già patchata 😉 ) e la patch kernel_v3.11.patch .

Eseguiamo l’estrazione del contenuto del driver . run :

#sh NVIDIA-Linux-x86_64-325.15.run --extract-only

ora spostamoci e applichiamo la patch :

#cd NVIDIA-Linux-x86_64-325.15/kernel
#patch -p1 < ../../kernel_v3.11.patch

torniamo un passo indietro

#cd ..

a questo punto lanciamo l’installer :

./nvidia-installer -K --kernel-name=3.11-1.dmz.1-liquorix-amd64

anche se non è il .run accetta le opzioni 🙂  .

  • Aggiornamento per kernel 3.11-3-liquorix-amd64 e driver 331.13

Scarichiamo i driver (2013.10.4) 331.13 BETA link e copiamo il seguente testo in un file che chiameremo : kernel_3.11-3.patch

--- a/kernel/nv-linux.h    2013-09-06 05:16:30.000000000 +0100
+++ b/kernel/nv-linux.h        2013-09-06 05:25:06.000000000 +0100
@@ -958,7 +958,13 @@
 #endif

 #if !defined(NV_VMWARE)
-#define NV_NUM_PHYSPAGES                num_physpages
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
+#define NV_NUM_PHYSPAGES get_num_physpages
+#else
+#define NV_NUM_PHYSPAGES num_physpages
+#endif
+
 #define NV_GET_CURRENT_PROCESS()        current->tgid
 #define NV_IN_ATOMIC()                  in_atomic()
 #define NV_LOCAL_BH_DISABLE()           local_bh_disable()

la procedura è uguale alla precedente , e andremo a patchare :

# sh NVIDIA-Linux-x86_64-331.13.run --apply-patch kernel_3.11-3.patch

alla domanda , rispondiamo :

File to patch: kernel/nv-linux.h

Verrà generato un driver-custom che andremo a installiare :

# ./NVIDIA-Linux-x86_64-331.13-custom.run -K --kernel-name=3.11-3.dmz.2-liquorix-amd64

Godiamoci i nuovi driver considerando che ora con questa versione si è risolto pure il controllo della CPU che ora pare tornata a lavorare in powersave.

😉

 

  • OBSOLETO

Ora il resto è divertente perchè dopo il riavvio con il kernel 3.11-1 di liquorix con finalmente i driver video funzionanti mi trovo un’altro problema.

Anche se cpufrequtils è impostato in powersave e ha fino adesso funzionato con tutti gli altri kernel, ora non è in grado di modificarla e resta a 3.7GH scaldando inutilemtne il processore.

$ cpufreq-info
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel.org, please.
analyzing CPU 0:
driver: intel_pstate
CPUs which run at the same hardware frequency: 0
CPUs which need to have their frequency coordinated by software: 0
maximum transition latency: 0.97 ms.
hardware limits: 1.60 GHz - 3.70 GHz
available cpufreq governors: performance, powersave
current policy: frequency should be within 1.60 GHz and 3.70 GHz.
The governor "powersave" may decide which speed to use
within this range.
analyzing CPU 1:
driver: intel_pstate
CPUs which run at the same hardware frequency: 1
CPUs which need to have their frequency coordinated by software: 1
maximum transition latency: 0.97 ms.
hardware limits: 1.60 GHz - 3.70 GHz
available cpufreq governors: performance, powersave
current policy: frequency should be within 1.60 GHz and 3.70 GHz.
The governor "powersave" may decide which speed to use
within this range.
analyzing CPU 2:
driver: intel_pstate
CPUs which run at the same hardware frequency: 2
CPUs which need to have their frequency coordinated by software: 2
maximum transition latency: 0.97 ms.
hardware limits: 1.60 GHz - 3.70 GHz
available cpufreq governors: performance, powersave
current policy: frequency should be within 1.60 GHz and 3.70 GHz.
The governor "powersave" may decide which speed to use
within this range.
analyzing CPU 3:
driver: intel_pstate
CPUs which run at the same hardware frequency: 3
CPUs which need to have their frequency coordinated by software: 3
maximum transition latency: 0.97 ms.
hardware limits: 1.60 GHz - 3.70 GHz
available cpufreq governors: performance, powersave
current policy: frequency should be within 1.60 GHz and 3.70 GHz.
The governor "powersave" may decide which speed to use
within this range.

maneggio la frequenza manualmente :

#cpufreq-set -r -d 1.6Ghz

la frequenza viene modificata ma ciò non avviene in automatico, così provo a ricaricare il governor :

#cpufreq-set -r -g powersave

un pò di man non guasta mai :

$ man cpufreq-set

come pure un buon link : https://wiki.debian.org/HowTo/CpuFrequencyScaling

Ora però ho sonno e essere avanti mi ha scassato un pò per questa sera , domani la macchina verrà avviata con il kernel 3.10-3 di Jessie.

Una risposta a “patch nvidia driver for kernel 3.11”

  1. Interessante! Ho aggiornato quest’oggi Ubuntu da 13.04, non ti dico i problemi incontrati perché sono tanti, ma ciò che mi ha dato più rogne è stata questa “conflittualità” fra sorgente del kernel e driver di NVidia. Ho cercato in lungo e in largo e avevo già visto queste patch, ho un solo dubbio su get_num_physpages(): dalla mia ricerca di stamattina avevo trovato nella mailing list del zfs una soluzione diversa, invece di sostituire num_physpages con quella macro, veniva proposto totalram_pages. Anche nel changelog del Kernel viene suggerito totalram_pages. Non sono tanto esperto da capirne le differenze purtroppo. Ho provato get_num_phys e il sistema sembra impazzito: schermate nere, lock screen che non funziona, ventola della CPU impazzita 🙁
    Speriamo Nvidia si decida ad aggiornare il driver al più presto.

Rispondi

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.