Package: nvidia-graphics-drivers
Severity: wishlist
Tags: patch

If you want to use the full range of nvidia proprietry drivers on live
systems the kernel dkms packages must both be installed at the same time
and the correct module to use selected at runtime. While co-installation
is possible for the GLX and xorg parts, this is currently not possible
for the dkms packages.

The attached patches modify the dkms packages to allow coinstallation.
The legacy packages dkms config is modified to name the module
nvidia-legacy-173xx instead of just nvidia.

Unfortunately both modules claim to support most PCI IDs. To load the
most recent module in case both variants are installed. The patch for
nvidia-support adds a script to nvidia-kernel-common to select the right
module when modprobing either nvidia or nvidia-legacy-173xx. The correct
module is selected based on the existing nvidia.ids lists of PCI IDs.

The patches to nvidia-graphics-drivers and
nvidia-graphics-drivers-legacy-173xx also move the nvidia.ids file from
the xserver-xorg-video-nvidia-xxx package to the dkms and kernel-source
package to support the above script.

While I agree that all of this is a bit hacky. I can't see any better
way to support live systems and in my tests the whole thing works quite
well. I'm open for suggestions if you see better ways to make the dkms
packages co-installable.

I'm currently also writing a boot script for live systems to select the
correct glx and nvidia alternatives on boot based on the hardware present
in the system.

Gaudenz

P.S.: I'll clone this report to the other affected packages as soon as I
get the bug number.

