[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ANNOUNCE] udev 015 release


On Fri, 2004-01-30 at 19:23, Greg KH wrote:
> On Fri, Jan 30, 2004 at 05:45:41PM +0100, Prakash K. Cheemplavam wrote:
> > Hi Greg,
> > 
> > perhaps you remember me being a gentoo user wanting to switch to udev. 
> > Well I did so, but am having some problems:
> > 
> > 1.) Minor one: Nodes for Nvidia (I am using binary display modules 
> > 1.0.5328) ar not created. I have to do it by hand each start-up (written 
> > into loacal.start.):
> > mknod /dev/nvidia0 c 195 0
> > mknod /dev/nvidiactl c 195 255
> 
> Heh, and you expect me to be able to modify a binary driver to work with
> udev how?  :)
> 
> You're on your own here...
> 

No offense, but you guys sometimes really see things as too black and
white :)

Its only the high level api calls that are in binary object files, but
the main interface to the kernel is source that needs compiling.  I have
a patch attached here that adds basic sysfs support via the class_simple
functions.

It works as expected, only problem is kbuild seems to ignore
EXTRA_CFLAGS?  If I remove the 'defined(HAVE_CLASS_SIMPLE), or
use the attached non-kbuild Makefile, it works just fine.  Anybody
have an idea bout the EXTRA_CFLAGS issue?


Cheers,

-- 

Martin Schlemmer



