2005-12-09 14:06:03

by Olaf Hering

[permalink] [raw]
Subject: [PATCH] Adding ctrl-o sysrq hack support to 8250 driver


If you can queue this up in -mm for a decade or two, just to make sure
it doesnt make some setup unhappy.


a POWER4 system in 'full-system-partition' mode has the console device
on ttyS0. But the user interface to the Linux system console may still
be on the hardware management console (HMC). If this is the case, there
is no way to send a break to trigger a sysrq.
Other setups do already use 'ctrl o' to trigger sysrq. This includes iSeries
virtual console on tty1, and pSeries LPAR console on hvc0 or hvsi0.

'ctrl o' is currently mapped to 'flush output', see 'stty -a'

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

drivers/serial/8250.c | 7 +++++++
1 files changed, 7 insertions(+)

Index: linux-2.6.15-rc5-olh/drivers/serial/8250.c
===================================================================
--- linux-2.6.15-rc5-olh.orig/drivers/serial/8250.c
+++ linux-2.6.15-rc5-olh/drivers/serial/8250.c
@@ -1154,6 +1154,13 @@ receive_chars(struct uart_8250_port *up,
*/
}
ch = serial_inp(up, UART_RX);
+
+#if defined(CONFIG_MAGIC_SYSRQ) && defined(CONFIG_SERIAL_CORE_CONSOLE)
+ /* Handle the SysRq ^O Hack, but only on the system console */
+ if (ch == '\x0f' && uart_handle_break(&up->port))
+ goto ignore_char;
+#endif
+
flag = TTY_NORMAL;
up->port.icount.rx++;

--
short story of a lazy sysadmin:
alias appserv=wotan


2005-12-09 14:10:59

by Russell King

[permalink] [raw]
Subject: Re: [PATCH] Adding ctrl-o sysrq hack support to 8250 driver

On Fri, Dec 09, 2005 at 03:05:59PM +0100, Olaf Hering wrote:
>
> If you can queue this up in -mm for a decade or two, just to make sure
> it doesnt make some setup unhappy.
>
>
> a POWER4 system in 'full-system-partition' mode has the console device
> on ttyS0. But the user interface to the Linux system console may still
> be on the hardware management console (HMC). If this is the case, there
> is no way to send a break to trigger a sysrq.
> Other setups do already use 'ctrl o' to trigger sysrq. This includes iSeries
> virtual console on tty1, and pSeries LPAR console on hvc0 or hvsi0.
>
> 'ctrl o' is currently mapped to 'flush output', see 'stty -a'

I still strongly disagree with the idea of using a well defined
control character which already has an expected purpose for this.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-12-09 15:13:53

by Daniel Jacobowitz

[permalink] [raw]
Subject: Re: [PATCH] Adding ctrl-o sysrq hack support to 8250 driver

On Fri, Dec 09, 2005 at 03:05:59PM +0100, Olaf Hering wrote:
>
> If you can queue this up in -mm for a decade or two, just to make sure
> it doesnt make some setup unhappy.
>
>
> a POWER4 system in 'full-system-partition' mode has the console device
> on ttyS0. But the user interface to the Linux system console may still
> be on the hardware management console (HMC). If this is the case, there
> is no way to send a break to trigger a sysrq.
> Other setups do already use 'ctrl o' to trigger sysrq. This includes iSeries
> virtual console on tty1, and pSeries LPAR console on hvc0 or hvsi0.
>
> 'ctrl o' is currently mapped to 'flush output', see 'stty -a'

And... you're going to make it impossible to run ppp over the serial
console port. For everyone, not just your big POWER4 boxes. As far as
I know, if you turn off the printk log level, this should work just
fine today.

--
Daniel Jacobowitz
CodeSourcery, LLC

2005-12-09 15:19:17

by Olaf Hering

[permalink] [raw]
Subject: Re: [PATCH] Adding ctrl-o sysrq hack support to 8250 driver

On Fri, Dec 09, Daniel Jacobowitz wrote:

> And... you're going to make it impossible to run ppp over the serial
> console port. For everyone, not just your big POWER4 boxes. As far as
> I know, if you turn off the printk log level, this should work just
> fine today.

