Skip to contentSkip to conversation

Serial console issue with 2.6.32

DISCUSSION Frans Pop 2 participants 10 messages Mar 15, 2010 – Aug 16, 2010 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore

Frans Pop

author
#0 lore raw

I've got a bit of a puzzler here.

With earlier kernels I can install Debian on my Ultra 10 using 3 methods:
1) headless: without keyboard connected
2) with head: using attached keyboard and monitor
3) with unused head: keyboard connected, but boot with 'console=ttyS0'

With Debian Lenny (2.6.26.x) and the alpha1 installer for Squeeze (2.6.30.x) all three methods work.

With a daily built version of the installer (based on 2.6.32.9) the first two methods work, but the third doesn't.
At the point where output should start appearing on my remote system, minicom shows ttyS0 going offline.

What's visible on the console of the U10 looks the same. With both .30 and .32 I see the tftp loading of the boot image and the early boot messages. Then the screen goes black with only Tux displayed.

I've verified that it's not an issue in the installer by booting with 'BOOT_DEBUG=3', which means that a debug shell is started at the very beginning of init, even before busybox init is called. With .30 that correctly gives me the debug shell in minicom; with .32 it goes offline again.

The exact commands I used to boot are:
boot net install console=ttyS0
boot net install console=ttyS0 BOOT_DEBUG=3

Any ideas?

Cheers,
FJP

maintainer
#1 lore raw

From: Frans Pop <[email protected]>
Date: Mon, 15 Mar 2010 18:09:27 +0100

Quoted 4 lines

With a daily built version of the installer (based on 2.6.32.9) the first two methods work, but the third doesn't.
At the point where output should start appearing on my remote system, minicom shows ttyS0 going offline.

I changed the behavior of SUNSAB serial consoles in 2.6.32 and later, see:

commit 4e68e188411ea98e40309700cf0c89ad4469ac1d

Author: David S. Miller <[email protected]>
Date:   Tue Nov 24 13:56:39 2009 -0800

sunsab: Do not set sunsab_reg.cons right before registering minors.

Other Sun serial drivers do not do this, and if we keep it this way it ends up registering all serial devices as consoles rather than just the one which we explicitly register via sunserial_console_match() which uses add_preferred_console().

This makes it consistent with the way all the other Sun serial console drivers were behaving.

Looking more at what you're trying to do, I think you really need to set the output-device and input-device firmware variables properly.

The kernel tries very hard to use whatever the firmware specified as the output-device as the console. I couldn't find an easy way get the behaviour you were after, yet at the same time get the multiple-serial-devices-only-one-is-console case right all the time.

author
#2 lore raw
In reply to Frans Pop
Quoted 2 lines · David Miller

I changed the behavior of SUNSAB serial consoles in 2.6.32 and later, see:

Thanks! That at least saves me a probably very painful bisection.

I'm not even going to attempt the technical merits of the change, but...

Quoted 5 lines

Looking more at what you're trying to do, I think you really need to set the output-device and input-device firmware variables properly.

The kernel tries very hard to use whatever the firmware specified as the output-device as the console.

That seems fair. However, all Linux documentation I've come across so far, including Documentation/{kernel-parameters,serial-console}.txt, says to use 'console=' to override the default console.

What's extra confusing is that the serial port is shown as "online" during the early part of the boot and only goes offline at the point the switch should happen.

And it seems you still have a bug because the connected monitor does *not* display the kernel output either. So apparently the kernel still thinks ttyS0 is the console and directs output there, even though the port has been disabled.

Also, Documentation/serial-console}.txt suggests that it should be possible to direct console output to multiple devices. I can understand not wanting to *disable* the console specified by firmware, but couldn't consoles specified on the command line be enabled in addition?
Not sure what that would mean for accepting input though (which I guess would normally be from the last console specified).

Quoted 4 lines

I couldn't find an easy way
get the behaviour you were after, yet at the same time get the multiple-serial-devices-only-one-is-console case right all the time.

IMO it's a real pity that a general mechanism that AFAIK works on most (all?) other arches doesn't not work for Sparc.

