Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 181812 - nvidia-drivers only work with a patched Makefile, because of interchanged retvals in kernel capability detection
Summary: nvidia-drivers only work with a patched Makefile, because of interchanged ret...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: X11 External Driver Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-12 19:04 UTC by Dirk
Modified: 2007-11-11 09:12 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk 2007-06-12 19:04:04 UTC
There are mixed up return values in the nvidia-drivers' build system - at least in  9755, 8776 and 7676.
I can only build a _working_ kernel modul for recent vanilla kernels if I tweak the retvals.
 
In ./usr/src/nv/Makefile.kbuild I need these two Definitions 

    EXTRA_CFLAGS += -DNV_REMAP_PFN_RANGE_PRESENT
    EXTRA_CFLAGS += -DNV_PCI_GET_CLASS_PRESENT

because they are present (and it without the two -Defines it fails):

    $ nm -B /usr/src/linux/vmlinux | egrep -e "\<remap_pfn_range" -e "\<pci_get_class"
        c0282319 T pci_get_class
        c01506b1 T remap_pfn_range

The according Conditions in ./usr/src/nv/Makefile.kbuild look like this:

      ifeq ($(shell $(CONFTEST) pci_get_class), 1)
        EXTRA_CFLAGS += -DNV_PCI_GET_CLASS_PRESENT
      endif
      ifeq ($(shell $(CONFTEST) remap_pfn_range), 1)
        EXTRA_CFLAGS += -DNV_REMAP_PFN_RANGE_PRESENT
      else

If I want to have the two defintions, the calls to $(CONFTEST) => ./usr/src/nv/conftest.sh 
both have to return 1. This is the belonging code:

 remap_pfn_range)
        #
        # Determine if remap_pfn_range() is present.
        #

        echo "#include <linux/autoconf.h>
        #include <linux/mm.h>
        void conftest_remap_pfn_range(void) {
            remap_pfn_range();
        }" > conftest$$.c

        $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
        rm -f conftest$$.c

        if [ -f conftest$$.o ]; then
            rm -f conftest$$.o
            echo 0
        else
            echo 1
        fi
    ;;
  pci_get_class)
        #
        # Determine if pci_get_class() is present.
        #

        echo "#include <linux/autoconf.h>
        #include <linux/pci.h>
        void conftest_pci_get_class(void) {
            pci_get_class();
        }" > conftest$$.c

        $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
        rm -f conftest$$.c

        if [ -f conftest$$.o ]; then
            rm -f conftest$$.o
            echo 0
        else
            echo 1
        fi
    ;;

Both testcompilations succeed, because the kernel has the Symbols mentioned
above, but the wrong values are returned by conftest.sh or tested by
Makefile.kbuild.

So either:

--- usr/src/nv/Makefile.kbuild.orgy	2007-06-12 10:31:24.000000000 +0200
+++ usr/src/nv/Makefile.kbuild	2007-06-12 11:20:03.000000000 +0200
@@ -179,7 +179,7 @@ ifneq ($(PATCHLEVEL), 4)
     EXTRA_CFLAGS += -DNV_MULTIPLE_BRIDGE_AGPGART_PRESENT
   endif
 
-  ifeq ($(shell $(CONFTEST) pci_get_class), 1)
+  ifeq ($(shell $(CONFTEST) pci_get_class), 0)
     EXTRA_CFLAGS += -DNV_PCI_GET_CLASS_PRESENT
   endif
 
@@ -207,7 +207,7 @@ ifneq ($(PATCHLEVEL), 4)
   endif
 endif
 
-ifeq ($(shell $(CONFTEST) remap_pfn_range), 1)
+ifeq ($(shell $(CONFTEST) remap_pfn_range), 0)
   EXTRA_CFLAGS += -DNV_REMAP_PFN_RANGE_PRESENT
 else
   REMAP_PAGE_RANGE := $(shell $(CONFTEST) remap_page_range)


Or :


--- usr/src/nv/conftest.sh.orgy	2007-06-12 19:24:01.000000000 +0200
+++ usr/src/nv/conftest.sh	2007-06-12 19:27:24.000000000 +0200
@@ -602,9 +602,9 @@ case "$5" in
 
         if [ -f conftest$$.o ]; then
             rm -f conftest$$.o
-            echo 0
-        else
             echo 1
+        else
+            echo 0
         fi
     ;;
 
@@ -624,9 +624,9 @@ case "$5" in
 
         if [ -f conftest$$.o ]; then
             rm -f conftest$$.o
-            echo 0
-        else
             echo 1
+        else
+            echo 0
         fi
     ;;

Now I can compile _AND_ use the kernel modul.


The last lines of the compilation without a patch, for a 2.6.21.5 vanilla kernel:

make -f /opt/mr-machine/src/kernel/linux-2.6.21.5/scripts/Makefile.modpost
  scripts/mod/modpost   -i /opt/mr-machine/src/kernel/linux-2.6.21.5/Module.symvers -I /var/tmp/portage/x11-drivers/nvidia-drivers-1.0.9755-r1/work/NVIDIA-Linux-x86-1.0-9755-pkg0/usr/src/nv/Module.symvers -o /var/tmp/portage/x11-drivers/nvidia-drivers-1.0.9755-r1/work/NVIDIA-Linux-x86-1.0-9755-pkg0/usr/src/nv/Module.symvers -w vmlinux /var/tmp/portage/x11-drivers/nvidia-drivers-1.0.9755-r1/work/NVIDIA-Linux-x86-1.0-9755-pkg0/usr/src/nv/nvidia.o
