2005-05-16 23:15:45

by Matt Mackall

[permalink] [raw]
Subject: Re: serial console

On Mon, May 16, 2005 at 01:57:31PM -0700, Matt Mackall wrote:
> On Mon, May 16, 2005 at 02:16:55PM -0700, YhLu wrote:
> > it says
> >
> > drivers/built-in.o(.init.text+0x1b68): In function
> > `serial8250_start_console':
> > : undefined reference to `add_preferred_console'
> >
> > add_preferred_console is defined in printk.c
>
> Ahh. Turn CONFIG_PRINTK back on and it should work. This is broken in
> mainline too, I need to find time to fix it.

This should fix it (against 2.6.12-rc4, should apply cleanly to the
last -tiny release as well):

Fix compile bug with serial console and printk disabled.

Signed-off-by: Matt Mackall <[email protected]>

Index: l-p/kernel/printk.c
===================================================================
--- l-p.orig/kernel/printk.c 2005-05-16 15:13:51.000000000 -0700
+++ l-p/kernel/printk.c 2005-05-16 15:29:56.000000000 -0700
@@ -665,6 +665,11 @@ asmlinkage long sys_syslog(int type, cha
return 0;
}

+int __init add_preferred_console(char *name, int idx, char *options)
+{
+ return 0;
+}
+
int do_syslog(int type, char __user * buf, int len) { return 0; }
static void call_console_drivers(unsigned long start, unsigned long end) {}




--
Mathematics is the supreme nostalgia of our time.


2005-05-16 23:36:32

by Andrew Morton

[permalink] [raw]
Subject: Re: serial console

Matt Mackall <[email protected]> wrote:
>
> Fix compile bug with serial console and printk disabled.
>
> Signed-off-by: Matt Mackall <[email protected]>
>
> Index: l-p/kernel/printk.c
> ===================================================================
> --- l-p.orig/kernel/printk.c 2005-05-16 15:13:51.000000000 -0700
> +++ l-p/kernel/printk.c 2005-05-16 15:29:56.000000000 -0700
> @@ -665,6 +665,11 @@ asmlinkage long sys_syslog(int type, cha
> return 0;
> }
>
> +int __init add_preferred_console(char *name, int idx, char *options)
> +{
> + return 0;
> +}
> +

It would be nicer if this was a static inline, so all the function call
code at the callsites is removed by the compiler.

Yes, it's presumably __init code anyway, but that's no excuse ;)

2005-05-16 23:48:33

by Matt Mackall

[permalink] [raw]
Subject: Re: serial console

On Mon, May 16, 2005 at 04:37:12PM -0700, Andrew Morton wrote:
>
> It would be nicer if this was a static inline, so all the function call
> code at the callsites is removed by the compiler.

Better yet, a patch that's actually right. add_preferred_console is
setting the console used by init and so on, so it's still relevant
with CONFIG_PRINTK off. So I just move it out of the ifdef. Obviously
more correct(tm).


Move add_preferred_console out of CONFIG_PRINTK so serial console does
the right thing.

Signed-off-by: Matt Mackall <[email protected]>