Can one send break (via ppp) in this setup?

--
short story of a lazy sysadmin:
alias appserv=wotan

2005-12-09 15:25:37

by Erik Mouw

[permalink] [raw]
Subject: Re: [PATCH] Adding ctrl-o sysrq hack support to 8250 driver

On Fri, Dec 09, 2005 at 03:05:59PM +0100, Olaf Hering wrote:
> a POWER4 system in 'full-system-partition' mode has the console device
> on ttyS0. But the user interface to the Linux system console may still
> be on the hardware management console (HMC). If this is the case, there
> is no way to send a break to trigger a sysrq.
> Other setups do already use 'ctrl o' to trigger sysrq. This includes iSeries
> virtual console on tty1, and pSeries LPAR console on hvc0 or hvsi0.

So it's a POWER4 problem.

> 'ctrl o' is currently mapped to 'flush output', see 'stty -a'

Eww... If you can't use a serial break, why can't you use an
established control character like ctrl-] (telnet) or [enter]~ (ssh) ?

If you really want to use ctrl-o, could you make a way that pressing
ctrl-o twice sends a single ctrl-o to the process attached to the
console?

> Signed-off-by: Olaf Hering <[email protected]>
>
> drivers/serial/8250.c | 7 +++++++
> 1 files changed, 7 insertions(+)
>
> Index: linux-2.6.15-rc5-olh/drivers/serial/8250.c
> ===================================================================
> --- linux-2.6.15-rc5-olh.orig/drivers/serial/8250.c
> +++ linux-2.6.15-rc5-olh/drivers/serial/8250.c
> @@ -1154,6 +1154,13 @@ receive_chars(struct uart_8250_port *up,
> */
> }
> ch = serial_inp(up, UART_RX);
> +
> +#if defined(CONFIG_MAGIC_SYSRQ) && defined(CONFIG_SERIAL_CORE_CONSOLE)

If it is a POWER4-only problem, why isn't there a dependency on
CONFIG_POWER4 over here? I don't like to have the ctrl-o sysrq stuff
enabled on my regular PC if it only matters to some rare (in absolute
numbers) system.


Erik

--
+-- Erik Mouw -- http://www.harddisk-recovery.com -- +31 70 370 12 90 --
| Lab address: Delftechpark 26, 2628 XH, Delft, The Netherlands

2005-12-09 15:28:38

by Olaf Hering

[permalink] [raw]
Subject: Re: [PATCH] Adding ctrl-o sysrq hack support to 8250 driver

On Fri, Dec 09, Daniel Jacobowitz wrote:

> Maybe I'm misunderstanding your patch, but the issue is that you've
> just made the serial console not-eight-bit-clean.

True. Have to throw more stuff in the if() for this part of the issue.

--
short story of a lazy sysadmin:
alias appserv=wotan

2005-12-09 15:26:32

by Daniel Jacobowitz

[permalink] [raw]
Subject: Re: [PATCH] Adding ctrl-o sysrq hack support to 8250 driver

On Fri, Dec 09, 2005 at 04:19:14PM +0100, Olaf Hering wrote:
> On Fri, Dec 09, Daniel Jacobowitz wrote:
>
> > And... you're going to make it impossible to run ppp over the serial
> > console port. For everyone, not just your big POWER4 boxes. As far as
> > I know, if you turn off the printk log level, this should work just
> > fine today.
>
> Can one send break (via ppp) in this setup?

Huh?

Maybe I'm misunderstanding your patch, but the issue is that you've
just made the serial console not-eight-bit-clean.

--
Daniel Jacobowitz
CodeSourcery, LLC

2005-12-09 15:34:36

by Olaf Hering

[permalink] [raw]
Subject: Re: [PATCH] Adding ctrl-o sysrq hack support to 8250 driver

On Fri, Dec 09, Erik Mouw wrote:

> > 'ctrl o' is currently mapped to 'flush output', see 'stty -a'
>
> Eww... If you can't use a serial break, why can't you use an
> established control character like ctrl-] (telnet) or [enter]~ (ssh) ?

