2007-05-19 02:02:17

by Yinghai Lu

[permalink] [raw]
Subject: [PATCH]serial: make early_uart to use early_prarm instead of console_initcall

[PATCH]serial: make early_uart to use early_prarm instead of console_initcall

Make early_uart to use early_param, so uart console can be used earlier.
Make it to be bootconsole with CON_BOOT flag, so can use console handover
feature. and it will switch to corresponding normal serial console automatically.
new command line will be

earlycon=uart,io,0x3f8,9600n8
earlycon=uart,io,0x3f8,9600n8 console=tty0

it will print in very early stage
Early serial console at I/O port 0x3f8 (options '9600n8')
later for console it will print
console handover: boot [uart0] -> real [ttyS0]

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

diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index c84dab0..75459e8 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2367,6 +2367,7 @@ static struct uart_ops serial8250_pops = {
.request_port = serial8250_request_port,
.config_port = serial8250_config_port,
.verify_port = serial8250_verify_port,
+ .find_port_for_earlycon = serial8250_find_port_for_earlycon,
};

static struct uart_8250_port serial8250_ports[UART_NR];
@@ -2533,7 +2534,7 @@ static int __init serial8250_console_init(void)
}
console_initcall(serial8250_console_init);

-static int __init find_port(struct uart_port *p)
+int __init find_port_serial8250(struct uart_port *p)
{
int line;
struct uart_port *port;
@@ -2546,26 +2547,6 @@ static int __init find_port(struct uart_port *p)
return -ENODEV;
}

-int __init serial8250_start_console(struct uart_port *port, char *options)
-{
- int line;
-
- line = find_port(port);
- if (line < 0)
- return -ENODEV;
-
- add_preferred_console("ttyS", line, options);
- printk("Adding console on ttyS%d at %s 0x%lx (options '%s')\n",
- line, port->iotype == UPIO_MEM ? "MMIO" : "I/O port",
- port->iotype == UPIO_MEM ? (unsigned long) port->mapbase :
- (unsigned long) port->iobase, options);
- if (!(serial8250_console.flags & CON_ENABLED)) {
- serial8250_console.flags &= ~CON_PRINTBUFFER;
- register_console(&serial8250_console);
- }
- return line;
-}
-
#define SERIAL8250_CONSOLE &serial8250_console
#else
#define SERIAL8250_CONSOLE NULL
diff --git a/drivers/serial/8250_early.c b/drivers/serial/8250_early.c
index 7e51119..42d4abe 100644
--- a/drivers/serial/8250_early.c
+++ b/drivers/serial/8250_early.c
@@ -17,13 +17,9 @@
* we locate the device directly by its MMIO or I/O port address.
*
* The user can specify the device directly, e.g.,
- * console=uart,io,0x3f8,9600n8
- * console=uart,mmio,0xff5e0000,115200n8
- * or platform code can call early_uart_console_init() to set
- * the early UART device.
+ * earlycon=uart,io,0x3f8,9600n8
+ * earlycon=uart,mmio,0xff5e0000,115200n8
*
- * After the normal serial driver starts, we try to locate the
- * matching ttyS device and start a console there.
*/

#include <linux/tty.h>
@@ -32,6 +28,7 @@
#include <linux/serial_core.h>
#include <linux/serial_reg.h>
#include <linux/serial.h>
+#include <linux/serial_8250.h>
#include <asm/io.h>
#include <asm/serial.h>

@@ -42,7 +39,6 @@ struct early_uart_device {
};

static struct early_uart_device early_device __initdata;
-static int early_uart_registered __initdata;

static unsigned int __init serial_in(struct uart_port *port, int offset)
{
@@ -175,6 +171,13 @@ static int __init parse_options(struct early_uart_device *device, char *options)
return 0;
}

+static struct console early_uart_console __initdata = {
+ .name = "uart",
+ .write = early_uart_write,
+ .flags = CON_PRINTBUFFER,
+ .index = -1,
+};
+
static int __init early_uart_setup(struct console *console, char *options)
{
struct early_uart_device *device = &early_device;
@@ -190,61 +193,60 @@ static int __init early_uart_setup(struct console *console, char *options)
return 0;
}