Now that I know it's not a huge issue for me personally. It just means I can no longer use my Sparc box for testing use of console= for Debian installations, which is a pity as it's the most suitable box I have for that.

I'm not sure how much this is going to throw off other users, but I suspect the majority (except maybe for long time sparc sysadmins) would expect console= to be honored.

Thanks,
FJP

maintainer
#3 lore raw
In reply to Frans Pop

From: Frans Pop <[email protected]>
Date: Wed, 17 Mar 2010 11:50:07 +0100

Quoted 3 lines

I'm not sure how much this is going to throw off other users, but I suspect the majority (except maybe for long time sparc sysadmins) would expect console= to be honored.

Agreed, I'll see what I can do to fix it.

maintainer
#4 lore raw
In reply to Frans Pop

From: Frans Pop <[email protected]>
Date: Wed, 17 Mar 2010 11:50:07 +0100

Quoted 8 lines

Now that I know it's not a huge issue for me personally. It just means I can no longer use my Sparc box for testing use of console= for Debian installations, which is a pity as it's the most suitable box I have for that.

I'm not sure how much this is going to throw off other users, but I suspect the majority (except maybe for long time sparc sysadmins) would expect console= to be honored.

Frans, is this patch enough to get the behavior you want?

--------------------
sunserial: Don't call add_preferred_console() when console= is specified.

---
 drivers/serial/suncore.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/serial/suncore.c +3 -1
index ed7d958..544f2e2 100644
@@ -71,7 +71,9 @@ int sunserial_console_match(struct console *con, struct device_node *dp,
 
 	con->index = line;
 	drv->cons = con;
-	add_preferred_console(con->name, line, NULL);
+
+	if (!console_set_on_cmdline)
+		add_preferred_console(con->name, line, NULL);
 
 	return 1;
 }
Signature · 1 line
1.7.0.4
author
#5 lore raw
In reply to Frans Pop
Quoted 12 lines · David Miller

From: Frans Pop <[email protected]>
Date: Wed, 17 Mar 2010 11:50:07 +0100

Quoted 8 lines

Now that I know it's not a huge issue for me personally. It just means I can no longer use my Sparc box for testing use of console= for Debian installations, which is a pity as it's the most suitable box I have for that.

I'm not sure how much this is going to throw off other users, but I suspect the majority (except maybe for long time sparc sysadmins) would expect console= to be honored.

Quoted 5 lines

Frans, is this patch enough to get the behavior you want?

--------------------
sunserial: Don't call add_preferred_console() when console= is specified.

Thanks for the patch David. I've tried to test with it, but for some reason the box does not boot at all with .34 (both with and without the patch) if I pass console=ttyS0. If I don't pass the parameter it boots fine.

Need to investigate (using netconsole or earlier kernels), but that will take some more time.

Cheers,
FJP

maintainer
#6 lore raw
In reply to Frans Pop

From: Frans Pop <[email protected]>
Date: Wed, 2 Jun 2010 19:53:34 +0200

Quoted 19 lines · David Miller
Quoted 12 lines

From: Frans Pop <[email protected]>
Date: Wed, 17 Mar 2010 11:50:07 +0100

Quoted 8 lines

Now that I know it's not a huge issue for me personally. It just means I can no longer use my Sparc box for testing use of console= for Debian installations, which is a pity as it's the most suitable box I have for that.

I'm not sure how much this is going to throw off other users, but I suspect the majority (except maybe for long time sparc sysadmins) would expect console= to be honored.

Quoted 5 lines

Frans, is this patch enough to get the behavior you want?

--------------------
sunserial: Don't call add_preferred_console() when console= is specified.

Quoted 6 lines

Thanks for the patch David. I've tried to test with it, but for some reason the box does not boot at all with .34 (both with and without the patch) if I pass console=ttyS0. If I don't pass the parameter it boots fine.

Need to investigate (using netconsole or earlier kernels), but that will take some more time.

Frans, I just wanted to let you know that I'm actively trying to debug this now. On my SunBlade100 I can see similar behavior. If I hook up a video head and a keyboard, yet give "console=ttyS0" on the command line it doesn't try to use the serial console for kernel messages.

I'll let you know when I have a fix to test.

Thanks for your patience.

