Anonymous Coward (kevin@koconnor.net) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/90
-gerrit
commit 51761067ec0ded3b8fa73efffc1462f262a94759 Author: Kevin O'Connor kevin@koconnor.net Date: Sat Jul 9 20:22:21 2011 -0400
Do full flush on uart8250 only at end of printk.
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 --- src/arch/x86/lib/romstage_console.c | 16 +++++++++++++--- src/console/uart8250_console.c | 6 ++++++ src/include/uart8250.h | 1 + src/lib/uart8250.c | 5 ++++- 4 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/src/arch/x86/lib/romstage_console.c b/src/arch/x86/lib/romstage_console.c index a5f2e2b..faa8afb 100644 --- a/src/arch/x86/lib/romstage_console.c +++ b/src/arch/x86/lib/romstage_console.c @@ -48,6 +48,16 @@ static void console_tx_byte(unsigned char byte) #endif }
+static void console_tx_flush(void) +{ +#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 +70,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; } diff --git a/src/console/uart8250_console.c b/src/console/uart8250_console.c index 4799ca6..330ed68 100644 --- a/src/console/uart8250_console.c +++ b/src/console/uart8250_console.c @@ -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, }; diff --git a/src/include/uart8250.h b/src/include/uart8250.h index bbf2d8c..ee0cd39 100644 --- a/src/include/uart8250.h +++ b/src/include/uart8250.h @@ -131,6 +131,7 @@ 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. diff --git a/src/lib/uart8250.c b/src/lib/uart8250.c index 64e8854..e7ddd0b 100644 --- a/src/lib/uart8250.c +++ b/src/lib/uart8250.c @@ -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); }