]> xenbits.xensource.com Git - people/aperard/linux-chromebook.git/commitdiff
CHROMIUM: serial: samsung: Avoid waiting forever for TX ready
authorMichael Spang <spang@chromium.org>
Fri, 9 Nov 2012 01:06:06 +0000 (20:06 -0500)
committerGerrit <chrome-bot@google.com>
Wed, 5 Dec 2012 20:35:38 +0000 (12:35 -0800)
The no_console_suspend option allows the console to write to the UART
during early resume, before the serial port itself is resumed. Such
writes hang indefinitely waiting for TX ready.

This adds a check to the console putchar function to drop characters
instead of hanging if the port hasn't been initialized. That way, we
can use no_console_suspend without risk of hanging.

BUG=chrome-os-partner:10932
TEST=powerd_suspend with no_console_suspend but not SAMSUNG_PM_DEBUG

Change-Id: I64e8def33fe984b97776206451e6030d6c761355
Signed-off-by: Michael Spang <spang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/37714

drivers/tty/serial/samsung.c

index 4c2ac38d03a6b78a7738ebd4317a3add236e3c06..456f2ad821c55418bcb78bc7d2a840437cef632b 100644 (file)
@@ -1353,6 +1353,13 @@ s3c24xx_serial_console_txrdy(struct uart_port *port, unsigned int ufcon)
        return (utrstat & S3C2410_UTRSTAT_TXE) ? 1 : 0;
 }
 
+static bool
+s3c24xx_port_configured(unsigned int ucon)
+{
+       /* consider the serial port configured if the tx/rx mode set */
+       return (ucon & 0xf) != 0;
+}
+
 #ifdef CONFIG_CONSOLE_POLL
 /*
  * Console polling routines for writing and reading from the uart while
@@ -1375,6 +1382,11 @@ static void s3c24xx_serial_put_poll_char(struct uart_port *port,
                unsigned char c)
 {
        unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON);
+       unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON);
+
+       /* not possible to xmit on unconfigured port */
+       if (!s3c24xx_port_configured(ucon))
+               return;
 
        while (!s3c24xx_serial_console_txrdy(port, ufcon))
                cpu_relax();
@@ -1387,6 +1399,12 @@ static void
 s3c24xx_serial_console_putchar(struct uart_port *port, int ch)
 {
        unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON);
+       unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON);
+
+       /* not possible to xmit on unconfigured port */
+       if (!s3c24xx_port_configured(ucon))
+               return;
+
        while (!s3c24xx_serial_console_txrdy(port, ufcon))
                barrier();
        wr_regb(cons_uart, S3C2410_UTXH, ch);
@@ -1419,9 +1437,7 @@ s3c24xx_serial_get_options(struct uart_port *port, int *baud,
            "registers: ulcon=%08x, ucon=%08x, ubdriv=%08x\n",
            port, ulcon, ucon, ubrdiv);
 
-       if ((ucon & 0xf) != 0) {
-               /* consider the serial port configured if the tx/rx mode set */
-
+       if (s3c24xx_port_configured(ucon)) {
                switch (ulcon & S3C2410_LCON_CSMASK) {
                case S3C2410_LCON_CS5:
                        *bits = 5;