linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* initcall ordering of driver w/respect to tty_init?
@ 2003-10-08  7:48 Miles Bader
  2003-10-10 15:02 ` Randy.Dunlap
  0 siblings, 1 reply; 4+ messages in thread
From: Miles Bader @ 2003-10-08  7:48 UTC (permalink / raw)
  To: linux-kernel

I have a tty driver, arch/v850/kernel/simcons.c, who's init function is
called via __initcall:

   int __init simcons_tty_init (void)
   {
           struct tty_driver *driver = alloc_tty_driver(1);
   ...
           err = tty_register_driver(driver);
   }
   __initcall (simcons_tty_init);

I'm getting errors because this init function is being called _before_
tty_init, and tty_kobj (which is the `parent' kobj of simcon's kobj) is
apparently not setup correctly yet when the simcons_tty_init calls
tty_register_driver.

Since there seems to be no way of ordering basic initcalls, I can see
why it's happening.  But what's the proper way to avoid this?  Other
tty drivers that call tty_register_driver also seem to get initialized
via initcalls (usually declared with module_init), so maybe this
problem exists for other drivers too.

Thanks,

-Miles
-- 
Come now, if we were really planning to harm you, would we be waiting here, 
 beside the path, in the very darkest part of the forest?

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

* Re: initcall ordering of driver w/respect to tty_init?
  2003-10-08  7:48 initcall ordering of driver w/respect to tty_init? Miles Bader
@ 2003-10-10 15:02 ` Randy.Dunlap
  2003-10-10 18:12   ` Miles Bader
  0 siblings, 1 reply; 4+ messages in thread
From: Randy.Dunlap @ 2003-10-10 15:02 UTC (permalink / raw)
  To: Miles Bader; +Cc: miles, linux-kernel

On 08 Oct 2003 16:48:17 +0900 Miles Bader <miles@lsi.nec.co.jp> wrote:

| I have a tty driver, arch/v850/kernel/simcons.c, who's init function is
| called via __initcall:
| 
|    int __init simcons_tty_init (void)
|    {
|            struct tty_driver *driver = alloc_tty_driver(1);
|    ...
|            err = tty_register_driver(driver);
|    }
|    __initcall (simcons_tty_init);
| 
| I'm getting errors because this init function is being called _before_
| tty_init, and tty_kobj (which is the `parent' kobj of simcon's kobj) is
| apparently not setup correctly yet when the simcons_tty_init calls
| tty_register_driver.
| 
| Since there seems to be no way of ordering basic initcalls, I can see
| why it's happening.  But what's the proper way to avoid this?  Other
| tty drivers that call tty_register_driver also seem to get initialized
| via initcalls (usually declared with module_init), so maybe this
| problem exists for other drivers too.

Does it help/work to change it to a console_initcall() ?

--
~Randy

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

* Re: initcall ordering of driver w/respect to tty_init?
  2003-10-10 15:02 ` Randy.Dunlap
@ 2003-10-10 18:12   ` Miles Bader
  2003-10-14  2:12     ` Miles Bader
  0 siblings, 1 reply; 4+ messages in thread
From: Miles Bader @ 2003-10-10 18:12 UTC (permalink / raw)
  To: Randy.Dunlap; +Cc: Miles Bader, miles, linux-kernel

On Fri, Oct 10, 2003 at 08:02:12AM -0700, Randy.Dunlap wrote:
> | I have a tty driver, arch/v850/kernel/simcons.c, who's init function is
> | called via __initcall:
> 
> Does it help/work to change it to a console_initcall() ?

I think that would solve the problem, but is it the right solution?  How
about all those other drivers that call tty_register_driver?  module_init
becomes __initcall when driver is statically linked into the kernel...

-Miles
-- 
Suburbia: where they tear out the trees and then name streets after them.

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

* Re: initcall ordering of driver w/respect to tty_init?
  2003-10-10 18:12   ` Miles Bader
@ 2003-10-14  2:12     ` Miles Bader
  0 siblings, 0 replies; 4+ messages in thread
From: Miles Bader @ 2003-10-14  2:12 UTC (permalink / raw)
  To: Randy.Dunlap; +Cc: linux-kernel

Miles Bader <miles@gnu.org> writes:
> I think that would solve the problem, but is it the right solution?  How
> about all those other drivers that call tty_register_driver?  module_init
> becomes __initcall when driver is statically linked into the kernel...

I've looked more at <linux/init.h>, and I think for my driver, which is
always statically linked, I can use `late_initcall' instead of
`__initcall' (it makes me slightly nervous to use the last init slot,
but whatever).

But what about all those tty drivers that are suppose to work as
modules?  They use `module_init' to do their initialization, which will
work fine when they _are_ a module, but if they get statically linked,
the module_init will turn into `__initcall', and run into the same
problem I'm having.  Presumably they _could_ use `late_initcall', since
<linux/init.h> contains code that makes it work in modules too, but the
comment in the code says you shouldn't do that.

[To recap: tty drivers that use module_init to initialize themselves,
which turns into __initcall if statically linked, will only work if they
happen to be initialized _after_ tty_io.c (because of the kobj stuff) --
and there seems to be nothing enforcing this ordering.]

-Miles
-- 
97% of everything is grunge

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

end of thread, other threads:[~2003-10-14  2:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-08  7:48 initcall ordering of driver w/respect to tty_init? Miles Bader
2003-10-10 15:02 ` Randy.Dunlap
2003-10-10 18:12   ` Miles Bader
2003-10-14  2:12     ` Miles Bader

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).