Hi Timothy,

supporting a dynamic major was something missing indeed.
I do propose to implement it slightly different, namely first try the static major, and attempt dynamic assignment on failure.
This makes sure that systems without udev will still work.

I attached my patch..

Regarding /dev/fusion/0, a recent change suggested by a fellow mailing-lister now tries both variants. This did not yet manage to find its way in a release.

Also, I believe André Draszik provided an updated Makefile which I did not fully check yet, but you might have a look to see if it suits your needs, then I'll check it in.

Not sure why you are having problems with FCEF_ONEWAY..

Thanks for the updates,
Greets
Niels

Strelchun, Timothy wrote:
Hi guys,

Here's a patch for linux-fusion-8.1.1 that handles dynamic major number 
generation.  In the interest of quickly getting this out, I have not stripped 
the original unmodified code (which the compile will revert back to if 
INTELCE_CHANGES is not defined).

I also attached a full patch for the changes we did as described below.  Not 
all, but most of the makefile changes are to custom the package work to build 
as a subcomponent in a different build environment.

  Files:  Makefile

    Modified to allow for proper building on kernel 2.6.28

  Files:  linux/drivers/char/fusion/Makefile-2.6
          linux/drivers/char/fusion/fusiondev.c
          tests/calls.c
          tests/latency.c
          tests/throughput.c
          tests/Makefile
          Makefile

    Modified makefiles to not depend on the host's kernel because the
    target's kernel is often different than the host's kernel and was
    modifying how the compile occurred.

    Modified makefile to include IntelCE_Version.o and use DFB_FUSION_NAME
    environment variable in KERNEL_INCLUDE path.

    Modified device registration to use a dynamically allocated major number.

    Added INTELCE_CHANGES define to the Makefile.

    Modified tests to use /dev/fusion0 instead of /dev/fusion/0.

    Modified the 'calls' test to not use the FCEF_ONEWAY flag, which caused
    failures on the FUSION_CALL_RETURN ioctl.

Regards,
Timothy

--

Timothy Strelchun
CE Software Engineering
Digital Home Group
Intel Corporation

The views expressed above are my own and not those of Intel

-----Original Message-----
From: directfb-dev-boun...@directfb.org [mailto:directfb-dev-boun...@directfb.org] On Behalf Of Niels Roest
Sent: Tuesday, November 10, 2009 1:02 PM
To: Mark
Cc: directfb-dev@directfb.org
Subject: Re: [directfb-dev] Device ID issue in linux-fusion module

As a quick comment:

The device ID is indeed fixed, this is the "old fashioned" way of assigning device IDs. In recent desktop linux environments the major number is now normally configurable, the linux-fusion driver should be updatable to support that. Note that some embedded devices do not support this, and embedded systems in general do not suffer as strongly from major number clogging as desktop systems. Open for patches though..

Greets
Niels
------------------------------------------------------------------------

_______________________________________________
directfb-dev mailing list
directfb-dev@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev


--

.------------------------------------------.
| DirectFB - Hardware accelerated graphics |
| http://www.directfb.org/                 |
"------------------------------------------"
# for native builds:
# make modules modules_install
# make KERNELDIR=<not currently running kernel's build tree> modules 
modules_install
# make KERNEL_VERSION=<uname -r of the not currently running kernel> modules 
modules_install
#
# for cross builds, using standard kernel make environment, i.e.
# make KERNELDIR=<linux build tree> INSTALL_MOD_PATH=<target root fs> modules 
modules_install

KERNEL_VERSION   ?= $(shell uname -r)
INSTALL_MOD_PATH ?= /
KERNELDIR        ?= $(INSTALL_MOD_PATH)/lib/modules/$(KERNEL_VERSION)/build