Index: l-p/kernel/printk.c
===================================================================
--- l-p.orig/kernel/printk.c 2005-05-16 16:37:15.000000000 -0700
+++ l-p/kernel/printk.c 2005-05-16 16:40:31.000000000 -0700
@@ -160,42 +160,6 @@ static int __init console_setup(char *st

__setup("console=", console_setup);

-/**
- * add_preferred_console - add a device to the list of preferred consoles.
- *
- * The last preferred console added will be used for kernel messages
- * and stdin/out/err for init. Normally this is used by console_setup
- * above to handle user-supplied console arguments; however it can also
- * be used by arch-specific code either to override the user or more
- * commonly to provide a default console (ie from PROM variables) when
- * the user has not supplied one.
- */
-int __init add_preferred_console(char *name, int idx, char *options)
-{
- struct console_cmdline *c;
- int i;
-
- /*
- * See if this tty is not yet registered, and
- * if we have a slot free.
- */
- for(i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++)
- if (strcmp(console_cmdline[i].name, name) == 0 &&
- console_cmdline[i].index == idx) {
- selected_console = i;
- return 0;
- }
- if (i == MAX_CMDLINECONSOLES)
- return -E2BIG;
- selected_console = i;
- c = &console_cmdline[i];
- memcpy(c->name, name, sizeof(c->name));
- c->name[sizeof(c->name) - 1] = 0;
- c->options = options;
- c->index = idx;
- return 0;
-}
-
static int __init log_buf_len_setup(char *str)
{
unsigned long size = memparse(str, &str);
@@ -671,6 +635,42 @@ static void call_console_drivers(unsigne
#endif

/**
+ * add_preferred_console - add a device to the list of preferred consoles.
+ *
+ * The last preferred console added will be used for kernel messages
+ * and stdin/out/err for init. Normally this is used by console_setup
+ * above to handle user-supplied console arguments; however it can also
+ * be used by arch-specific code either to override the user or more
+ * commonly to provide a default console (ie from PROM variables) when
+ * the user has not supplied one.
+ */
+int __init add_preferred_console(char *name, int idx, char *options)
+{
+ struct console_cmdline *c;
+ int i;
+
+ /*
+ * See if this tty is not yet registered, and
+ * if we have a slot free.
+ */
+ for(i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++)
+ if (strcmp(console_cmdline[i].name, name) == 0 &&
+ console_cmdline[i].index == idx) {
+ selected_console = i;
+ return 0;
+ }
+ if (i == MAX_CMDLINECONSOLES)
+ return -E2BIG;
+ selected_console = i;
+ c = &console_cmdline[i];
+ memcpy(c->name, name, sizeof(c->name));
+ c->name[sizeof(c->name) - 1] = 0;
+ c->options = options;
+ c->index = idx;
+ return 0;
+}
+
+/**
* acquire_console_sem - lock the console system for exclusive use.
*
* Acquires a semaphore which guarantees that the caller has


--
Mathematics is the supreme nostalgia of our time.

2005-05-17 01:24:28

by Coywolf Qi Hunt

[permalink] [raw]
Subject: Re: serial console

On 5/17/05, Matt Mackall <[email protected]> wrote:
> On Mon, May 16, 2005 at 04:37:12PM -0700, Andrew Morton wrote:
> >
> > It would be nicer if this was a static inline, so all the function call
> > code at the callsites is removed by the compiler.
>
> Better yet, a patch that's actually right. add_preferred_console is
> setting the console used by init and so on, so it's still relevant
> with CONFIG_PRINTK off. So I just move it out of the ifdef. Obviously
> more correct(tm).
>
> Move add_preferred_console out of CONFIG_PRINTK so serial console does
> the right thing.


What's the purpose of serial console if printk is disabled? I suggest
we put add_preferred_console and all its callers, console code etc
into CONFIG_PRINTK.

--
Coywolf Qi Hunt
http://sosdg.org/~coywolf/

2005-05-17 02:26:54

by Matt Mackall

[permalink] [raw]
Subject: Re: serial console

On Tue, May 17, 2005 at 09:24:23AM +0800, Coywolf Qi Hunt wrote:
> On 5/17/05, Matt Mackall <[email protected]> wrote:
> > On Mon, May 16, 2005 at 04:37:12PM -0700, Andrew Morton wrote:
> > >
> > > It would be nicer if this was a static inline, so all the function call
> > > code at the callsites is removed by the compiler.
> >
> > Better yet, a patch that's actually right. add_preferred_console is
> > setting the console used by init and so on, so it's still relevant
> > with CONFIG_PRINTK off. So I just move it out of the ifdef. Obviously
> > more correct(tm).
> >
> > Move add_preferred_console out of CONFIG_PRINTK so serial console does
> > the right thing.
>
>
> What's the purpose of serial console if printk is disabled? I suggest
> we put add_preferred_console and all its callers, console code etc
> into CONFIG_PRINTK.

Serial console is currently two things: where to write kernel
messages, and the terminal init is attached to.

--
Mathematics is the supreme nostalgia of our time.

2005-05-17 02:40:47

by Coywolf Qi Hunt

[permalink] [raw]
Subject: Re: serial console

On 5/17/05, Matt Mackall <[email protected]> wrote:
> On Tue, May 17, 2005 at 09:24:23AM +0800, Coywolf Qi Hunt wrote:
> > On 5/17/05, Matt Mackall <[email protected]> wrote:
> > > On Mon, May 16, 2005 at 04:37:12PM -0700, Andrew Morton wrote:
> > > >
> > > > It would be nicer if this was a static inline, so all the function call
> > > > code at the callsites is removed by the compiler.
> > >
> > > Better yet, a patch that's actually right. add_preferred_console is
> > > setting the console used by init and so on, so it's still relevant
> > > with CONFIG_PRINTK off. So I just move it out of the ifdef. Obviously
> > > more correct(tm).
> > >
> > > Move add_preferred_console out of CONFIG_PRINTK so serial console does
> > > the right thing.
> >
> >
> > What's the purpose of serial console if printk is disabled? I suggest
> > we put add_preferred_console and all its callers, console code etc
> > into CONFIG_PRINTK.
>
> Serial console is currently two things: where to write kernel
> messages, and the terminal init is attached to.


For init, console_setup should be moved out of ifdef too, imho.

--
Coywolf Qi Hunt
http://sosdg.org/~coywolf/

2005-05-17 03:23:05

by Rob Landley

[permalink] [raw]
Subject: Re: serial console

On Monday 16 May 2005 07:15 pm, Matt Mackall wrote:

> +int __init add_preferred_console(char *name, int idx, char *options)
> +{
> + return 0;
> +}
> +

Inline that puppy please. I can be optimized away. Having it be __init makes
no sense...

Rob