There are many ways to get to the console session on the HMC. One is
ssh. But maybe this would work somehow.

> If you really want to use ctrl-o, could you make a way that pressing
> ctrl-o twice sends a single ctrl-o to the process attached to the
> console?

Sounds good. Have to check how to handle that.

> If it is a POWER4-only problem, why isn't there a dependency on
> CONFIG_POWER4 over here? I don't like to have the ctrl-o sysrq stuff
> enabled on my regular PC if it only matters to some rare (in absolute
> numbers) system.

More CONFIG_PPC_PSERIES, the mentioned option is for gcc optimization.

--
short story of a lazy sysadmin:
alias appserv=wotan

2005-12-09 17:08:53

by Russell King

[permalink] [raw]
Subject: Re: [PATCH] Adding ctrl-o sysrq hack support to 8250 driver

On Fri, Dec 09, 2005 at 04:25:31PM +0100, Erik Mouw wrote:
> If you really want to use ctrl-o, could you make a way that pressing
> ctrl-o twice sends a single ctrl-o to the process attached to the
> console?

That's already handled by adding uart_handle_break() - the first call
to this function will set sysrq status and return 1 (ignore character).
The second call will clear sysrq status and return 0 (don't ignore).

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-12-09 20:47:38

by Olaf Hering

[permalink] [raw]
Subject: Re: [PATCH] Adding ctrl-o sysrq hack support to 8250 driver

On Fri, Dec 09, Olaf Hering wrote:

> > If it is a POWER4-only problem, why isn't there a dependency on
> > CONFIG_POWER4 over here? I don't like to have the ctrl-o sysrq stuff
> > enabled on my regular PC if it only matters to some rare (in absolute
> > numbers) system.

The system with the build tree on it just crashed hard.
Thats what I saved from the screen session:

Index: linux-2.6.15-rc5-olh/drivers/serial/8250.c
===================================================================
--- linux-2.6.15-rc5-olh.orig/drivers/serial/8250.c
+++ linux-2.6.15-rc5-olh/drivers/serial/8250.c
@@ -85,6 +85,8 @@ static unsigned int share_irqs = SERIAL8
#define CONFIG_SERIAL_MANY_PORTS 1
#endif

+#define arch_8250_sysrq_via_ctrl_o(x) (0)
+
/*
* HUB6 is always on. This will be removed once the header
* files have been cleaned.
@@ -1154,6 +1156,10 @@ receive_chars(struct uart_8250_port *up,
*/
}
ch = serial_inp(up, UART_RX);
+
+ if (arch_8250_sysrq_via_ctrl_o(ch, &up->port))
+ goto ignore_char;
+
flag = TTY_NORMAL;
up->port.icount.rx++;

Index: linux-2.6.15-rc5-olh/include/asm-powerpc/serial.h
===================================================================
--- linux-2.6.15-rc5-olh.orig/include/asm-powerpc/serial.h
+++ linux-2.6.15-rc5-olh/include/asm-powerpc/serial.h
@@ -15,4 +15,11 @@
/* Default baud base if not found in device-tree */
#define BASE_BAUD ( 1843200 / 16 )

+
+#if defined(SUPPORT_SYSRQ) && defined(CONFIG_PPC_PSERIES)
+ /* Handle the SysRq ^O Hack, but only on the system console */
+#undef arch_8250_sysrq_via_ctrl_o
+#define arch_8250_sysrq_via_ctrl_o(ch, port) ((ch) == '\x0f' && uart_handle_break((port)))
+#endif
+
#endif /* _PPC64_SERIAL_H */



--
short story of a lazy sysadmin:
alias appserv=wotan

2005-12-12 10:03:29

by Olaf Hering

[permalink] [raw]
Subject: Re: [PATCH] Adding ctrl-o sysrq hack support to 8250 driver

On Fri, Dec 09, Russell King wrote:

> On Fri, Dec 09, 2005 at 04:25:31PM +0100, Erik Mouw wrote:
> > If you really want to use ctrl-o, could you make a way that pressing
> > ctrl-o twice sends a single ctrl-o to the process attached to the
> > console?
>
> That's already handled by adding uart_handle_break() - the first call
> to this function will set sysrq status and return 1 (ignore character).
> The second call will clear sysrq status and return 0 (don't ignore).

Russel,
are you ok with the arch specific approach? I could trim it down further
by checking the model type in the device-tree, somewhere in
arch/powerpc/kernel/setup-common.c.


drivers/serial/8250.c | 6 ++++++
include/asm-powerpc/serial.h | 19 +++++++++++++++++++
2 files changed, 25 insertions(+)

Index: linux-2.6.15-rc5-olh/drivers/serial/8250.c
===================================================================
--- linux-2.6.15-rc5-olh.orig/drivers/serial/8250.c
+++ linux-2.6.15-rc5-olh/drivers/serial/8250.c
@@ -85,6 +85,8 @@ static unsigned int share_irqs = SERIAL8
#define CONFIG_SERIAL_MANY_PORTS 1
#endif

+#define arch_8250_sysrq_via_ctrl_o(x) (0)
+
/*
* HUB6 is always on. This will be removed once the header
* files have been cleaned.
@@ -1154,6 +1156,10 @@ receive_chars(struct uart_8250_port *up,
*/
}
ch = serial_inp(up, UART_RX);
+
+ if (arch_8250_sysrq_via_ctrl_o(ch, &up->port))
+ goto ignore_char;
+
flag = TTY_NORMAL;
up->port.icount.rx++;

Index: linux-2.6.15-rc5-olh/include/asm-powerpc/serial.h
===================================================================
--- linux-2.6.15-rc5-olh.orig/include/asm-powerpc/serial.h
+++ linux-2.6.15-rc5-olh/include/asm-powerpc/serial.h
@@ -15,4 +15,23 @@
/* Default baud base if not found in device-tree */
#define BASE_BAUD ( 1843200 / 16 )

+
+#if defined(SUPPORT_SYSRQ) && defined(CONFIG_PPC_PSERIES)
+ /*
+ * Handle the SysRq ^O Hack also via ttyS0 on POWER4 systems
+ * but only on the system console
+ * affected Models:
+ * p690 7040-681
+ * p670 7040-671
+ * p655 7039-651
+ * p650 7038-6M2
+ * p630 7028-6E4 tower
+ * p630 7028-6C4 rack
+ * p615 7029-6E3 tower
+ * p615 7029-6C3 rack
+ */
+#undef arch_8250_sysrq_via_ctrl_o
+#define arch_8250_sysrq_via_ctrl_o(ch, port) ((ch) == '\x0f' && uart_handle_break((port)))
+#endif
+
#endif /* _PPC64_SERIAL_H */
--
short story of a lazy sysadmin:
alias appserv=wotan

2006-01-03 12:44:12

by Olaf Hering

[permalink] [raw]
Subject: Re: [PATCH] Adding ctrl-o sysrq hack support to 8250 driver

On Mon, Dec 12, Olaf Hering wrote:

Russell,
are you ok with the arch specific approach?



a POWER4 system in 'full-system-partition' mode has the console device
on ttyS0. But the user interface to the Linux system console may still
be on the hardware management console (HMC). If this is the case, there
is no way to send a break to trigger a sysrq.
Other setups do already use 'ctrl o' to trigger sysrq. This includes iSeries
virtual console on tty1, and pSeries LPAR console on hvc0 or hvsi0.

To limit the 'ctrl o' only to the affected systems, query the model property
in the device-tree. The patch makes the serial console not-eight-bit-clean.
Booting with 'console=ttyS0' will disable 'ctrl o', it is only enabled
with console autodetection.

'ctrl o' is currently mapped to 'flush output', see 'stty -a'


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

arch/powerpc/kernel/setup-common.c | 45 +++++++++++++++++++++++++++++++++++++
drivers/serial/8250.c | 4 +++
include/asm-powerpc/serial.h | 6 ++++
3 files changed, 55 insertions(+)

Index: linux-2.6.15-rc6-olh/arch/powerpc/kernel/setup-common.c
===================================================================
--- linux-2.6.15-rc6-olh.orig/arch/powerpc/kernel/setup-common.c
+++ linux-2.6.15-rc6-olh/arch/powerpc/kernel/setup-common.c
@@ -295,6 +295,48 @@ struct seq_operations cpuinfo_op = {
};

