public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] for Linux IRDA initialisation bug 2.4.5
@ 2001-06-01 13:32 Matt Chapman
  2001-06-01 13:59 ` Keith Owens
  0 siblings, 1 reply; 3+ messages in thread
From: Matt Chapman @ 2001-06-01 13:32 UTC (permalink / raw)
  To: Dag Brattli; +Cc: linux-kernel, linux-irda

I've found that if you compile IRDA into the kernel, irda_proto_init
gets called twice - once at do_initcalls time, and once explicitly
in do_basic_setup - eventually resulting in a hang (as
register_netdevice_notifier gets called twice with the same struct,
and it's list becomes circular).

Here's a suggested patch.

Cheers,
Matt


diff -urN linux-2.4.5/init/main.c linux-2.4.5-irdafix/init/main.c
--- linux-2.4.5/init/main.c	Wed May 23 02:35:42 2001
+++ linux-2.4.5-irdafix/init/main.c	Fri Jun  1 23:03:00 2001
@@ -61,10 +61,6 @@
 #include <linux/isapnp.h>
 #endif
 
-#ifdef CONFIG_IRDA
-#include <net/irda/irda_device.h>
-#endif
-
 #ifdef CONFIG_X86_IO_APIC
 #include <asm/smp.h>
 #endif
@@ -698,10 +694,6 @@
 	start_context_thread();
 	do_initcalls();
 
-#ifdef CONFIG_IRDA
-	irda_proto_init();
-	irda_device_init(); /* Must be done after protocol initialization */
-#endif
 #ifdef CONFIG_PCMCIA
 	init_pcmcia_ds();		/* Do this last */
 #endif
diff -urN linux-2.4.5/net/irda/af_irda.c linux-2.4.5-irdafix/net/irda/af_irda.c
--- linux-2.4.5/net/irda/af_irda.c	Sun May 20 10:47:55 2001
+++ linux-2.4.5-irdafix/net/irda/af_irda.c	Fri Jun  1 23:04:25 2001
@@ -2411,9 +2411,7 @@
 	register_netdevice_notifier(&irda_dev_notifier);
 
 	irda_init();
-#ifdef MODULE
- 	irda_device_init();  /* Called by init/main.c when non-modular */
-#endif
+ 	irda_device_init();
 	return 0;
 }
 module_init(irda_proto_init);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] for Linux IRDA initialisation bug 2.4.5
  2001-06-01 13:32 Matt Chapman
@ 2001-06-01 13:59 ` Keith Owens
  0 siblings, 0 replies; 3+ messages in thread
From: Keith Owens @ 2001-06-01 13:59 UTC (permalink / raw)
  To: Matt Chapman; +Cc: Dag Brattli, linux-kernel, linux-irda

On Fri, 1 Jun 2001 23:32:46 +1000, 
Matt Chapman <matthewc@cse.unsw.edu.au> wrote:
>I've found that if you compile IRDA into the kernel, irda_proto_init
>gets called twice - once at do_initcalls time, and once explicitly
>in do_basic_setup - eventually resulting in a hang (as
>register_netdevice_notifier gets called twice with the same struct,
>and it's list becomes circular).

The suggested patch has one non-obvious side effect which somebody in
irda needs to verify is OK.  Previously irda_proto_init() and
irda_device_init() were called after every other driver had
initialized.  Now irda_proto_init() is called based on the object order
in the top level Makefile, so irda is initialized before i2c,
telephony, acpi and mddev.  Is this a valid initialization order?  If
not, move

  DRIVERS-$(CONFIG_IRDA) += drivers/net/irda/irda.o

to the end of the drivers list and document why it needs to be there.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] for Linux IRDA initialisation bug 2.4.5
       [not found] <mailman.991404121.32135.linux-kernel2news@redhat.com>
@ 2001-06-01 19:16 ` Pete Zaitcev
  0 siblings, 0 replies; 3+ messages in thread
From: Pete Zaitcev @ 2001-06-01 19:16 UTC (permalink / raw)
  To: kaos, Matt Chapman; +Cc: Dag Brattli, linux-kernel, linux-irda

> >I've found that if you compile IRDA into the kernel, irda_proto_init
> >gets called twice - once at do_initcalls time, and once explicitly
> >in do_basic_setup - eventually resulting in a hang (as
> >register_netdevice_notifier gets called twice with the same struct,
> >and it's list becomes circular).
> 
> The suggested patch has one non-obvious side effect which somebody in
> irda needs to verify is OK.  Previously irda_proto_init() and
> irda_device_init() were called after every other driver had
> initialized.  Now irda_proto_init() is called based on the object order
> in the top level Makefile, so irda is initialized before i2c,
> telephony, acpi and mddev.  Is this a valid initialization order?  If
> not, move
> 
>   DRIVERS-$(CONFIG_IRDA) += drivers/net/irda/irda.o
> 
> to the end of the drivers list and document why it needs to be there.

Keith, you mistake Matt's fix for an "obvious" fix that turns
old style inits into new ones. Matt's fix does not change
initialization order and certainly cannot be corrected by
moving object files about.

I tried to change the thing to new style init and it did not
quite work. The original problem was fixed but now the system
hangs when it tries to initialize IP loopback. Perhaps irda0
gets in the way.

The suggestion about the link order is very relevant for the
attached patch. I need Dag to pick it where I left it.

-- Pete

diff -ur -X dontdiff linux-2.4.5/net/irda/ircomm/ircomm_core.c linux-2.4.5-tr5/net/irda/ircomm/ircomm_core.c
--- linux-2.4.5/net/irda/ircomm/ircomm_core.c	Fri Mar  2 11:12:12 2001
+++ linux-2.4.5-tr5/net/irda/ircomm/ircomm_core.c	Fri May 25 23:26:12 2001@@ -76,8 +76,7 @@
 	return 0;
 }
 
-#ifdef MODULE
-void ircomm_cleanup(void)
+void __exit ircomm_cleanup(void)
 {
 	IRDA_DEBUG(2, __FUNCTION__ "()\n");
 
@@ -87,7 +86,6 @@
 	remove_proc_entry("ircomm", proc_irda);
 #endif /* CONFIG_PROC_FS */
 }
-#endif /* MODULE */
 
 /*
  * Function ircomm_open (client_notify)
@@ -511,18 +509,8 @@
 }
 #endif /* CONFIG_PROC_FS */
 
-#ifdef MODULE
 MODULE_AUTHOR("Dag Brattli <dag@brattli.net>");
 MODULE_DESCRIPTION("IrCOMM protocol");
 
-int init_module(void) 
-{
-	return ircomm_init();
-}
-	
-void cleanup_module(void)
-{
-	ircomm_cleanup();
-}
-#endif /* MODULE */
-
+module_init(ircomm_init);
+module_exit(ircomm_cleanup);
diff -ur -X dontdiff linux-2.4.5/net/irda/ircomm/ircomm_tty.c linux-2.4.5-tr5/net/irda/ircomm/ircomm_tty.c
--- linux-2.4.5/net/irda/ircomm/ircomm_tty.c	Fri Mar  2 11:12:12 2001
+++ linux-2.4.5-tr5/net/irda/ircomm/ircomm_tty.c	Fri May 25 23:27:11 2001@@ -89,7 +89,7 @@
  *    Init IrCOMM TTY layer/driver
  *
  */
-int __init ircomm_tty_init(void)
+static int __init ircomm_tty_init(void)
 {	
 	ircomm_tty = hashbin_new(HB_LOCAL); 
 	if (ircomm_tty == NULL) {
@@ -142,8 +142,7 @@
 	return 0;
 }
 
-#ifdef MODULE
-static void __ircomm_tty_cleanup(struct ircomm_tty_cb *self)
+static void __exit __ircomm_tty_cleanup(struct ircomm_tty_cb *self)
 {
 	IRDA_DEBUG(0, __FUNCTION__ "()\n");
 
@@ -162,7 +161,7 @@
  *    Remove IrCOMM TTY layer/driver
  *
  */
-void ircomm_tty_cleanup(void)
+static void __exit ircomm_tty_cleanup(void)
 {
 	int ret;
 
@@ -176,7 +175,6 @@
 
 	hashbin_delete(ircomm_tty, (FREE_FUNC) __ircomm_tty_cleanup);
 }
-#endif /* MODULE */
 
 /*
  * Function ircomm_startup (self)
@@ -1359,22 +1357,8 @@
 }
 #endif /* CONFIG_PROC_FS */
 
-#ifdef MODULE
 MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
 MODULE_DESCRIPTION("IrCOMM serial TTY driver");
 
-int init_module(void) 
-{
-	return ircomm_tty_init();
-}
-
-void cleanup_module(void)
-{
-	ircomm_tty_cleanup();
-}
-
-#endif /* MODULE */
-
-
-
-
+module_init(ircomm_tty_init);
+module_exit(ircomm_tty_cleanup);
diff -ur -X dontdiff linux-2.4.5/net/irda/irsyms.c linux-2.4.5-tr5/net/irda/irsyms.c
--- linux-2.4.5/net/irda/irsyms.c	Sun Nov 12 20:43:11 2000
+++ linux-2.4.5-tr5/net/irda/irsyms.c	Fri May 25 23:28:47 2001
@@ -61,8 +61,6 @@
 extern int irlan_init(void);
 extern int irlan_client_init(void);
 extern int irlan_server_init(void);
-extern int ircomm_init(void);
-extern int ircomm_tty_init(void);
 extern int irlpt_client_init(void);
 extern int irlpt_server_init(void);
 
@@ -203,10 +201,6 @@
 	 */
 #ifdef CONFIG_IRLAN
 	irlan_init();
-#endif
-#ifdef CONFIG_IRCOMM
-	ircomm_init();
-	ircomm_tty_init();
 #endif
 
 #ifdef CONFIG_IRDA_COMPRESSION


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-06-01 19:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.991404121.32135.linux-kernel2news@redhat.com>
2001-06-01 19:16 ` [PATCH] for Linux IRDA initialisation bug 2.4.5 Pete Zaitcev
2001-06-01 13:32 Matt Chapman
2001-06-01 13:59 ` Keith Owens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox