summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-06-21 14:01:15 -0700
committerCommit Bot <commit-bot@chromium.org>2019-06-24 22:30:34 +0000
commite9144509b437218de7092ad4340bb9821ec4ae21 (patch)
treeac388fd11cdd3c11f3144484dba4706218a2466e /chip
parentb01ef0473c54b65a170d83f9184bfb7eb9583276 (diff)
downloadchrome-ec-e9144509b437218de7092ad4340bb9821ec4ae21.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>
Diffstat (limited to 'chip')
-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)