Re: [PATCH v2] x86: Call setup_early_printk before first call to early_printk

Previous thread: [PATCH] sched: cpuacct: Track cpuusage for CPU frequencies by Mike Chan on Tuesday, April 6, 2010 - 6:21 pm. (5 messages)

Next thread: [PATCH][GIT PULL] tracing/mac80211: Move TRACE_SYSTEM out of #if protection by Steven Rostedt on Tuesday, April 6, 2010 - 6:57 pm. (1 message)
From: Guenter Roeck
Date: Tuesday, April 6, 2010 - 6:42 pm

Current code calls setup_early_printk() too late to catch the initial calls
to early_printk(). This results in those early messages not to be printed on a
serial console. Also, if there is no VGA device in the system, it will cause
bad writes into VGA memory space. This can cause problems if the VGA memory
space is used by another device in such a system.

Fix the problem by calling setup_early_printk() immediately after the boot
command line is available, and by preventing early_printk() to print anything
before setup_early_printk() was executed.

Also removed conditional output "Kernel alive".

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
---
The first version of this patch used the headline
    x86: Do not write to VGA memory space if CONFIG_VGA_CONSOLE is undefined
I changed the headline to reflect its expanded scope.

I removed the "Kernel alive" message because I don't see how console_loglevel
can ever be equal to 10 when the code is executed. An alternative might be
(if that possibility exists after all) to move it after the call to
setup_early_printk().

 arch/x86/include/asm/setup.h   |    2 ++
 arch/x86/kernel/early_printk.c |    5 ++++-
 arch/x86/kernel/head32.c       |    4 ++++
 arch/x86/kernel/head64.c       |    7 ++++---
 4 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
index 86b1506..83847af 100644
--- a/arch/x86/include/asm/setup.h
+++ b/arch/x86/include/asm/setup.h
@@ -93,6 +93,8 @@ void *extend_brk(size_t size, size_t align);
 			: : "i" (sz));					\
 	}
 
+int __init setup_early_printk(char *buf);
+
 #ifdef __i386__
 
 void __init i386_start_kernel(void);
diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
index b9c830c..873f1cd 100644
--- a/arch/x86/kernel/early_printk.c
+++ b/arch/x86/kernel/early_printk.c
@@ -170,6 +170,9 @@ asmlinkage void early_printk(const char *fmt, ...)
 	int n;
 	va_list ap;
 
+	if ...
From: Yinghai Lu
Date: Wednesday, April 7, 2010 - 10:44 pm

On Tue, Apr 6, 2010 at 6:42 PM, Guenter Roeck

if someone specify "earlyprintk", early_console will still point to
early_vga_console...

prefer to set early_console to NULL,

and here change to

if (!early_console) {
    printk(fmt, vargs)
    return;

you may need to search "earlyprintk" and cut the "earlyprintk=....."
string out at first, and then use that
string to call setup_early_printk()

YH
--

Previous thread: [PATCH] sched: cpuacct: Track cpuusage for CPU frequencies by Mike Chan on Tuesday, April 6, 2010 - 6:21 pm. (5 messages)

Next thread: [PATCH][GIT PULL] tracing/mac80211: Move TRACE_SYSTEM out of #if protection by Steven Rostedt on Tuesday, April 6, 2010 - 6:57 pm. (1 message)