Do full flush on uart8250 only at end of printk.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 10 Jul 2011 00:22:21 +0000 (20:22 -0400)
committerPatrick Georgi <patrick@georgi-clan.de>
Tue, 12 Jul 2011 09:36:20 +0000 (11:36 +0200)
The previous code does a full flush of the uart after every character.
Unfortunately, this can cause transmission delays on some serial
ports.

This patch changes the code so that it does a flush at the end of
every printk instead of at the end of every character.  This reduces
the time it takes to transmit serial messages (up to 9% on my Asrock
e350m1 board).  It also makes the transmission time more consistent
which is important when performing timing tests via serial
transmissions.

Change-Id: I6b28488b905da68c6d68d7c517cc743cde567d70
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Reviewed-on: http://review.coreboot.org/90
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins)
Reviewed-by: Rudolf Marek <r.marek@assembler.cz>
Reviewed-by: Sven Schnelle <svens@stackframe.org>
src/arch/x86/lib/romstage_console.c
src/console/uart8250_console.c
src/console/uart8250mem_console.c
src/include/uart8250.h
src/lib/uart8250.c
src/lib/uart8250mem.c

index a5f2e2b0740d95988418abd1eb544f5ece3375b2..8adb3ba93d2324ee4259aeb6f5d35f94255aa838 100644 (file)
@@ -48,6 +48,19 @@ static void console_tx_byte(unsigned char byte)
 #endif
 }
 
+static void console_tx_flush(void)
+{
+#if CONFIG_CONSOLE_SERIAL8250MEM
+       uart8250_mem_tx_flush(CONFIG_OXFORD_OXPCIE_BASE_ADDRESS + 0x1000);
+#endif
+#if CONFIG_CONSOLE_SERIAL8250
+       uart8250_tx_flush(CONFIG_TTYS0_BASE);
+#endif
+#if CONFIG_CONSOLE_NE2K
+       ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
+#endif
+}
+
 int do_printk(int msg_level, const char *fmt, ...)
 {
        va_list args;
@@ -60,8 +73,8 @@ int do_printk(int msg_level, const char *fmt, ...)
        va_start(args, fmt);
        i = vtxprintf(console_tx_byte, fmt, args);
        va_end(args);
-#if CONFIG_CONSOLE_NE2K
-       ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
-#endif
+
+       console_tx_flush();
+
        return i;
 }
index 4799ca66e56d077719e2a265a2cc13905edc5fad..330ed684f786f7b1662e6282a89a45bfc46405c2 100644 (file)
@@ -31,6 +31,11 @@ static void ttyS0_tx_byte(unsigned char data)
        uart8250_tx_byte(CONFIG_TTYS0_BASE, data);
 }
 
+static void ttyS0_tx_flush(void)
+{
+       uart8250_tx_flush(CONFIG_TTYS0_BASE);
+}
+
 static unsigned char ttyS0_rx_byte(void)
 {
        return uart8250_rx_byte(CONFIG_TTYS0_BASE);
@@ -44,6 +49,7 @@ static int ttyS0_tst_byte(void)
 static const struct console_driver uart8250_console __console = {
        .init     = ttyS0_init,
        .tx_byte  = ttyS0_tx_byte,
+       .tx_flush = ttyS0_tx_flush,
        .rx_byte  = ttyS0_rx_byte,
        .tst_byte = ttyS0_tst_byte,
 };
index a6968ddc4b018d90740dd9e90c4c5582dd8194be..e622ad090cb6f35b25d59cb83df1097884cafd17 100644 (file)
@@ -36,6 +36,11 @@ static void uartmem_tx_byte(unsigned char data)
        uart8250_mem_tx_byte(uart_bar, data);
 }
 
+static void uartmem_tx_flush(void)
+{
+       uart8250_mem_tx_flush(uart_bar);
+}
+
 static unsigned char uartmem_rx_byte(void)
 {
        if (!uart_bar)
@@ -55,6 +60,7 @@ static int uartmem_tst_byte(void)
 static const struct console_driver uart8250mem_console __console = {
        .init     = uartmem_init,
        .tx_byte  = uartmem_tx_byte,
+       .tx_flush = uartmem_tx_flush,
        .rx_byte  = uartmem_rx_byte,
        .tst_byte = uartmem_tst_byte,
 };
index bbf2d8c8a96c1f34eafab9967f324938d209632e..4a02179210283085f6dea7c22e3be77543d0e281 100644 (file)
 unsigned char uart8250_rx_byte(unsigned base_port);
 int uart8250_can_rx_byte(unsigned base_port);
 void uart8250_tx_byte(unsigned base_port, unsigned char data);
+void uart8250_tx_flush(unsigned base_port);
 
 /* Yes it is silly to have three different uart init functions. But we used to
  * have three different sets of uart code, so it's an improvement.
@@ -142,6 +143,7 @@ void uart_init(void);
 unsigned char uart8250_mem_rx_byte(unsigned base_port);
 int uart8250_mem_can_rx_byte(unsigned base_port);
 void uart8250_mem_tx_byte(unsigned base_port, unsigned char data);
+void uart8250_mem_tx_flush(unsigned base_port);
 void uart8250_mem_init(unsigned base_port, unsigned divisor);
 u32 uart_mem_init(void);
 
index 64e8854ef551842ba70dba266dfda3d71da5f723..e7ddd0bfd55336900486a4fc30983e579cf0e2fa 100644 (file)
@@ -48,7 +48,10 @@ void uart8250_tx_byte(unsigned base_port, unsigned char data)
 {
        uart8250_wait_to_tx_byte(base_port);
        outb(data, base_port + UART_TBR);
-       /* Make certain the data clears the fifos */
+}
+
+void uart8250_tx_flush(unsigned base_port)
+{
        uart8250_wait_until_sent(base_port);
 }
 
index 918308ecdfe0e50233a0c8e3a66f38c401fe50e0..e79cb633467c40444d1e03ad627e6afe72f7f505 100644 (file)
@@ -51,7 +51,10 @@ void uart8250_mem_tx_byte(unsigned base_port, unsigned char data)
 {
        uart8250_mem_wait_to_tx_byte(base_port);
        write8(base_port + UART_TBR, data);
-       /* Make certain the data clears the FIFOs */
+}
+
+void uart8250_mem_tx_flush(unsigned base_port)
+{
        uart8250_mem_wait_until_sent(base_port);
 }