public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] x86: Allow early_printk to use console style param like 115200n8
@ 2015-07-03 22:16 Steven Rostedt
  2015-07-04 11:03 ` Ingo Molnar
  2015-07-06 14:14 ` [PATCH] " Steven Rostedt
  0 siblings, 2 replies; 9+ messages in thread
From: Steven Rostedt @ 2015-07-03 22:16 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Greg Kroah-Hartman,
	David Cohen, Andy Shevchenko, Alan Cox, Stuart R. Anderson

When I enable early_printk on a kernel, I cut and paste the console=
input and add to earlyprintk parameter. But I notice recently that
ktest has not been detecting triple faults. The way it detects it, is
by seeing the kernel banner "Linux version .." with a different kernel
version pop up. Then I noticed that early printk was no longer working
on my console, which was why ktest was not seeing it.

I bisected it down and it was added to 4.0 with this commit:

commit ea9e9d802902 ("Specify PCI based UART for earlyprintk")

because it converted the simple_strtoul() that converts the baud number
into a kstrtoul(). The problem with this is, I had as my baud rate,
115200n8 (acceptable for console=ttyS0), but because of the "n8", the
kstrtoul() doesn't parse the baud rate and returns an error, which sets
the baud rate to the default 9600. This explains the garbage on my
screen.

Now, earlyprintk= kernel parameter does not say it accepts that format.
Thus, one answer would simply be me changing my kernel parameters to
remove the "n8" since it isn't parsed anyway. But I wonder if other
people run into this, and it seems strange that the two consoles for
serial accepts different input.

I could also extend this to have earlyprintk do something with that
"n8" or whatever it has and have it match the console parsing (which,
BTW, still uses simple_strtoul(), as I guess it has to).

This patch just makes my old kernel parameter parsing work like it use
to. Although, if someone were to use a hex number starting with "0x",
this patch would break it. That could be fixed too (hence the RFC).

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
index a62536a1be88..83d375148565 100644
--- a/arch/x86/kernel/early_printk.c
+++ b/arch/x86/kernel/early_printk.c
@@ -17,6 +17,7 @@
 #include <asm/intel-mid.h>
 #include <asm/pgtable.h>
 #include <linux/usb/ehci_def.h>
+#include <linux/ctype.h>
 #include <linux/efi.h>
 #include <asm/efi.h>
 #include <asm/pci_x86.h>
@@ -189,6 +190,15 @@ static __init void early_serial_init(char *s)
 	}
 
 	if (*s) {
+		char *p;
+		/*
+		 * In case the input is like console with text after the baud
+		 * rate. e.g. 115200n8. kstrtoul() will error on such input.
+		 */
+		for (p = s; *p && isdigit(*p); p++)
+			;
+		*p = 0;
+
 		if (kstrtoul(s, 0, &baud) < 0 || baud == 0)
 			baud = DEFAULT_BAUD;
 	}

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

end of thread, other threads:[~2015-07-06 16:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-03 22:16 [RFC][PATCH] x86: Allow early_printk to use console style param like 115200n8 Steven Rostedt
2015-07-04 11:03 ` Ingo Molnar
2015-07-04 13:16   ` Steven Rostedt
2015-07-04 13:20   ` Steven Rostedt
2015-07-05  9:05     ` Ingo Molnar
2015-07-06 13:29     ` Peter Hurley
2015-07-06 13:33       ` Ingo Molnar
2015-07-06 14:14 ` [PATCH] " Steven Rostedt
2015-07-06 16:34   ` [tip:x86/urgent] x86/earlyprintk: Allow early_printk() to use console style parameters like '115200n8' tip-bot for Steven Rostedt

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