diff options
author | Namyoon Woo <namyoon@chromium.org> | 2019-06-17 20:59:57 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-18 17:07:47 +0000 |
commit | b8a8fde3cc2639ce00245bed7bb59fa362b6bffc (patch) | |
tree | f616b5a6557b87395f4751a1b3d5d3dc8d4a3ae7 /chip/g/usb_console.c | |
parent | e467b21013cf120ce9167bfb6b6e61ccfa258129 (diff) | |
download | chrome-ec-b8a8fde3cc2639ce00245bed7bb59fa362b6bffc.tar.gz |
Revert "g: consolidate USB console transfer codes to usb-stream"
This reverts commit 79e88d81f3e090d959669b4de6215cef96c2a3ed.
Reason for revert: It slows down CR50 UART console response.
The original plan was to consolidate CR50 console USB configuration
into USB stream configuration, then optimize USB stream
implementation. However, I am changing the plan: will commit this
patch after USB stream is optimized.
BUG=None
BRANCH=None
TEST=Downloaded the cr50 bin, and checked the cr50 console responding
stable.
Change-Id: I21ae8c4e043e10c4325bbf91123f2ee185faa413
Signed-off-by: Namyoon Woo <namyoon@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1662849
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'chip/g/usb_console.c')
-rw-r--r-- | chip/g/usb_console.c | 84 |
1 files changed, 10 insertions, 74 deletions
diff --git a/chip/g/usb_console.c b/chip/g/usb_console.c index 12aa5b379b..515229afe4 100644 --- a/chip/g/usb_console.c +++ b/chip/g/usb_console.c @@ -15,18 +15,16 @@ #include "timer.h" #include "util.h" #include "usb_descriptor.h" -#include "usb-stream.h" #include "usb_hw.h" /* Console output macro */ #define CPRINTF(format, args...) cprintf(CC_USB, format, ## args) #define USB_CONSOLE_TIMEOUT_US (30 * MSEC) -#define QUEUE_SIZE_USB_TX 4096 -#define QUEUE_SIZE_USB_RX USB_MAX_PACKET_SIZE - static int last_tx_ok = 1; +static int is_reset; + /* * Start enabled, so we can queue early debug output before the board gets * around to calling usb_console_enable(). @@ -39,62 +37,6 @@ static int is_enabled = 1; */ static int is_readonly = 1; -#ifdef CONFIG_STREAM_USB -struct usb_stream_config const usb_console; - -/* - * This is a usb_console producer policy, which wakes up CONSOLE task whenever - * rx_q gets new data added. This shall be called by rx_stream_handler() in - * usb-stream.c. - */ -static void usb_console_written(struct queue_policy const *policy, size_t count) -{ - task_wake(TASK_ID_CONSOLE); -} - -static void uart_console_read(struct queue_policy const *policy, size_t count) -{ - /* do nothing */ -} - -static struct queue_policy const usb_console_policy = { - .add = usb_console_written, - .remove = uart_console_read, -}; - -static struct queue const tx_q = QUEUE_NULL(QUEUE_SIZE_USB_TX, uint8_t); -static struct queue const rx_q = QUEUE(QUEUE_SIZE_USB_RX, uint8_t, - usb_console_policy); - -USB_STREAM_CONFIG(usb_console, - USB_IFACE_CONSOLE, - USB_STR_CONSOLE_NAME, - USB_EP_CONSOLE, - USB_MAX_PACKET_SIZE, - USB_MAX_PACKET_SIZE, - rx_q, - tx_q) - -static inline void handle_output(void) -{ - /* Wake up the Tx FIFO handler */ - hook_call_deferred(usb_console.deferred_tx, 0); -} - -static inline int tx_fifo_is_ready_(void) -{ - return tx_fifo_is_ready(&usb_console); -} - -static inline int usb_console_is_reset(void) -{ - return usb_stream_is_reset(&usb_console); -} - -#else /* #ifdef CONFIG_STREAM_USB ... */ - -static int is_reset; - /* USB-Serial descriptors */ const struct usb_interface_descriptor USB_IFACE_DESC(USB_IFACE_CONSOLE) = { @@ -132,8 +74,8 @@ static uint8_t ep_buf_rx[USB_MAX_PACKET_SIZE]; static struct g_usb_desc ep_out_desc; static struct g_usb_desc ep_in_desc; -static struct queue const tx_q = QUEUE_NULL(QUEUE_SIZE_USB_TX, uint8_t); -static struct queue const rx_q = QUEUE_NULL(QUEUE_SIZE_USB_RX, uint8_t); +static struct queue const tx_q = QUEUE_NULL(4096, uint8_t); +static struct queue const rx_q = QUEUE_NULL(USB_MAX_PACKET_SIZE, uint8_t); /* Let the USB HW IN-to-host FIFO transmit some bytes */ @@ -235,19 +177,13 @@ static void con_ep_rx(void) /* clear the RX/OUT interrupts */ GR_USB_DOEPINT(USB_EP_CONSOLE) = 0xffffffff; } - /* True if the Tx/IN FIFO can take some bytes from us. */ -static inline int tx_fifo_is_ready_(void) +static inline int tx_fifo_is_ready(void) { uint32_t status = ep_in_desc.flags & DIEPDMA_BS_MASK; return status == DIEPDMA_BS_DMA_DONE || status == DIEPDMA_BS_HOST_BSY; } -static inline int usb_console_is_reset(void) -{ - return is_reset; -} - /* Try to send some bytes to the host */ static void tx_fifo_handler(void) { @@ -257,7 +193,7 @@ static void tx_fifo_handler(void) return; /* If the HW FIFO isn't ready, then we can't do anything right now. */ - if (!tx_fifo_is_ready_()) + if (!tx_fifo_is_ready()) return; count = QUEUE_REMOVE_UNITS(&tx_q, ep_buf_tx, USB_MAX_PACKET_SIZE); @@ -309,7 +245,6 @@ static void ep_reset(void) USB_DECLARE_EP(USB_EP_CONSOLE, con_ep_tx, con_ep_rx, ep_reset); -#endif /* #ifdef CONFIG_STREAM_USB ... #else ... */ static int usb_wait_console(void) { @@ -326,8 +261,7 @@ static int usb_wait_console(void) * we should wait so that we don't clobber the buffer. */ if (last_tx_ok) { - while (queue_space(&tx_q) < USB_MAX_PACKET_SIZE || - !usb_console_is_reset()) { + while (queue_space(&tx_q) < USB_MAX_PACKET_SIZE || !is_reset) { if (timestamp_expired(deadline, NULL) || in_interrupt_context()) { last_tx_ok = 0; @@ -339,10 +273,12 @@ static int usb_wait_console(void) usleep(wait_time_us); wait_time_us *= 2; } + + return EC_SUCCESS; } else { last_tx_ok = queue_space(&tx_q); + return EC_SUCCESS; } - return EC_SUCCESS; } #ifdef CONFIG_USB_CONSOLE_CRC |