linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] printk/of_serial: fix serial console cessation part way through boot.
@ 2014-05-10  5:37 Stephen Chivers
  2014-05-12  9:33 ` Geert Uytterhoeven
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Chivers @ 2014-05-10  5:37 UTC (permalink / raw)
  To: geert, jslaby, gregkh
  Cc: linuxppc-dev, benh, devicetree, rob+dt, grant.likely,
	linux-kernel, cproctor, linux-serial, schivers

Commit 5f5c9ae56c38942623f69c3e6dc6ec78e4da2076
"serial_core: Unregister console in uart_remove_one_port()"
fixed a crash where a serial port was removed but
not deregistered as a console.

There is a side effect of that commit for platforms having serial consoles
and of_serial configured (CONFIG_SERIAL_OF_PLATFORM). The serial console
is disabled midway through the boot process.

This cessation of the serial console affects PowerPC computers
such as the MVME5100 and SAM440EP.

The sequence is:

	bootconsole [udbg0] enabled
	....
	serial8250/16550 driver initialises and registers its UARTS,
	one of these is the serial console.
	console [ttyS0] enabled
	....
	of_serial probes "platform" devices, registering them as it goes.
	One of these is the serial console.
	console [ttyS0] disabled.

The disabling of the serial console is due to:

	a.  unregister_console in printk not clearing the
	    CONS_ENABLED bit in the console flags,
	    even though it has announced that the console is disabled; and

	b.  of_platform_serial_probe in of_serial not setting the port type
	    before it registers with serial8250_register_8250_port.

This patch ensures that the serial console is re-enabled when of_serial
registers a serial port that corresponds to the designated console.

Signed-off-by: Stephen Chivers <schivers@csc.com>
Tested-by: Stephen Chivers <schivers@csc.com>

===
The above failure was identified in Linux-3.15-rc2.

Tested using MVME5100 and SAM440EP PowerPC computers with
kernels built from Linux-3.15-rc5 and tty-next.

The continued operation of the serial console is vital for computers
such as the MVME5100 as that Single Board Computer does not
have any grapical/display hardware.

---
 drivers/tty/serial/of_serial.c |    1 +
 kernel/printk/printk.c         |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index 9924660..27981e2 100644
--- a/drivers/tty/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
@@ -173,6 +173,7 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
 	{
 		struct uart_8250_port port8250;
 		memset(&port8250, 0, sizeof(port8250));
+		port.type = port_type;
 		port8250.port = port;
 
 		if (port.fifosize)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 7228258..221229c 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2413,6 +2413,7 @@ int unregister_console(struct console *console)
 	if (console_drivers != NULL && console->flags & CON_CONSDEV)
 		console_drivers->flags |= CON_CONSDEV;
 
+	console->flags &= ~CON_ENABLED;
 	console_unlock();
 	console_sysfs_notify();
 	return res;

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

* Re: [PATCH] printk/of_serial: fix serial console cessation part way through boot.
  2014-05-10  5:37 [PATCH] printk/of_serial: fix serial console cessation part way through boot Stephen Chivers
@ 2014-05-12  9:33 ` Geert Uytterhoeven
  0 siblings, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2014-05-12  9:33 UTC (permalink / raw)
  To: Stephen Chivers
  Cc: Jiri Slaby, Greg KH, linuxppc-dev@lists.ozlabs.org,
	Benjamin Herrenschmidt, devicetree@vger.kernel.org, rob+dt,
	Grant Likely, linux-kernel@vger.kernel.org, Chris Proctor,
	linux-serial

Hi Stephen,

On Sat, May 10, 2014 at 7:37 AM, Stephen Chivers <schivers@csc.com> wrote:
> Commit 5f5c9ae56c38942623f69c3e6dc6ec78e4da2076
> "serial_core: Unregister console in uart_remove_one_port()"
> fixed a crash where a serial port was removed but
> not deregistered as a console.
>
> There is a side effect of that commit for platforms having serial consoles
> and of_serial configured (CONFIG_SERIAL_OF_PLATFORM). The serial console
> is disabled midway through the boot process.
>
> This cessation of the serial console affects PowerPC computers
> such as the MVME5100 and SAM440EP.
>
> The sequence is:
>
>         bootconsole [udbg0] enabled
>         ....
>         serial8250/16550 driver initialises and registers its UARTS,
>         one of these is the serial console.
>         console [ttyS0] enabled
>         ....
>         of_serial probes "platform" devices, registering them as it goes.
>         One of these is the serial console.
>         console [ttyS0] disabled.
>
> The disabling of the serial console is due to:
>
>         a.  unregister_console in printk not clearing the
>             CONS_ENABLED bit in the console flags,
>             even though it has announced that the console is disabled; and