maintainer
#7 lore raw
In reply to Frans Pop

From: Frans Pop <[email protected]>
Date: Wed, 2 Jun 2010 19:53:34 +0200

Quoted 8 lines · David Miller
Quoted 3 lines

--------------------
sunserial: Don't call add_preferred_console() when console= is specified.

Thanks for the patch David. I've tried to test with it, but for some reason the box does not boot at all with .34 (both with and without the patch) if I pass console=ttyS0. If I don't pass the parameter it boots fine.

Ok, I think I really got it this time :-) Please add this patch on top of the existing stuff.

--------------------
sparc: Really fix "console=" for serial consoles.

If a video head and keyboard are hooked up, specifying "console=ttyS0" or similar to use a serial console will not work properly.

The key issue is that we must register all serial console capable devices with register_console(), otherwise the command line specified device won't be found. The sun serial drivers would only register themselves as console devices if the OpenFirmware specified console device node matched. To fix this part we now unconditionally get the serial console register by setting serial_drv->cons always.

Secondarily we must not add_preferred_console() using the firmware provided console setting if the user gaven an override on the kernel command line using "console=" The "primary framebuffer" matching logic was always triggering o n openfirmware device node match, make it not when a command line override was given.

---
 arch/sparc/include/asm/fb.h |    4 ++++
 drivers/serial/suncore.c    |   15 +++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)
arch/sparc/include/asm/fb.h +4 -0
index e834880..2173432 100644
@@ -1,5 +1,6 @@
 #ifndef _SPARC_FB_H_
 #define _SPARC_FB_H_
+#include <linux/console.h>
 #include <linux/fb.h>
 #include <linux/fs.h>
 #include <asm/page.h>
@@ -18,6 +19,9 @@ static inline int fb_is_primary_device(struct fb_info *info)
 	struct device *dev = info->device;
 	struct device_node *node;
 
+	if (console_set_on_cmdline)
+		return 0;
+
 	node = dev->of_node;
 	if (node &&
 	    node = of_console_device)
drivers/serial/suncore.c +9 -6
index 544f2e2..6381a02 100644
@@ -55,7 +55,12 @@ EXPORT_SYMBOL(sunserial_unregister_minors);
 int sunserial_console_match(struct console *con, struct device_node *dp,
 			    struct uart_driver *drv, int line, bool ignore_line)
 {
-	if (!con || of_console_device != dp)
+	if (!con)
+		return 0;
+
+	drv->cons = con;
+
+	if (of_console_device != dp)
 		return 0;
 
 	if (!ignore_line) {
@@ -69,12 +74,10 @@ int sunserial_console_match(struct console *con, struct device_node *dp,
 			return 0;
 	}
 
-	con->index = line;
-	drv->cons = con;
-
-	if (!console_set_on_cmdline)
+	if (!console_set_on_cmdline) {
+		con->index = line;
 		add_preferred_console(con->name, line, NULL);
-
+	}
 	return 1;
 }
 EXPORT_SYMBOL(sunserial_console_match);
Signature · 1 line
1.7.2.1
author
#8 lore raw
In reply to Frans Pop
Quoted 16 lines · David Miller

Ok, I think I really got it this time :-) Please add this patch on top of the existing stuff.

--------------
sparc: Really fix "console=" for serial consoles.

If a video head and keyboard are hooked up, specifying "console=ttyS0" or similar to use a serial console will not work properly.

The key issue is that we must register all serial console capable devices with register_console(), otherwise the command line specified device won't be found. The sun serial drivers would only register themselves as console devices if the OpenFirmware specified console device node matched. To fix this part we now unconditionally get the serial console register by setting serial_drv->cons always.

Quoted 5 lines

Secondarily we must not add_preferred_console() using the firmware provided console setting if the user gaven an override on the kernel command line using "console=" The "primary framebuffer" matching logic was always triggering o n openfirmware device node match, make it not when a command line override was given.

Works great.

Tested on top of previous patch (against 2.6.34; I've not done any kernel testing recently and am thus a bit behind).

Quoted 1 line

s/-by:/-and-tested-by:/

As always: many thanks David!

Cheers,
FJP