-static struct console early_uart_console __initdata = {
- .name = "uart",
- .write = early_uart_write,
- .setup = early_uart_setup,
- .flags = CON_PRINTBUFFER,
- .index = -1,
-};
-
-static int __init early_uart_console_init(void)
-{
- if (!early_uart_registered) {
- register_console(&early_uart_console);
- early_uart_registered = 1;
- }
- return 0;
-}
-console_initcall(early_uart_console_init);
-
-int __init early_serial_console_init(char *cmdline)
+static int __init setup_early_serial_console(char *cmdline)
{
char *options;
int err;

- options = strstr(cmdline, "console=uart,");
+ options = strstr(cmdline, "uart,");
if (!options)
return -ENODEV;

options = strchr(cmdline, ',') + 1;
if ((err = early_uart_setup(NULL, options)) < 0)
return err;
- return early_uart_console_init();
+
+ early_uart_console.flags |= CON_BOOT;
+ register_console(&early_uart_console);
+
+ /* add one dummy entry in console_cmdline*/
+ add_preferred_console("ttyS", 255, early_device.options);
+
+ return 0;
}

-static int __init early_uart_console_switch(void)
+int serial8250_find_port_for_earlycon(void)
{
struct early_uart_device *device = &early_device;
struct uart_port *port = &device->port;
- int mmio, line;
+ int line;

- if (!(early_uart_console.flags & CON_ENABLED))
- return 0;
+ line = find_port_serial8250(port);

- /* Try to start the normal driver on a matching line. */
- mmio = (port->iotype == UPIO_MEM);
- line = serial8250_start_console(port, device->options);
if (line < 0)
- printk("No ttyS device at %s 0x%lx for console\n",
- mmio ? "MMIO" : "I/O port",
- mmio ? port->mapbase :
- (unsigned long) port->iobase);
+ return -ENODEV;
+
+ /* update the dummy entry to what we want console type */
+ update_console_cmdline_console_index("ttyS", 255, line);
+
+ return 0;
+
+}
+
+early_param("earlycon", setup_early_serial_console);

- unregister_console(&early_uart_console);
- if (mmio)
+static int __init early_uart_console_post(void)
+{
+ struct early_uart_device *device = &early_device;
+ struct uart_port *port = &device->port;
+
+ if (!(early_uart_console.flags & CON_ENABLED))
+ return 0;
+
+ if (port->iotype == UPIO_MEM)
iounmap(port->membase);

return 0;
}
-late_initcall(early_uart_console_switch);
+
+late_initcall(early_uart_console_post);
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 315ea99..fc58473 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -62,6 +62,12 @@ config SERIAL_8250_CONSOLE
kernel will automatically use the first serial line, /dev/ttyS0, as
system console.

+ you can set that using a kernel command line option such as
+ "earlycon=uart,io,0x3f8,9600n8" or
+ "earlycon=uart,mem,0xfe000008,115200n8".
+ and it will switch to normal serial console when correponding port is
+ ready.
+
If unsure, say N.

config SERIAL_8250_GSC
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 326020f..956d435 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -2303,8 +2303,11 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *port)
* It may be that the port was not available.
*/
if (port->type != PORT_UNKNOWN &&
- port->cons && !(port->cons->flags & CON_ENABLED))
+ port->cons && !(port->cons->flags & CON_ENABLED)) {
+ if(port->ops && port->ops->find_port_for_earlycon)
+ port->ops->find_port_for_earlycon();
register_console(port->cons);
+ }