WARNING: "pci_find_class" [/var/tmp/portage/x11-drivers/nvidia-drivers-1.0.9755-r1/work/NVIDIA-Linux-x86-1.0-9755-pkg0/usr/src/nv/nvidia.ko] undefined!
WARNING: "remap_page_range" [/var/tmp/portage/x11-drivers/nvidia-drivers-1.0.9755-r1/work/NVIDIA-Linux-x86-1.0-9755-pkg0/usr/src/nv/nvidia.ko] undefined!
  i686-pc-linux-gnu-gcc -Wp,-MD,/var/tmp/portage/x11-drivers/nvidia-drivers-1.0.9755-r1/work/NVIDIA-Linux-x86-1.0-9755-pkg0/usr/src/nv/.nvidia.mod.o.d  -nostdinc -isystem /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include -D__KERNEL__ -Iinclude  -include include/linux/autoconf.h -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Os -pipe -msoft-float -mregparm=3 -freg-struct-return -mpreferred-stack-boundary=2  -march=i686 -mtune=pentium4 -ffreestanding -maccumulate-outgoing-args -DCONFIG_AS_CFI=1  -Iinclude/asm-i386/mach-default -fomit-frame-pointer  -fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign    -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(nvidia.mod)"  -D"KBUILD_MODNAME=KBUILD_STR(nvidia)" -DMODULE -c -o /var/tmp/portage/x11-drivers/nvidia-drivers-1.0.9755-r1/work/NVIDIA-Linux-x86-1.0-9755-pkg0/usr/src/nv/nvidia.mod.o /var/tmp/portage/x11-drivers/nvidia-drivers-1.0.9755-r1/work/NVIDIA-Linux-x86-1.0-9755-pkg0/usr/src/nv/nvidia.mod.c
  ld -m elf_i386  -r -o /var/tmp/portage/x11-drivers/nvidia-drivers-1.0.9755-r1/work/NVIDIA-Linux-x86-1.0-9755-pkg0/usr/src/nv/nvidia.ko /var/tmp/portage/x11-drivers/nvidia-drivers-1.0.9755-r1/work/NVIDIA-Linux-x86-1.0-9755-pkg0/usr/src/nv/nvidia.o /var/tmp/portage/x11-drivers/nvidia-drivers-1.0.9755-r1/work/NVIDIA-Linux-x86-1.0-9755-pkg0/usr/src/nv/nvidia.mod.o
NVIDIA: left KBUILD.
>>> Source compiled.

depmod says:

WARNING: /lib/modules/2.6.21.5/video/nvidia.ko needs unknown symbol remap_page_range
WARNING: /lib/modules/2.6.21.5/video/nvidia.ko needs unknown symbol pci_find_class

#####################################################################
# Let's have a "nouveau" hope: http://nouveau.freedesktop.org/wiki/ #
#####################################################################

Reproducible: Always

Steps to Reproduce:
building the kernel modul

Actual Results:  
No X, KDE
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2007-06-12 19:09:35 UTC
What's a "recent vanilla kernel"? It builds just fine w/ gentoo-sources-2.6.21-r3, so nothing critical here.
Comment 2 Dirk 2007-06-14 09:28:18 UTC
(In reply to comment #1)
> What's a "recent vanilla kernel"? It builds just fine w/
> gentoo-sources-2.6.21-r3, so nothing critical here.
> 
A kernel from kernel.org. 
A non-gentoo-sources kernel. 
It's called like that in the gentoo handbook, and by Distros in general, i think.

Comment 3 Dirk 2007-06-14 10:06:52 UTC
Because the names are similar, let me add:
The kernel has the symbols
       pci_get_class
       remap_pfn_range
depmod complains because the _unpatched_ nvidia kernel modul gets defined to use
       pci_find_class       
       remap_page_range
Both Symbols changed around 2.6.9, 2.6.10 
Comment 4 Dirk 2007-07-02 18:25:42 UTC
If you don't have either autoconf.h or (pci.h and mm.h) in /usr/include/linux you get a correct driver without this patch !
For example sys-kernel/linux-headers-2.6.21 is lacking autoconf.h and mm.h
Comment 5 Jakub Moc (RETIRED) gentoo-dev 2007-09-04 01:11:49 UTC
(In reply to comment #4)
> If you don't have either autoconf.h or (pci.h and mm.h) in /usr/include/linux
> you get a correct driver without this patch !
> For example sys-kernel/linux-headers-2.6.21 is lacking autoconf.h and mm.h

linux-headers-2.6.21 is stable everywhere, problem fixed.
Comment 6 Dirk 2007-11-11 09:12:54 UTC
Although I didn't want to post anything anymore, I can't let this be the last post of this thread.
This isn't about the kernel headers, but the scrubby way the nvidia drivers test kernel properties. And again, _nothing_ that gentoo-developers are to blame for.
Oh well, this stats-hungry ...