diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2012-02-21 12:29:03 -0800 |
---|---|---|
committer | Vincent Palatin <vpalatin@chromium.org> | 2012-02-29 20:33:10 +0000 |
commit | e3fbea00b72dc71ff64f04363c36e362267b3122 (patch) | |
tree | 4dcaf890924dfe27e25eb32fa6ce4ac5abcce3a7 /common/uart_buffering.c | |
parent | d1e627926f7cdad2ee2428a3cfe3c64cf959afde (diff) | |
download | chrome-ec-e3fbea00b72dc71ff64f04363c36e362267b3122.tar.gz |
uart: fix race condition in flow control
The previous TX might end in the middle of the buffer filling and stop
TX. So we need to check if we want to restart the transmission.
With 1-byte deep FIFO, it's easy to trigger that race condition.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BUG=None
TEST=run console commands with lots of traces on BDS, Link and ADV and check
we are not stuck.
Change-Id: Ia57e974a3a51af694e736d4cf36d9d01eafd2251
Diffstat (limited to 'common/uart_buffering.c')
-rw-r--r-- | common/uart_buffering.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/common/uart_buffering.c b/common/uart_buffering.c index 6eea74329a..b9c7f6d1ff 100644 --- a/common/uart_buffering.c +++ b/common/uart_buffering.c @@ -367,15 +367,13 @@ void uart_set_console_mode(int enable) int uart_puts(const char *outstr) { - int was_empty = (tx_buf_head == tx_buf_tail); - /* Put all characters in the output buffer */ while (*outstr) { if (__tx_char(*outstr++) != 0) break; } - if (was_empty) + if (uart_tx_stopped()) uart_tx_start(); /* Successful if we consumed all output */ @@ -392,7 +390,6 @@ int uart_printf(const char *format, ...) int is_left; int pad_zero; int pad_width; - int was_empty = (tx_buf_head == tx_buf_tail); va_list args; char *vstr; int vlen; @@ -510,7 +507,7 @@ int uart_printf(const char *format, ...) } va_end(args); - if (was_empty) + if (uart_tx_stopped()) uart_tx_start(); /* Successful if we consumed all output */ |