/*
* Ensure UPF_DEAD is not set.
diff --git a/include/linux/console.h b/include/linux/console.h
index 62ef6e1..4cb7749 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -107,6 +107,7 @@ struct console {
};

extern int add_preferred_console(char *name, int idx, char *options);
+extern int update_console_cmdline_console_index(char *name, int idx_old, int idx_new);
extern void register_console(struct console *);
extern int unregister_console(struct console *);
extern struct console *console_drivers;
diff --git a/include/linux/serial.h b/include/linux/serial.h
index 33fc8cb..deb7143 100644
--- a/include/linux/serial.h
+++ b/include/linux/serial.h
@@ -177,11 +177,5 @@ struct serial_icounter_struct {
#ifdef __KERNEL__
#include <linux/compiler.h>

-/* Allow architectures to override entries in serial8250_ports[] at run time: */
-struct uart_port; /* forward declaration */
-extern int early_serial_setup(struct uart_port *port);
-extern int early_serial_console_init(char *options);
-extern int serial8250_start_console(struct uart_port *port, char *options);
-
#endif /* __KERNEL__ */
#endif /* _LINUX_SERIAL_H */
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index 71310d8..0d79fc5 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -60,4 +60,7 @@ void serial8250_unregister_port(int line);
void serial8250_suspend_port(int line);
void serial8250_resume_port(int line);

+extern int find_port_serial8250(struct uart_port *p);
+extern int serial8250_find_port_for_earlycon(void);
+
#endif
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index a3ac4c8..b74fa4a 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -199,6 +199,11 @@ struct uart_ops {
void (*config_port)(struct uart_port *, int);
int (*verify_port)(struct uart_port *, struct serial_struct *);
int (*ioctl)(struct uart_port *, unsigned int, unsigned long);
+
+ /*
+ * for earlycon to console switch
+ */
+ int (*find_port_for_earlycon)(void);
};

#define UART_CONFIG_TYPE (1 << 0)
diff --git a/init/main.c b/init/main.c
diff --git a/kernel/printk.c b/kernel/printk.c
index 0bbdeac..253c0f7 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -726,6 +726,21 @@ int __init add_preferred_console(char *name, int idx, char *options)
return 0;
}