KERNEL_BUILD  = $(KERNELDIR)
KERNEL_SOURCE = $(shell grep ^KERNELSRC $(KERNEL_BUILD)/Makefile | cut -d ' ' 
-f 6)
ifneq ($(KERNEL_SOURCE), )
  K_VERSION    = $(shell grep '^VERSION =' $(KERNEL_SOURCE)/Makefile | cut -d ' 
' -f 3)
  K_PATCHLEVEL = $(shell grep '^PATCHLEVEL =' $(KERNEL_SOURCE)/Makefile | cut 
-d ' ' -f 3)
  K_SUBLEVEL   = $(shell grep '^SUBLEVEL =' $(KERNEL_SOURCE)/Makefile | cut -d 
' ' -f 3)
else
  K_VERSION    = $(shell grep '^VERSION =' $(KERNEL_BUILD)/Makefile | cut -d ' 
' -f 3)
  K_PATCHLEVEL = $(shell grep '^PATCHLEVEL =' $(KERNEL_BUILD)/Makefile | cut -d 
' ' -f 3)
  K_SUBLEVEL   = $(shell grep '^SUBLEVEL =' $(KERNEL_BUILD)/Makefile | cut -d ' 
' -f 3)
endif

SUB    = linux/drivers/char/fusion
SUBMOD = drivers/char/fusion

export CONFIG_FUSION_DEVICE=m


ifeq ($(DEBUG),yes)
  CPPFLAGS += -DFUSION_DEBUG_SKIRMISH_DEADLOCK
endif

ifeq ($(shell test -e $(KERNEL_BUILD)/include/linux/autoconf.h && echo yes),yes)
  AUTOCONF_H = -include $(KERNEL_BUILD)/include/linux/autoconf.h
endif

ifeq ($(shell test -e $(KERNEL_BUILD)/include/linux/config.h && echo yes),yes)
  CPPFLAGS += -DHAVE_LINUX_CONFIG_H
endif

check-version = $(shell expr \( $(K_VERSION) \* 65536 + $(K_PATCHLEVEL) \* 256 
+ $(K_SUBLEVEL) \) \>= \( $(1) \* 65536 + $(2) \* 256 + $(3) \))

.PHONY: all modules modules_install install clean

all: modules
install: modules_install headers_install

modules:
        rm -f $(SUB)/Makefile
        ln -s Makefile-2.$(K_PATCHLEVEL) $(SUB)/Makefile
        echo kernel is in $(KERNEL_SOURCE) and version is $(K_SUBLEVEL)
ifeq ($(call check-version,2,6,24),1)
        $(MAKE) -C $(KERNEL_BUILD) \
                KCPPFLAGS="$(CPPFLAGS) -I`pwd`/linux/include" \
                SUBDIRS=`pwd`/$(SUB) modules
else
        $(MAKE) -C $(KERNEL_BUILD) \
                CPPFLAGS="$(CPPFLAGS) -D__KERNEL__ -I`pwd`/linux/include 
-I$(KERNEL_BUILD)/include -I$(KERNEL_BUILD)/include2 -I$(KERNEL_SOURCE)/include 
$(AUTOCONF_H)" \
                SUBDIRS=`pwd`/$(SUB) modules
endif

modules_install: modules
ifeq ($(K_PATCHLEVEL),4)
        install -d 
$(INSTALL_MOD_PATH)/lib/modules/$(KERNEL_VERSION)/drivers/char/fusion
        install -m 644 $(SUB)/fusion.o 
$(INSTALL_MOD_PATH)/lib/modules/$(KERNEL_VERSION)/drivers/char/fusion
        rm -f $(INSTALL_MOD_PATH)/lib/modules/$(KERNEL_VERSION)/fusion.o
        /sbin/depmod -ae -b $(INSTALL_MOD_PATH) $(KERNEL_VERSION)
else
ifeq ($(call check-version,2,6,24),1)
        $(MAKE) -C $(KERNEL_BUILD) \
                KCPPFLAGS="$(CPPFLAGS) -I`pwd`/linux/include" \
                INSTALL_MOD_DIR="$(SUBMOD)" \
                SUBDIRS=`pwd`/$(SUB) modules_install
else
        $(MAKE) -C $(KERNEL_BUILD) \
                CPPFLAGS="$(CPPFLAGS) -D__KERNEL__ -I`pwd`/linux/include 
-I$(KERNEL_BUILD)/include -I$(KERNEL_BUILD)/include2 -I$(KERNEL_SOURCE)/include 
$(AUTOCONF_H)" \
                SUBDIRS=`pwd`/$(SUB) modules_install
endif
endif

headers_install:
        install -d $(INSTALL_MOD_PATH)/usr/include/linux
        install -m 644 linux/include/linux/fusion.h 
$(INSTALL_MOD_PATH)/usr/include/linux



clean:
        find $(SUB) -name *.o -o -name *.ko -o -name .*.o.cmd -o \
                -name fusion.mod.* -o -name .fusion.* | xargs rm -f
        rm -f $(SUB)/Makefile
commit a32de7e9d4e68304159ff144a71ee26b18d6cd41
Author: Niels Roest <ni...@directfb.org>
Date:   Mon Nov 16 19:31:46 2009 +0100

    registering: allow dynamic major (fallback if static major is taken)

diff --git a/linux/drivers/char/fusion/fusiondev.c b/linux/drivers/char/fusion/fusiondev.c
index eb77a19..93cd93e 100644
--- a/linux/drivers/char/fusion/fusiondev.c
+++ b/linux/drivers/char/fusion/fusiondev.c
@@ -65,6 +65,8 @@ MODULE_AUTHOR("Denis Oliver Kropp <d...@directfb.org>");
 
 struct proc_dir_entry *proc_fusion_dir;
 
+static int fusion_major = FUSION_MAJOR;
+
 #define NUM_MINORS 8
 
 static FusionDev *fusion_devs[NUM_MINORS] = { 0 };
@@ -1117,10 +1119,16 @@ static int __init register_devices(void)
 {
 	int i;
 
-	if (register_chrdev(FUSION_MAJOR, "fusion", &fusion_fops)) {
-		printk(KERN_ERR "fusion: unable to get major %d\n",
-		       FUSION_MAJOR);
-		return -EIO;
+	fusion_major = FUSION_MAJOR;
+
+	if (register_chrdev(fusion_major, "fusion", &fusion_fops)) {
+		fusion_major = register_chrdev(0, "fusion", &fusion_fops);
+		if (fusion_major <= 0) {
+			printk (KERN_ERR "fusion: unable to register fusion device\n");
+			return -EIO;
+		}
+		printk(KERN_ERR "fusion: unable to register major %d. "
+		                "Registered %d instead\n", FUSION_MAJOR, fusion_major);
 	}
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 2)
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
@@ -1129,7 +1137,7 @@ static int __init register_devices(void)
 	fusion_class = class_simple_create(THIS_MODULE, "fusion");
 #endif
 	if (IS_ERR(fusion_class)) {
-		unregister_chrdev(FUSION_MAJOR, "fusion");
+		unregister_chrdev(fusion_major, "fusion");
 		return PTR_ERR(fusion_class);
 	}
 #endif
@@ -1142,27 +1150,27 @@ static int __init register_devices(void)
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
 		device_create(fusion_class,
 			      NULL,
-			      MKDEV(FUSION_MAJOR, i), NULL, "fusion%d", i);
+			      MKDEV(fusion_major, i), NULL, "fusion%d", i);
 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
 		device_create(fusion_class,
-			      NULL, MKDEV(FUSION_MAJOR, i), "fusion%d", i);
+			      NULL, MKDEV(fusion_major, i), "fusion%d", i);
 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)
 		class_device_create(fusion_class,
 				    NULL,
-				    MKDEV(FUSION_MAJOR, i),
+				    MKDEV(fusion_major, i),
 				    NULL, "fusion%d", i);
 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
 		class_device_create(fusion_class,
-				    MKDEV(FUSION_MAJOR, i),
+				    MKDEV(fusion_major, i),
 				    NULL, "fusion%d", i);
 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 2)
 		class_simple_device_add(fusion_class,
-					MKDEV(FUSION_MAJOR, i),
+					MKDEV(fusion_major, i),
 					NULL, "fusion%d", i);
 #endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