diff -urpN NVIDIA-Linux-x86-1.0-5336/usr/src/nv/Makefile.kbuild NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/Makefile.kbuild
--- NVIDIA-Linux-x86-1.0-5336/usr/src/nv/Makefile.kbuild	2004-01-15 05:29:12.000000000 +0200
+++ NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/Makefile.kbuild	2004-02-01 16:15:55.529582488 +0200
@@ -146,6 +146,10 @@ ifeq ($(shell sh $(src)/conftest.sh rema
   EXTRA_CFLAGS += -DREMAP_PAGE_RANGE_4
 endif
 
+ifeq ($(shell sh $(src)/conftest.sh class_simple $(KERNEL_HEADERS)), yes)
+  EXTRA_CFLAGS += -DHAVE_CLASS_SIMPLE
+endif
+  
 #
 # NVIDIA binary object file includes .common section.
 #
diff -urpN NVIDIA-Linux-x86-1.0-5336/usr/src/nv/built-in.o NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/built-in.o
--- NVIDIA-Linux-x86-1.0-5336/usr/src/nv/built-in.o	1970-01-01 02:00:00.000000000 +0200
+++ NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/built-in.o	2004-02-01 16:11:27.428340072 +0200
@@ -0,0 +1 @@
+!<arch>
diff -urpN NVIDIA-Linux-x86-1.0-5336/usr/src/nv/conftest.sh NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/conftest.sh
--- NVIDIA-Linux-x86-1.0-5336/usr/src/nv/conftest.sh	2004-01-15 05:29:11.000000000 +0200
+++ NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/conftest.sh	2004-02-01 16:19:19.079638176 +0200
@@ -42,6 +42,29 @@ case "$1" in
         fi
     ;;
 
+    class_simple)
+        shift
+        #
+        # Determine if we have struct class_simple needed for limited sysfs
+        # support in 2.6
+        #
+        echo "#include <linux/device.h>
+        struct class_simple *test_class;
+        int add_test_class() {
+           test_class = class_simple_create(THIS_MODULE, \"test\");
+        }" > conftest.c
+
+        gcc -c conftest.c -o conftest.o $* -D__KERNEL__ > /dev/null 2>&1
+
+        if test -f conftest.o; then
+          echo "yes"
+        else
+          echo "no"
+        fi
+
+        rm -f conftest.{c,o}
+    ;;
+
     cc_sanity_check)
         shift
         #
diff -urpN NVIDIA-Linux-x86-1.0-5336/usr/src/nv/nv-linux.h NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/nv-linux.h
--- NVIDIA-Linux-x86-1.0-5336/usr/src/nv/nv-linux.h	2004-01-15 05:29:11.000000000 +0200
+++ NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/nv-linux.h	2004-02-01 16:54:14.850032648 +0200
@@ -448,6 +448,33 @@ typedef struct agp_memory agp_memory;
 #  endif // defined(KERNEL_2_4)
 #endif // defined(CONFIG_DEVFS_FS)
 
+#if defined(KERNEL_2_6) && defined(HAVE_CLASS_SIMPLE)
+#  define NV_SYSFS_REGISTER						\
+    nvidia_class = class_simple_create(THIS_MODULE, "nvidia");
+
+#  define NV_SYSFS_ADD_CONTROL						\
+     class_simple_device_add(nvidia_class,				\
+                             MKDEV(NV_MAJOR_DEVICE_NUMBER, 255),	\
+                             NULL, "nvidiactl");
+
+#  define NV_SYSFS_ADD_DEVICE(_name, _minor)				\
+     class_simple_device_add(nvidia_class,				\
+                             MKDEV(NV_MAJOR_DEVICE_NUMBER, _minor),	\
+                             &nv_linux_devices[_minor].dev->dev, _name);
+
+#  define NV_SYSFS_REMOVE_DEVICE(i)					\
+            class_simple_device_remove(MKDEV(NV_MAJOR_DEVICE_NUMBER, i));
+
+#  define NV_SYSFS_UNREGISTER						\
+    class_simple_destroy(nvidia_class);
+#else
+#  define NV_SYSFS_REGISTER
+#  define NV_SYSFS_ADD_CONTROL
+#  define NV_SYSFS_ADD_DEVICE(_name, _minor)
+#  define NV_SYSFS_REMOVE_DEVICE(i)
+#  define NV_SYSFS_UNREGISTER
+#endif
+
 
 /*
  * Linux 2.5 introduced the five argument version of remap_page_range, all
diff -urpN NVIDIA-Linux-x86-1.0-5336/usr/src/nv/nv.c NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/nv.c
--- NVIDIA-Linux-x86-1.0-5336/usr/src/nv/nv.c	2004-01-15 05:29:11.000000000 +0200
+++ NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/nv.c	2004-02-01 16:58:03.429283320 +0200
@@ -47,6 +47,10 @@ struct proc_dir_entry *proc_nvidia;
 devfs_handle_t nv_devfs_handles[NV_MAX_DEVICES+1];
 #endif
 
+#if defined(KERNEL_2_6) && defined(HAVE_CLASS_SIMPLE)
+struct class_simple *nvidia_class;
+#endif
+
 // #define NV_DBG_MEM 1
 #undef NV_DBG_MEM
 
@@ -874,23 +878,31 @@ static int __init nvidia_init_module(voi
     rc = register_chrdev(nv_major, "nvidia", &nv_fops);
 #endif
 
+    NV_SYSFS_REGISTER;
+
     if (rc < 0)
     {
         nv_printf(NV_DBG_ERRORS, "nvidia_init_module: register failed\n");
         return rc;
     }
 
-#ifdef CONFIG_DEVFS_FS
+#if defined(CONFIG_DEVFS_FS) || defined(KERNEL_2_6)
     do
     {
         char name[10];
 
+# if defined(CONFIG_DEVFS_FS)
         nv_devfs_handles[0] = NV_DEVFS_REGISTER("nvidiactl", 255);
+# endif
+        NV_SYSFS_ADD_CONTROL;
 
         for (i = 0; i < num_nv_devices; i++)
         {
             sprintf(name, "nvidia%d", i);
+# if defined(CONFIG_DEVFS_FS)
             nv_devfs_handles[i+1] = NV_DEVFS_REGISTER(name, i);
+# endif
+            NV_SYSFS_ADD_DEVICE(name, i);
         }
     } while(0);
 #endif
@@ -951,6 +963,7 @@ static int __init nvidia_init_module(voi
 #else
     unregister_chrdev(nv_major, "nvidia");
 #endif
+    NV_SYSFS_UNREGISTER;
     return rc;
 }
 
@@ -1011,15 +1024,24 @@ static void __exit nvidia_exit_module(vo
         nv_printf(NV_DBG_ERRORS, "nvidia_exit_module: unregister nv failed\n");
     }
 
-#ifdef CONFIG_DEVFS_FS
+#if defined(CONFIG_DEVFS_FS) || defined(KERNEL_2_6)
     do {
         int i;
+# if defined(CONFIG_DEVFS_FS)
         NV_DEVFS_REMOVE_CONTROL();
-        for (i = 0; i < num_nv_devices; i++)
+# endif
+        NV_SYSFS_REMOVE_DEVICE(255);
+        for (i = 0; i < num_nv_devices; i++) {
+# if defined(CONFIG_DEVFS_FS)
             NV_DEVFS_REMOVE_DEVICE(i);
+# endif
+            NV_SYSFS_REMOVE_DEVICE(i);
+        }
     } while (0);
 #endif
 
+    NV_SYSFS_UNREGISTER;
+
 #if NV_ENABLE_MEM_TRACKING
     nv_list_mem(vm_list);
     nv_list_mem(km_list);
# This Makefile is automatically generated; do not edit
#   Generated on 'builder3.nvidia.com' on Thu Jun 19 04:05:35 PDT 2003

LINUX_MODULE=nv-linux.o
DEFINES=-D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES -DKBUILD_MODNAME="nvidia" -DNTRM -D_GNU_SOURCE -D_LOOSE_KERNEL_NAMES -D__KERNEL__ -DMODULE  -DNV_MAJOR_VERSION=1 -DNV_MINOR_VERSION=0 -DNV_PATCHLEVEL=5328     -DNV_UNIX   -DNV_LINUX   -DNV_INT64_OK   -DNVCPU_X86
INCLUDES=-I.

OBJECTS=nv.o os-agp.o os-interface.o os-registry.o 
HEADERS=os-agp.h os-interface.h nv-linux.h nv-misc.h nv-memdbg.h nv.h  rmretval.h nvtypes.h  $(VERSION_HDR)

CFLAGS=-Wall -Wimplicit -Wreturn-type -Wswitch -Wformat -Wchar-subscripts -Wparentheses -Wcast-qual -Wno-multichar  -O -MD $(DEFINES) $(INCLUDES) -Wno-cast-qual

RESMAN_KERNEL_MODULE=nv-kernel.o

KERNDIR=/lib/modules/$(shell uname -r)

# check for newer paths. if found, use them, otherwise use old paths
# these wouldn't work with the gnu make included with rh6.2
# KERNINC=$(if -d $(KERNDIR)/build, $(KERNDIR)/build/include, /usr/src/linux/include)
# INSTALLDIR=$(if -d $(KERNDIR)/kernel, $(KERNDIR)/kernel/drivers/video, $(KERNDIR)/video)

# this is slightly more brain-dead, but works..
ifeq ($(shell if test -d $(KERNDIR)/build; then echo yes; fi),yes)
KERNINC=$(KERNDIR)/build/include
else
KERNINC=/usr/src/linux/include
endif

ifeq ($(shell if test -d $(KERNDIR)/kernel; then echo yes; fi),yes)
INSTALLDIR=$(KERNDIR)/kernel/drivers/video
else
INSTALLDIR=$(KERNDIR)/video
endif

ifeq ($(shell echo $(NVDEBUG)),1)
  ifeq ($(shell test -z $(RMDEBUG) && echo yes),yes)
    RMDEBUG=1
  endif
endif

ifeq ($(shell echo $(RMDEBUG)),1)
CFLAGS += -DDEBUG -g -fno-common
endif

# this is just plain wrong, get rid of it
BROKENDIR=$(KERNDIR)/kernel/video

INSTALL=$(shell which install)

# allow specification of alternate include file tree on command line and extra defines
ifdef SYSINCLUDE
INCLUDES += -I$(SYSINCLUDE)
INCLUDES += -I$(SYSINCLUDE)/asm/mach-default
else
INCLUDES += -I$(KERNINC)
INCLUDES += -I$(KERNINC)/asm/mach-default
endif

ifeq ($(shell sh conftest.sh remap_page_range $(INCLUDES)), 5)
  DEFINES += -DREMAP_PAGE_RANGE_5
endif

ifeq ($(shell sh conftest.sh remap_page_range $(INCLUDES)), 4)
  DEFINES += -DREMAP_PAGE_RANGE_4
endif

ifeq ($(shell sh conftest.sh class_simple $(INCLUDES)), yes)
  DEFINES += -DHAVE_CLASS_SIMPLE
endif

DEFINES+=$(EXTRA_DEFINES)

# allow build parameters to be passed in through the environment
ifdef BUILD_PARAMS
    DEFINES+=-D$(BUILD_PARAMS)
endif

VERSION_HDR=nv_compiler.h

all: install

install: package-install

suser-sanity-check:
	@if ! sh conftest.sh suser_sanity_check; then \
	  echo; \
	  echo "You have insufficient privileges for this operation. Please "; \
	  echo "run \"make install\" as root!                               "; \
	  echo; \
	  exit 1; \
	fi

rmmod-sanity-check:
	@if ! sh conftest.sh rmmod_sanity_check nvidia; then \
	  echo; \
	  echo "Unable to unload the currently loaded NVIDIA kernel module! "; \
	  echo "Please be certain that you have exited X before attempting  "; \
	  echo "to install this version.                                    "; \
	  echo; \
	  exit 1; \
	fi

cc-sanity-check:
	@if ! sh conftest.sh cc_sanity_check full_output $(CC); then exit 1; fi

package-install: suser-sanity-check nvidia.o rmmod-sanity-check
	if [ -d $(BROKENDIR) ]; then \
		rm -f $(BROKENDIR)/NVdriver; \
		rmdir --ignore-fail-on-non-empty $(BROKENDIR); \
	fi && \
	mkdir -p $(INSTALLDIR) && \
	rm -f $(INSTALLDIR)/NVdriver && \
	$(INSTALL) -m 0664 -o root -g root nvidia.o $(INSTALLDIR)/nvidia.o$(O) && \
	/sbin/depmod -a && \
	/sbin/modprobe nvidia && \
	sh makedevices.sh && \
	echo "nvidia.o installed successfully."; \

nvidia.o: cc-sanity-check $(LINUX_MODULE) $(RESMAN_KERNEL_MODULE) 
	ld -d -r -o $@ $(LINUX_MODULE) $(RESMAN_KERNEL_MODULE)

$(VERSION_HDR): 
	echo \#define NV_COMPILER \"`$(CC) -v 2>&1 | tail -n 1`\" > $@

$(LINUX_MODULE): $(OBJECTS)
	ld -r -o $@ $(OBJECTS)

%.o: %.c $(HEADERS)
	$(CC) -c $(CFLAGS) $<

# debug tool to preprocess the file and leave .i to make it easier to untangle #defines
%.i: %.c
	$(CC) $(CFLAGS) -E $< > $@

%.s: %.c
	$(CC) $(CFLAGS) -S $< > $@


clean:
	$(RM) $(OBJECTS) $(LINUX_MODULE) $(VERSION_HDR) *.d NVdriver nvidia.o


-include $(OBJECTS:%.o=%.d)

Attachment: signature.asc
Description: This is a digitally signed message part


この情報があなたの探していたものかどうか選択してください。
yes/まさにこれだ!   no/違うなぁ   part/一部見つかった   try/これで試してみる

あなたが探していた情報はどのようなことか、ご自由に記入下さい。特に「まさにこれだ!」と言う場合は記入をお願いします。
例:「複数のマシンからCATV経由でipmasqueradeを利用してWebを参照したい場合の設定について」
Follow-Ups: References: