Re: [PATCH 2/2] Fix console handling during suspend/resume

David Brownell
2006-06-13T23:20:44Z

[-- Attachment #1: Type: text/plain, Size: 578 bytes --]

Here's a related patch (well, "hack") I found helpful ... specifically to
help let _serial_ consoles be more useful. As a rule, RS-232 lines will get
shut down right before the most interesting point in the system suspend
process, so that the debug messages I'm most interested in seeing will
then be thrown into the bitbucket (especially when resume breaks). But
this *cough* elegant patch lets you toss that bitbucket into itself.

Although I must say I like Nigel's "BDI-2000 per developer" hack better.
Even though not all boxes can hook up to a JTAG module. :(

- Dave

[-- Attachment #2: serial-pm.patch --]
[-- Type: text/x-diff, Size: 1872 bytes --]

Leave serial console active during freeze and prethaw, so we don't discard
the most interesting diagnostics.

Note that wakeup-enabled serial ports may already be bypassing the suspend
logic on some platforms, for serial ports which are enabled as wakeup
event sources.

Index: linux/drivers/serial/8250.c
===================================================================
--- linux.orig/drivers/serial/8250.c 2006-05-20 11:28:30.000000000 -0700
+++ linux/drivers/serial/8250.c 2006-05-20 11:29:51.000000000 -0700
@@ -2455,13 +2455,37 @@
return 0;
}

+/* HACK -- skipconsoles known to work with single serial port,
+ * allowing serial port to work during freeze/prethaw/thaw
+ * ... really the flag should be per-port
+ */
+static int skipconsoles;
+
+/* uart_console() should be in a header ... */
+#ifdef CONFIG_SERIAL_CORE_CONSOLE
+#define uart_console(port) ((port)->cons && (port)->cons->index == (port)->line)
+#else
+#define uart_console(port) (0)
+#endif
+
static int serial8250_suspend(struct platform_device *dev, pm_message_t state)
{
int i;

- for (i = 0; i < UART_NR; i++) {
+ for (i = 0;
+ 0 &&
+ i < UART_NR; i++) {
struct uart_8250_port *up = &serial8250_ports[i];

+ switch (state.event) {
+ case PM_EVENT_FREEZE:
+ case PM_EVENT_PRETHAW:
+ if (uart_console(&up->port)) {
+ skipconsoles = 1;
+ continue;
+ }
+ }
+
if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev)
uart_suspend_port(&serial8250_reg, &up->port);
}
@@ -2473,9 +2497,16 @@
{
int i;

- for (i = 0; i < UART_NR; i++) {
+ for (i = 0;
+ 0 &&
+ i < UART_NR; i++) {
struct uart_8250_port *up = &serial8250_ports[i];

+ if (skipconsoles && uart_console(&up->port)) {
+ skipconsoles = 0;
+ continue;
+ }
+
if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev)
uart_resume_port(&serial8250_reg, &up->port);
}

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]