-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (800, 'testing'), (700, 'unstable'), (50, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.2.0-3-amd64 (SMP w/2 CPU cores)
Locale: LANG=de_CH.UTF-8, LC_CTYPE=de_CH.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Index: debian/control
===================================================================
--- debian/control	(Revision 3309)
+++ debian/control	(Arbeitskopie)
@@ -231,7 +231,7 @@
  nvidia-installer-cleanup,
 Depends:
  dkms (>= 2.1),
- nvidia-kernel-common (>= 20110213),
+ nvidia-kernel-common (>= 20120630+4),
  ${misc:Depends}
 Recommends:
  nvidia-glx${nvidia:Legacy} (>= ${nvidia:Version}),
@@ -239,9 +239,12 @@
  nvidia-kernel-dkms,
  nvidia-kernel-${nvidia:Version}${nvidia:Perfkit},
 Conflicts:
- nvidia-kernel-dkms,
+ nvidia-kernel-source (>= 304.37-2),
 Breaks:
  make (= 3.82-1),
+ xserver-xorg-video-nvidia (<< 304.37-2),
+Replaces:
+ xserver-xorg-video-nvidia (<< 304.37-2),
 Description: NVIDIA binary kernel module DKMS source${nvidia:LegacyDesc}
  .
  This package builds the NVIDIA Xorg binary kernel module needed by
@@ -273,8 +276,13 @@
  nvidia-kernel-common,
 Suggests:
  nvidia-glx${nvidia:Legacy} (>= ${nvidia:Version}),
+Conflicts:
+ nvidia-kernel-dkms (>= 304.37-2)
 Breaks:
  make (= 3.82-1),
+ xserver-xorg-video-nvidia (<< 304.37-2),
+Replaces:
+ xserver-xorg-video-nvidia (<< 304.37-2),
 Description: NVIDIA binary kernel module source${nvidia:LegacyDesc}
  .
  This package provides the source for the NVIDIA Xorg binary kernel module
Index: debian/changelog
===================================================================
--- debian/changelog	(Revision 3309)
+++ debian/changelog	(Arbeitskopie)
@@ -8,6 +8,7 @@
   * {libgl1-nvidia-glx,libcuda1,nvidia-vdpau-driver,nvidia-opencl-icd}-ia32:
     Add NEWS file describing the steps needed to install the multiarch :i386
     nvidia packages on amd64.
+  * Make current and legacy dkms packages co-installable
 
  -- Andreas Beckmann <[email protected]>  Thu, 16 Aug 2012 09:45:17 +0200
 
Index: debian/nvidia-kernel-dkms.install.in
===================================================================
--- debian/nvidia-kernel-dkms.install.in	(Revision 0)
+++ debian/nvidia-kernel-dkms.install.in	(Revision 0)
@@ -0,0 +1 @@
+nvidia.ids		usr/lib/#PRIVATE#/
Index: debian/xserver-xorg-video-nvidia.install.in
===================================================================
--- debian/xserver-xorg-video-nvidia.install.in	(Revision 3309)
+++ debian/xserver-xorg-video-nvidia.install.in	(Arbeitskopie)
@@ -1,3 +1,2 @@
 nvidia_drv.so		usr/lib/#PRIVATE#/
 libglx.so.#VERSION#	usr/lib/#PRIVATE#/
-nvidia.ids		usr/lib/#PRIVATE#/
Index: debian/nvidia-kernel-source.install.in
===================================================================
--- debian/nvidia-kernel-source.install.in	(Revision 0)
+++ debian/nvidia-kernel-source.install.in	(Revision 0)
@@ -0,0 +1 @@
+nvidia.ids		usr/lib/#PRIVATE#/
Index: debian/changelog
===================================================================
--- debian/changelog	(Revision 3309)
+++ debian/changelog	(Arbeitskopie)
@@ -4,6 +4,7 @@
     Add upstream patch nvidia-blacklist-vga-pmu-registers-195.diff:
     Fix exploitable local privilege escalation through VGA window manipulation
     via the device nodes that allows access to arbitrary physical memory.
+  * Make current and legacy dkms packagess co-installable 
 
  -- Andreas Beckmann <[email protected]>  Fri, 17 Aug 2012 01:42:27 +0200
 
Index: debian/nvidia-kernel-dkms.install.in
===================================================================
--- debian/nvidia-kernel-dkms.install.in	(Revision 0)
+++ debian/nvidia-kernel-dkms.install.in	(Revision 0)
@@ -0,0 +1 @@
+nvidia.ids						usr/lib/#PRIVATE#/
Index: debian/control
===================================================================
--- debian/control	(Revision 3309)
+++ debian/control	(Arbeitskopie)
@@ -223,7 +223,7 @@
  nvidia-installer-cleanup,
 Depends:
  dkms (>= 2.1),
- nvidia-kernel-common (>= 20110213),
+ nvidia-kernel-common (>= 20120630+4),
  ${misc:Depends}
 Recommends:
  nvidia-glx${nvidia:Legacy} (>= ${nvidia:Version}),
@@ -231,9 +231,12 @@
  nvidia-kernel-dkms,
  nvidia-kernel-${nvidia:Version}${nvidia:Perfkit},
 Conflicts:
- nvidia-kernel-dkms,
+ nvidia-kernel-legacy-173xx-source (>= 173.14.35-3)
 Breaks:
  make (= 3.82-1),
+ xserver-xorg-video-nvidia (<< 173.14.35-3),
+Replaces:
+ xserver-xorg-video-nvidia (<< 173.14.35-3),
 Description: NVIDIA binary kernel module DKMS source${nvidia:LegacyDesc}
  This package builds the NVIDIA Xorg binary kernel module needed by
  nvidia-glx${nvidia:Legacy}, using DKMS.
@@ -264,8 +267,13 @@
  nvidia-kernel-common,
 Suggests:
  nvidia-glx${nvidia:Legacy} (>= ${nvidia:Version}),
+Conflicts:
+ nvidia-kernel-legacy-173xx-dkms (>= 173.14.35-3)
 Breaks:
  make (= 3.82-1),
+ xserver-xorg-video-nvidia (<< 173.14.35-3),
+Replaces:
+ xserver-xorg-video-nvidia (<< 173.14.35-3),
 Description: NVIDIA binary kernel module source${nvidia:LegacyDesc}
  This package provides the source for the NVIDIA Xorg binary kernel module
  needed by nvidia-glx${nvidia:Legacy} in a form suitable
Index: debian/xserver-xorg-video-nvidia.install.in
===================================================================
--- debian/xserver-xorg-video-nvidia.install.in	(Revision 3309)
+++ debian/xserver-xorg-video-nvidia.install.in	(Arbeitskopie)
@@ -1,3 +1,2 @@
 usr/X11R6/lib/modules/drivers/nvidia_drv.so		usr/lib/#PRIVATE#/
 usr/X11R6/lib/modules/extensions/libglx.so.#VERSION#	usr/lib/#PRIVATE#/
-nvidia.ids						usr/lib/#PRIVATE#/
Index: debian/rules
===================================================================
--- debian/rules	(Revision 3309)
+++ debian/rules	(Arbeitskopie)
@@ -52,7 +52,7 @@
 
 module_source	 = debian/nvidia-kernel$(legacy)-source/usr/src/modules/nvidia-kernel$(legacy)
 module_tbz	 = $(subst /modules/,/,$(module_source)).tar.bz2
-dkms_source	 = debian/nvidia-kernel$(legacy)-dkms/usr/src/nvidia-$(version)
+dkms_source	 = debian/nvidia-kernel$(legacy)-dkms/usr/src/nvidia$(legacy)-$(version)
 
 comma		 = ,
 xorg_depends	 = $(foreach abi, $(XORG_ABI_LIST), xorg-video-abi-$(abi) |)
Index: debian/nvidia-kernel-dkms.dkms
===================================================================
--- debian/nvidia-kernel-dkms.dkms	(Revision 3309)
+++ debian/nvidia-kernel-dkms.dkms	(Arbeitskopie)
@@ -1,10 +1,11 @@
 # DKMS configuration for the NVIDIA kernel module.  -*- sh -*-
 
 # The version is replaced at build time by dh_dkms invoked in debian/rules.
-PACKAGE_NAME="nvidia"
+PACKAGE_NAME="nvidia-legacy-173xx"
 PACKAGE_VERSION="#MODULE_VERSION#"
 
-BUILT_MODULE_NAME[0]="$PACKAGE_NAME"
+BUILT_MODULE_NAME[0]="nvidia"
+DEST_MODULE_NAME[0]="$PACKAGE_NAME"
 DEST_MODULE_LOCATION[0]="/updates/dkms"
 AUTOINSTALL=yes
 
Index: debian/nvidia-kernel-source.install.in
===================================================================
--- debian/nvidia-kernel-source.install.in	(Revision 0)
+++ debian/nvidia-kernel-source.install.in	(Revision 0)
@@ -0,0 +1 @@
+nvidia.ids						usr/lib/#PRIVATE#/
Index: load-nvidia-kmod
===================================================================
--- load-nvidia-kmod	(Revision 0)
+++ load-nvidia-kmod	(Revision 0)
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+# supported driver generations ordered by preference
+VERSIONS="current legacy-173xx"
+
+ID_BASEDIR="/usr/lib/nvidia/"
+ID_FILENAME="nvidia.ids"
+MODULE_BASE="nvidia"
+
+# get PCI ID of the first NVIDIA graphics card. Kernel module selection is done based on the first card.
+NV_DEVICES=$(lspci -mn | awk '{ gsub("\"",""); if ($2 == "0300" && ($3 == "10de" || $3 == "12d2")) { print $3$4 } }' | tr a-z A-Z | head -1)
+
+if [ -z "$NV_DEVICES" ]; then
+	echo "No NVIDIA GPU detected."
+	exit 1
+fi
+
+
+for v in $VERSIONS ; do
+    ID_FILE="$ID_BASEDIR/$v/$ID_FILENAME"
+
+    if [ ! -r $ID_FILE ] ; then
+        continue
+    fi
+
+    if grep -q $NV_DEVICES $ID_FILE ; then
+        if [ $v = "current" ] ; then
+            MODULE="$MODULE_BASE"
+        else
+            MODULE="$MODULE_BASE-$v"
+        fi
+        # load the module, ignore install scripts (to avoid recursion)
+        modprobe --ignore-install $MODULE $*
+        exit 0
+    fi
+done
+
+# No appropriate module found, try to load the nouveau driver as a last resort
+# don't pass module parameters as they won't be understood
+modprobe nouveau 

Eigenschaftsänderungen: load-nvidia-kmod
___________________________________________________________________
HinzugefĂĽgt: svn:executable
   + *

Index: debian/nvidia-kernel-common.install
===================================================================
--- debian/nvidia-kernel-common.install	(Revision 3309)
+++ debian/nvidia-kernel-common.install	(Arbeitskopie)
@@ -1,2 +1,3 @@
 nvidia_helper.ck /usr/lib/ConsoleKit/run-seat.d/
 nvidia_helper /lib/udev/
+load-nvidia-kmod /lib/modprobe.d/
\ No newline at end of file
Index: debian/nvidia-kernel-common.modprobe
===================================================================
--- debian/nvidia-kernel-common.modprobe	(Revision 3309)
+++ debian/nvidia-kernel-common.modprobe	(Arbeitskopie)
@@ -6,3 +6,7 @@
 
 # see #580894
 blacklist nouveau
+
+# Select correct kernel module if several are installed
+install nvidia /lib/modprobe.d/load-nvidia-kmod $CMDLINE_OPTS
+install nvidia-legacy-173xx /lib/modprobe.d/load-nvidia-kmod $CMDLINE_OPTS
Index: debian/changelog
===================================================================
--- debian/changelog	(Revision 3309)
+++ debian/changelog	(Arbeitskopie)
@@ -1,3 +1,11 @@
+nvidia-support (20120630+4) UNRELEASED; urgency=low
+
+  [ Gaudenz Steinlin ]
+  * Add script to nvidia-kernel-common to load correct
+    kernel module.
+
+ -- Gaudenz Steinlin <[email protected]>  Wed, 22 Aug 2012 09:26:09 +0200
+
 nvidia-support (20120630+3) unstable; urgency=low
 
   [ Debconf translations ]

Reply via email to