This part re-attaches the serial console on unbind/bind with the sh-sci driver,
too, which didn't work before. Cool, thanks!

>         b.  of_platform_serial_probe in of_serial not setting the port type
>             before it registers with serial8250_register_8250_port.

This part I couldn't test.

> This patch ensures that the serial console is re-enabled when of_serial
> registers a serial port that corresponds to the designated console.
>
> Signed-off-by: Stephen Chivers <schivers@csc.com>
> Tested-by: Stephen Chivers <schivers@csc.com>

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> [unregister_console]

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] printk/of_serial: fix serial console cessation part way through boot.
@ 2014-05-13 22:04 Stephen Chivers
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen Chivers @ 2014-05-13 22:04 UTC (permalink / raw)
  To: geert, jslaby, gregkh
  Cc: linuxppc-dev, benh, devicetree, rob+dt, grant.likely,
	linux-kernel, cproctor, linux-serial, schivers

Commit 5f5c9ae56c38942623f69c3e6dc6ec78e4da2076
"serial_core: Unregister console in uart_remove_one_port()"
fixed a crash where a serial port was removed but
not deregistered as a console.

There is a side effect of that commit for platforms having serial consoles
and of_serial configured (CONFIG_SERIAL_OF_PLATFORM). The serial console
is disabled midway through the boot process.

This cessation of the serial console affects PowerPC computers
such as the MVME5100 and SAM440EP.

The sequence is:

	bootconsole [udbg0] enabled
	....
	serial8250/16550 driver initialises and registers its UARTS,
	one of these is the serial console.
	console [ttyS0] enabled
	....
	of_serial probes "platform" devices, registering them as it goes.
	One of these is the serial console.
	console [ttyS0] disabled.

The disabling of the serial console is due to:

	a.  unregister_console in printk not clearing the
	    CONS_ENABLED bit in the console flags,
	    even though it has announced that the console is disabled; and

	b.  of_platform_serial_probe in of_serial not setting the port type
	    before it registers with serial8250_register_8250_port.

This patch ensures that the serial console is re-enabled when of_serial
registers a serial port that corresponds to the designated console.

Signed-off-by: Stephen Chivers <schivers@csc.com>
Tested-by: Stephen Chivers <schivers@csc.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> [unregister_console]

===
The above failure was identified in Linux-3.15-rc2.

Tested using MVME5100 and SAM440EP PowerPC computers with
kernels built from Linux-3.15-rc5 and tty-next.

The continued operation of the serial console is vital for computers
such as the MVME5100 as that Single Board Computer does not
have any grapical/display hardware.

---
 drivers/tty/serial/of_serial.c |    1 +
 kernel/printk/printk.c         |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index 9924660..27981e2 100644
--- a/drivers/tty/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
@@ -173,6 +173,7 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
 	{
 		struct uart_8250_port port8250;
 		memset(&port8250, 0, sizeof(port8250));
+		port.type = port_type;
 		port8250.port = port;
 
 		if (port.fifosize)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 7228258..221229c 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2413,6 +2413,7 @@ int unregister_console(struct console *console)
 	if (console_drivers != NULL && console->flags & CON_CONSDEV)
 		console_drivers->flags |= CON_CONSDEV;
 
+	console->flags &= ~CON_ENABLED;
 	console_unlock();
 	console_sysfs_notify();
 	return res;

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

end of thread, other threads:[~2014-05-13 22:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-10  5:37 [PATCH] printk/of_serial: fix serial console cessation part way through boot Stephen Chivers
2014-05-12  9:33 ` Geert Uytterhoeven
  -- strict thread matches above, loose matches on Subject: below --
2014-05-13 22:04 Stephen Chivers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).