+int __init update_console_cmdline_console_index(char *name, int idx_old, int idx_new)
+{
+ int i;
+
+ 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_old) {
+ console_cmdline[i].index = idx_new;
+ return 0;
+ }
+
+ return 0;
+}
+
+
#ifndef CONFIG_DISABLE_CONSOLE_SUSPEND
/**
* suspend_console - suspend the console subsystem


2007-05-21 03:26:54

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH]serial: make early_uart to use early_prarm instead of console_initcall

On Fri, 18 May 2007 19:00:16 -0700 Yinghai Lu <[email protected]> wrote:

> [PATCH]serial: make early_uart to use early_prarm instead of console_initcall
>
> Make early_uart to use early_param, so uart console can be used earlier.
> Make it to be bootconsole with CON_BOOT flag, so can use console handover
> feature. and it will switch to corresponding normal serial console automatically.
> new command line will be
>
> earlycon=uart,io,0x3f8,9600n8
> earlycon=uart,io,0x3f8,9600n8 console=tty0
>
> it will print in very early stage
> Early serial console at I/O port 0x3f8 (options '9600n8')
> later for console it will print
> console handover: boot [uart0] -> real [ttyS0]

I'll queue this up for some testing, but I'd be a bit reluctant to send it
into Linus due to my poor understanding of what it actually does. What
_is_ an early console, and how does it differ from a non-early one?

Someone help, please.

Coudl you please provide a patch against
Documentation/kernel-parameters.txt as well?

2007-05-21 04:29:30

by Yinghai Lu

[permalink] [raw]
Subject: Re: [PATCH]serial: make early_uart to use early_prarm instead of console_initcall

On 5/20/07, Andrew Morton <[email protected]> wrote:
> I'll queue this up for some testing, but I'd be a bit reluctant to send it
> into Linus due to my poor understanding of what it actually does. What
> _is_ an early console, and how does it differ from a non-early one?
>
> Someone help, please.
>
> Coudl you please provide a patch against
> Documentation/kernel-parameters.txt as well?
>
the story:
Bjorn refer to andi's early_printk to create one early_uart. it took
console=uart,io,0x3f8,9600n8
or console=uart,mem,0xfxxx,115200n8.
and it is called via console_init. --- it is not really early uart for
platform other than ia64.
ia64 call early_serial_console_init explicitly, so it is some early.
but it needs to late_initcall to do console switch.

Gerd's patch (console handover) was merged into mainline. it will
switch from early_printk to normal console in register_console via
CON_BOOT flags.. ===> only for x86

I produced one patch to change early_uart calling from console_init to
early_param. So to make early_uart to real early_uart for all other
platform in addition to ia64.
it will take
earlycon=uart,io,0x3f8,9600n8 console=ttyS0,9600n8

but Bjorn said that don't let the customer to key two times about
console command line.
Then come this patch. will take
earlycon=uart,io,0x3f8,9600n8
and it will switch to console ttyS0 automatically. ---- by calling
add_preferred_console.

Still need Bjorn to:
1. remove early_serial_console_init call in ia64 setup_arch.
2. verify mem io 8250 compatiable card.

for 2, in x86 platform we need to use fix_to_virt and fix map to give
it one fixed virtual address. == like Eric did for usb debug port
console.

I will send out another in email about updated early dbgp console with
current tree.

YH

2007-05-21 04:50:38

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH]serial: make early_uart to use early_prarm instead of console_initcall

On Sun, 20 May 2007 21:29:20 -0700 "Yinghai Lu" <[email protected]> wrote:

> On 5/20/07, Andrew Morton <[email protected]> wrote:
> > I'll queue this up for some testing, but I'd be a bit reluctant to send it
> > into Linus due to my poor understanding of what it actually does. What
> > _is_ an early console, and how does it differ from a non-early one?
> >
> > Someone help, please.
> >
> > Coudl you please provide a patch against
> > Documentation/kernel-parameters.txt as well?
> >
> the story:
> Bjorn refer to andi's early_printk to create one early_uart. it took
> console=uart,io,0x3f8,9600n8
> or console=uart,mem,0xfxxx,115200n8.
> and it is called via console_init. --- it is not really early uart for
> platform other than ia64.
> ia64 call early_serial_console_init explicitly, so it is some early.
> but it needs to late_initcall to do console switch.
>
> Gerd's patch (console handover) was merged into mainline. it will
> switch from early_printk to normal console in register_console via
> CON_BOOT flags.. ===> only for x86
>
> I produced one patch to change early_uart calling from console_init to
> early_param. So to make early_uart to real early_uart for all other
> platform in addition to ia64.
> it will take
> earlycon=uart,io,0x3f8,9600n8 console=ttyS0,9600n8
>
> but Bjorn said that don't let the customer to key two times about
> console command line.
> Then come this patch. will take
> earlycon=uart,io,0x3f8,9600n8
> and it will switch to console ttyS0 automatically. ---- by calling
> add_preferred_console.
>
> Still need Bjorn to:
> 1. remove early_serial_console_init call in ia64 setup_arch.
> 2. verify mem io 8250 compatiable card.
>
> for 2, in x86 platform we need to use fix_to_virt and fix map to give
> it one fixed virtual address. == like Eric did for usb debug port
> console.
>
> I will send out another in email about updated early dbgp console with
> current tree.

hm, OK. I hope you guys have it under control ;)


With http://userweb.kernel.org/~akpm/config-vmm.txt I get

drivers/built-in.o:(.data+0x5790): undefined reference to `serial8250_find_port_for_earlycon'

2007-05-21 06:56:49

by Yinghai Lu

[permalink] [raw]
Subject: Re: [PATCH]serial: make early_uart to use early_prarm instead of console_initcall

On 5/20/07, Andrew Morton <[email protected]> wrote:
> hm, OK. I hope you guys have it under control ;)
>
>
> With http://userweb.kernel.org/~akpm/config-vmm.txt I get
>
> drivers/built-in.o:(.data+0x5790): undefined reference to `serial8250_find_port_for_earlycon'
>

please check this one

Bjorn,
I can not find fixmap.h for ia64.....hope you can use ioremap instead,
then we can create one dummy fixmap.h in include/asm-ia64

[PATCH]serial: make early_uart to use early_prarm instead of console_initcall

Make early_uart to use early_param, so uart console can be used earlier.
Make it to be bootconsole with CON_BOOT flag, so can use console handover
feature. and it will switch to corresponding normal serial console
automatically.
new command line will be

earlycon=uart,io,0x3f8,9600n8
earlycon=uart,io,0x3f8,9600n8 console=tty0
earlycon=uart,mmio,0xff5e0000,115200n8

it will print in very early stage
Early serial console at I/O port 0x3f8 (options '9600n8')
later for console it will print
console handover: boot [uart0] -> real [ttyS0]

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


Attachments:
(No filename) (1.07 kB)
earlycon_05202007.diff (12.90 kB)
Download all attachments

2007-05-21 09:45:36

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH]serial: make early_uart to use early_prarm instead of console_initcall

On Sun, May 20, 2007 at 08:23:32PM -0700, Andrew Morton wrote:
> On Fri, 18 May 2007 19:00:16 -0700 Yinghai Lu <[email protected]> wrote:
>
> > [PATCH]serial: make early_uart to use early_prarm instead of console_initcall
> >
> > Make early_uart to use early_param, so uart console can be used earlier.
> > Make it to be bootconsole with CON_BOOT flag, so can use console handover
> > feature. and it will switch to corresponding normal serial console automatically.
> > new command line will be
> >
> > earlycon=uart,io,0x3f8,9600n8
> > earlycon=uart,io,0x3f8,9600n8 console=tty0
> >
> > it will print in very early stage
> > Early serial console at I/O port 0x3f8 (options '9600n8')
> > later for console it will print
> > console handover: boot [uart0] -> real [ttyS0]
>
> I'll queue this up for some testing, but I'd be a bit reluctant to send it
> into Linus due to my poor understanding of what it actually does. What
> _is_ an early console, and how does it differ from a non-early one?

It is someone's reimplemention of earlyprintk= for another architecture
that happens to mostly work on x86 too because the code is not ifdeffed.
I don't think it makes much sense on x86 though because earlyprintk exists.

-Andi

2007-05-21 10:24:22

by Gerd Hoffmann

[permalink] [raw]
Subject: Re: [PATCH]serial: make early_uart to use early_prarm instead of console_initcall

Yinghai Lu wrote:
> Gerd's patch (console handover) was merged into mainline. it will
> switch from early_printk to normal console in register_console via
> CON_BOOT flags.. ===> only for x86

Tagging boot consoles (aka early_printk) with CON_BOOT certainly makes
sense. Just doing that doesn't work for ia64?

What is the point in making that work on x86 additionally to serial
support in early_printk? It might make sense to split away the serial
bits from early_printk.c and move them out of arch/ into -- say --
drivers/serial/, so other architectures can use that too and we have
only one serial earlyprintk implementation in the kernel. Not sure it
is worth the effort given the code size.

cheers,
Gerd


2007-05-21 16:27:44

by Bjorn Helgaas

[permalink] [raw]
Subject: Re: [PATCH]serial: make early_uart to use early_prarm instead of console_initcall

On Monday 21 May 2007 04:42:21 am Andi Kleen wrote:
> On Sun, May 20, 2007 at 08:23:32PM -0700, Andrew Morton wrote:
> > I'll queue this up for some testing, but I'd be a bit reluctant to send it
> > into Linus due to my poor understanding of what it actually does. What
> > _is_ an early console, and how does it differ from a non-early one?
>
> It is someone's reimplemention of earlyprintk= for another architecture

I implemented 8250_early for ia64. It is based on early_printk and
is quite similar to it.

One important difference is that early_printk has the "ttyS0 is at
0x3f8" knowledge compiled into it. That doesn't work for ia64
because ttyS0 may be anywhere.

Since 8250_early doesn't assume the ttyS locations, you have to tell
it the device address, not the name. Some ia64 firmware tells the OS
the address of the console device. With 8250_early, if the user wants
the OS to use the same console as the firmware, he doesn't need any
"console=" argument at all.

The other important difference is that 8250_early tries to coordinate
with the normal 8250 console driver. For example, if you use
"console=uart,io,0x3f8", 8250_early works like early_printk does,
and then automatically switches to the normal 8250 driver later. With
early_printk, I think you would have to use "earlyprintk=serial,ttyS0
console=ttyS0" to do the same thing.

> that happens to mostly work on x86 too because the code is not ifdeffed.

8250_early has no arch dependency, so there's no reason to ifdef it.
It only depends on ioremap/inb/outb/readb/writeb.

> I don't think it makes much sense on x86 though because earlyprintk exists.

There are two reasons 8250_early might make sense on x86:

- x86 firmware might someday tell the OS where the console is
(e.g., via drivers/firmware/pcdp.c). That requires a way to
locate the device by its address, not by the name.

- You only have to specify the console device once, not twice.

On the other hand, maybe you *want* the earlyprintk device to be
a different device than the regular console. 8250_early wouldn't
handle that very well.

Bjorn

2007-05-21 16:27:58

by Bjorn Helgaas

[permalink] [raw]
Subject: Re: [PATCH]serial: make early_uart to use early_prarm instead of console_initcall

On Monday 21 May 2007 04:42:21 am Andi Kleen wrote:
> On Sun, May 20, 2007 at 08:23:32PM -0700, Andrew Morton wrote:
> > I'll queue this up for some testing, but I'd be a bit reluctant to send it
> > into Linus due to my poor understanding of what it actually does. What
> > _is_ an early console, and how does it differ from a non-early one?
>
> It is someone's reimplemention of earlyprintk= for another architecture

I implemented 8250_early for ia64. It is based on early_printk and
is quite similar to it.

One important difference is that early_printk has the "ttyS0 is at
0x3f8" knowledge compiled into it. That doesn't work for ia64
because ttyS0 may be anywhere.

Since 8250_early doesn't assume the ttyS locations, you have to tell
it the device address, not the name. Some ia64 firmware tells the OS
the address of the console device. With 8250_early, if the user wants
the OS to use the same console as the firmware, he doesn't need any
"console=" argument at all.

The other important difference is that 8250_early tries to coordinate
with the normal 8250 console driver. For example, if you use
"console=uart,io,0x3f8", 8250_early works like early_printk does,
and then automatically switches to the normal 8250 driver later. With
early_printk, I think you would have to use "earlyprintk=serial,ttyS0
console=ttyS0" to do the same thing.

> that happens to mostly work on x86 too because the code is not ifdeffed.

8250_early has no arch dependency, so there's no reason to ifdef it.
It only depends on ioremap/inb/outb/readb/writeb.

> I don't think it makes much sense on x86 though because earlyprintk exists.

There are two reasons 8250_early might make sense on x86:

- x86 firmware might someday tell the OS where the console is
(e.g., via drivers/firmware/pcdp.c). That requires a way to
locate the device by its address, not by the name.

- You only have to specify the console device once, not twice.

On the other hand, maybe you *want* the earlyprintk device to be
a different device than the regular console. 8250_early wouldn't
handle that very well.

Bjorn

2007-05-21 16:29:18

by Yinghai Lu

[permalink] [raw]
Subject: Re: [PATCH]serial: make early_uart to use early_prarm instead of console_initcall

Andi Kleen wrote:
> It is someone's reimplemention of earlyprintk= for another architecture
> that happens to mostly work on x86 too because the code is not ifdeffed.
> I don't think it makes much sense on x86 though because earlyprintk exists.

Andi,

Bjorn refer to your early_printk to implement early_uart for ia64 platform. code is almost identical, but it could take
mmio,0xfe00000,9600n8 etc. or say mmio type serial card.

YH

2007-05-21 16:40:05

by Yinghai Lu

[permalink] [raw]
Subject: Re: [PATCH]serial: make early_uart to use early_prarm instead of console_initcall

On 5/21/07, Gerd Hoffmann <[email protected]> wrote:
> What is the point in making that work on x86 additionally to serial
> support in early_printk? It might make sense to split away the serial
> bits from early_printk.c and move them out of arch/ into -- say --
> drivers/serial/, so other architectures can use that too and we have
> only one serial earlyprintk implementation in the kernel. Not sure it
> is worth the effort given the code size.

yes, we can drop serial bits from early_printk.c, and use
drivers/serial/8250_early.c and
with "earlycon=uart,io,0x3f8,9600n8", "early=ueart,mmio,0xfe000000,9600n8"

and we can extend other non 8250 compatitable uart to some *_early.c
in the same dir.
So other platform and other uart could be happy to get early console.

YH

2007-05-21 16:53:36

by Bjorn Helgaas

[permalink] [raw]
Subject: Re: [PATCH]serial: make early_uart to use early_prarm instead of console_initcall

On Monday 21 May 2007 12:56:37 am Yinghai Lu wrote:
> Bjorn,
> I can not find fixmap.h for ia64.....hope you can use ioremap instead,
> then we can create one dummy fixmap.h in include/asm-ia64

ia64 ioremap should work early enough, so it doesn't have fixmap.
Seems like in this case, maybe bt_ioremap() would be more
appropriate than fixmap, since there's no requirement that
virtual address be known at compile-time.

> [PATCH]serial: make early_uart to use early_prarm instead of console_initcall

s/prarm/param/

> new command line will be
>
> earlycon=uart,io,0x3f8,9600n8
> earlycon=uart,io,0x3f8,9600n8 console=tty0
> earlycon=uart,mmio,0xff5e0000,115200n8

Why do we have to have a new "earlycon" argument? Why can't we just
parse "console=uart" early?

BTW, if you want to convert it from "console=uart" to "console=8250",
as part of this cleanup, I think that would be OK. Just make it a
separate patch and don't forget to change drivers/firmware/pcdp.c and
Documentation/kernel-parameters.txt at the same time.

Bjorn

2007-05-21 17:37:13

by Yinghai Lu

[permalink] [raw]
Subject: Re: [PATCH]serial: make early_uart to use early_prarm instead of console_initcall

On 5/21/07, Bjorn Helgaas <[email protected]> wrote:
> > earlycon=uart,io,0x3f8,9600n8
> > earlycon=uart,io,0x3f8,9600n8 console=tty0
> > earlycon=uart,mmio,0xff5e0000,115200n8
>
> Why do we have to have a new "earlycon" argument? Why can't we just
> parse "console=uart" early?

with console=uart, you need to call early_serial_console_init
explictly in your arch setup_arch to get early console.

with console_initcall(early_uart_console_init), the early_uart_console
will be called via console_init in start_kernel, init/main.c that is
not real early console.

YH

2007-05-21 18:03:07

by Bjorn Helgaas

[permalink] [raw]
Subject: Re: [PATCH]serial: make early_uart to use early_prarm instead of console_initcall

On Monday 21 May 2007 11:36:58 am Yinghai Lu wrote:
> On 5/21/07, Bjorn Helgaas <[email protected]> wrote:
> > > earlycon=uart,io,0x3f8,9600n8
> > > earlycon=uart,io,0x3f8,9600n8 console=tty0
> > > earlycon=uart,mmio,0xff5e0000,115200n8
> >
> > Why do we have to have a new "earlycon" argument? Why can't we just
> > parse "console=uart" early?
>
> with console=uart, you need to call early_serial_console_init
> explictly in your arch setup_arch to get early console.

Can't we just do:

early_param("console", setup_early_console);

and have setup_early_console() ignore everything except "uart"?

> with console_initcall(early_uart_console_init), the early_uart_console
> will be called via console_init in start_kernel, init/main.c that is
> not real early console.

I agree that's too late.

Bjorn

2007-05-21 18:39:22

by Yinghai Lu

[permalink] [raw]
Subject: Re: [PATCH]serial: make early_uart to use early_prarm instead of console_initcall

On 5/21/07, Bjorn Helgaas <[email protected]> wrote:
> early_param("console", setup_early_console);
>
> and have setup_early_console() ignore everything except "uart"?

console= is used
__setup("console=", console_setup);
early_param doesn't have chance to see it.

YH