summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-06-21 14:01:15 -0700
committerVadim Bendebury <vbendeb@chromium.org>2019-09-21 19:11:25 -0700
commit8450617d98cc4be8dce24563ff25a14da9418142 (patch)
treebd5298a326a3841802573af4833acec1d78d69ac
parentd3f649dc91b12b816ee09b509ac4df030eeaa329 (diff)
downloadchrome-ec-8450617d98cc4be8dce24563ff25a14da9418142.tar.gz
g: make uart run faster
The EC queue library wrappers are very heavy, let's bypass them and use direct queue access where performance matters the most, in the UART RX driver used by USB streams. BUG=b:38448364 BRANCH=cr50, cr50-mp TEST=with the rest of the patches in place observed a much more reliable streaming of two consoles (ec and ap), both pumping chargen streams into their respective UARTs on an Octopus device. Change-Id: I45dc8f1c0841b43e17ef67e96820669053fba831 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1672208 Reviewed-by: Namyoon Woo <namyoon@chromium.org> (cherry picked from commit e9144509b437218de7092ad4340bb9821ec4ae21) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1684048 (cherry picked from commit 5bf47e515464f2551325c726ae4e827bfb532eef) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1705737 (cherry picked from commit c70e908a30835b74a514a6c0f8eddd58b50454d1)
-rw-r--r--chip/g/usart.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/chip/g/usart.c b/chip/g/usart.c
index e3e83dd1f2..0a08d261b8 100644
--- a/chip/g/usart.c
+++ b/chip/g/usart.c
@@ -145,26 +145,29 @@ void get_data_from_usb(struct usart_config const *config)
void send_data_to_usb(struct usart_config const *config)
{
- /*
- * UART RX FIFO is 32 bytes in size, let's have little extra room so
- * that we could catch up if we are draining the FIFO while the chip
- * keeps receiving.
- */
- uint8_t buffer[50];
- uint32_t i;
- uint32_t room;
struct queue const *uart_in = config->producer.queue;
int uart = config->uart;
+ size_t count;
+ size_t q_room;
+ size_t tail;
+ size_t mask;
+ q_room = queue_space(uart_in);
- i = 0;
- room = MIN(sizeof(buffer), queue_space(uart_in));
+ if (!q_room)
+ return;
- while ((i < room) && uartn_rx_available(uart))
- buffer[i++] = uartn_read_char(uart);
+ mask = uart_in->buffer_units_mask;
+ tail = uart_in->state->tail & mask;
+ count = 0;
- if (i)
- QUEUE_ADD_UNITS(uart_in, buffer, i);
+ while ((count != q_room) && uartn_rx_available(uart)) {
+ uart_in->buffer[tail] = uartn_read_char(uart);
+ tail = (tail + 1) & mask;
+ count++;
+ }
+ if (count)
+ queue_advance_tail(uart_in, count);
}
static void uart_read(struct producer const *producer, size_t count)