#ifdef CONFIG_PPC_MULTIPLATFORM
+#if defined(CONFIG_PPC_PSERIES) && defined(CONFIG_SERIAL_8250_CONSOLE)
+/*
+ * Handle the SysRq ^O Hack also via ttyS0 on POWER4 systems
+ * but only on the system console, see asm/serial.h
+ * If they run in FullSystemPartition mode, the firmware console comes in via ttyS0
+ * But BREAK does not work via the HMC, to trigger sysrq.
+ * Affected Models:
+ * p690 7040-681
+ * p670 7040-671
+ * p655 7039-651
+ * p650 7038-6M2
+ * p630 7028-6E4 tower
+ * p630 7028-6C4 rack
+ * p615 7029-6E3 tower
+ * p615 7029-6C3 rack
+ */
+int power4_sysrq_via_ctrl_o;
+
+static void detect_power4_console(void)
+{
+ struct device_node *root;
+ char *model;
+
+ root = of_find_node_by_path("/");
+ if (root) {
+ model = get_property(root, "model", NULL);
+ if (model) {
+ if(!strcmp(model, "IBM,7040-681") ||
+ !strcmp(model, "IBM,7040-671") ||
+ !strcmp(model, "IBM,7039-651") ||
+ !strcmp(model, "IBM,7038-6M2") ||
+ !strcmp(model, "IBM,7028-6E4") ||
+ !strcmp(model, "IBM,7028-6C4") ||
+ !strcmp(model, "IBM,7029-6E3") ||
+ !strcmp(model, "IBM,7029-6C3"))
+ power4_sysrq_via_ctrl_o = 1;
+ }
+ of_node_put(root);
+ }
+}
+#endif
+
static int __init set_preferred_console(void)
{
struct device_node *prom_stdout = NULL;
@@ -359,6 +401,9 @@ static int __init set_preferred_console(
/* We dont recognise the serial port */
goto not_found;
}
+#ifdef CONFIG_PPC_PSERIES
+ detect_power4_console();
+#endif /* CONFIG_PPC_PSERIES */
}
}
#endif /* CONFIG_SERIAL_8250_CONSOLE */
Index: linux-2.6.15-rc6-olh/drivers/serial/8250.c
===================================================================
--- linux-2.6.15-rc6-olh.orig/drivers/serial/8250.c
+++ linux-2.6.15-rc6-olh/drivers/serial/8250.c
@@ -85,6 +85,8 @@ static unsigned int share_irqs = SERIAL8
#define CONFIG_SERIAL_MANY_PORTS 1
#endif

+#define arch_8250_sysrq_via_ctrl_o(x) (0)
+
/*
* HUB6 is always on. This will be removed once the header
* files have been cleaned.
@@ -1154,6 +1156,8 @@ receive_chars(struct uart_8250_port *up,
*/
}
ch = serial_inp(up, UART_RX);
+ if (arch_8250_sysrq_via_ctrl_o(ch, &up->port))
+ goto ignore_char;
flag = TTY_NORMAL;
up->port.icount.rx++;

Index: linux-2.6.15-rc6-olh/include/asm-powerpc/serial.h
===================================================================
--- linux-2.6.15-rc6-olh.orig/include/asm-powerpc/serial.h
+++ linux-2.6.15-rc6-olh/include/asm-powerpc/serial.h
@@ -15,4 +15,10 @@
/* Default baud base if not found in device-tree */
#define BASE_BAUD ( 1843200 / 16 )

+#if defined(SUPPORT_SYSRQ) && defined(CONFIG_PPC_PSERIES)
+#undef arch_8250_sysrq_via_ctrl_o
+extern int power4_sysrq_via_ctrl_o;
+#define arch_8250_sysrq_via_ctrl_o(ch, port) ((ch) == '\x0f' && power4_sysrq_via_ctrl_o && uart_handle_break((port)))
+#endif
+
#endif /* _PPC64_SERIAL_H */

--
short story of a lazy sysadmin:
alias appserv=wotan