-		devfs_mk_cdev(MKDEV(FUSION_MAJOR, i),
+		devfs_mk_cdev(MKDEV(fusion_major, i),
 			      S_IFCHR | S_IRUSR | S_IWUSR, "fusion/%d", i);
 #endif
 	}
@@ -1175,9 +1183,9 @@ static int __init register_devices(void)
 	int i;
 	char buf[16];
 
-	if (devfs_register_chrdev(FUSION_MAJOR, "fusion", &fusion_fops)) {
+	if (devfs_register_chrdev(fusion_major, "fusion", &fusion_fops)) {
 		printk(KERN_ERR "fusion: unable to get major %d\n",
-		       FUSION_MAJOR);
+		       fusion_major);
 		return -EIO;
 	}
 
@@ -1185,7 +1193,7 @@ static int __init register_devices(void)
 		snprintf(buf, 16, "fusion/%d", i);
 
 		devfs_handles[i] = devfs_register(NULL, buf, DEVFS_FL_DEFAULT,
-						  FUSION_MAJOR, i,
+						  fusion_major, i,
 						  S_IFCHR | S_IRUSR | S_IWUSR,
 						  &fusion_fops, NULL);
 	}
@@ -1214,16 +1222,16 @@ static void __exit deregister_devices(void)
 {
 	int i;
 
-	unregister_chrdev(FUSION_MAJOR, "fusion");
+	unregister_chrdev(fusion_major, "fusion");
 
 	for (i = 0; i < NUM_MINORS; i++) {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 2)
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
-		device_destroy(fusion_class, MKDEV(FUSION_MAJOR, i));
+		device_destroy(fusion_class, MKDEV(fusion_major, i));
 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
-		class_device_destroy(fusion_class, MKDEV(FUSION_MAJOR, i));
+		class_device_destroy(fusion_class, MKDEV(fusion_major, i));
 #else
-		class_simple_device_remove(MKDEV(FUSION_MAJOR, i));
+		class_simple_device_remove(MKDEV(fusion_major, i));
 #endif
 #endif
 
@@ -1249,7 +1257,7 @@ static void __exit deregister_devices(void)
 {
 	int i;
 
-	devfs_unregister_chrdev(FUSION_MAJOR, "fusion");
+	devfs_unregister_chrdev(fusion_major, "fusion");
 
 	for (i = 0; i < NUM_MINORS; i++)
 		devfs_unregister(devfs_handles[i]);
_______________________________________________
directfb-dev mailing list
directfb-dev@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to