diff options
author | Wai-Hong Tam <waihong@google.com> | 2019-05-06 13:20:31 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-05-11 14:18:17 -0700 |
commit | e02b08ceca36300a602c50b2b3cc81f3a5385978 (patch) | |
tree | ca86369257c69186d762a653dedf335e98fa51a8 /include/config.h | |
parent | 1009c67272f56d66f4d23a2994bf30809a0deef5 (diff) | |
download | chrome-ec-e02b08ceca36300a602c50b2b3cc81f3a5385978.tar.gz |
stm32: Decouple printf logic from directly calling USB console driver
When calling printf functions, it was to call the USB console driver
directly, i.e. copying all the bytes to USB package buffer and enabling
the transmission. If the next printf is called immediately before the
USB transmission is done, it will wait (polling the EP_TX_VALID status).
This implementation limited each printf function can only transmit 64
bytes, i.e. the USB max package size. The remaining bytes will be
dropped silently.
To fix this issue, this CL puts a queue between the printf logic and
the driver. The size of the queue is 2048-byte (no overflow happened on
a normal boot and console commands). The printf logic now fills the
queue and schedules a deferred hook to handle the transmission. When the
transmission is done, an interrupt will be triggered that schedules
the deferred hook again to check any remaining bytes need to be
transmitted.
For the incoming bytes, replace the circular buffer to a queue structure
for better reusability. No major logic changes.
BRANCH=servo
BUG=b:129423678
TEST=Manually added a printf call to show >64 bytes and verified it.
TEST=Manually added a printf call to show >2048 bytes and the bytes
after the 2048-th dropped silently.
Change-Id: Icb2310421d7bcbbff8d7cd753c732390acc43ab8
Signed-off-by: Wai-Hong Tam <waihong@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1597960
Commit-Ready: Todd Broch <tbroch@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Diffstat (limited to 'include/config.h')
-rw-r--r-- | include/config.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/config.h b/include/config.h index 8d8d2631b2..f1719806da 100644 --- a/include/config.h +++ b/include/config.h @@ -3716,6 +3716,9 @@ /* Enable USB serial console module. */ #undef CONFIG_USB_CONSOLE +/* USB serial console transmit buffer size in bytes. */ +#define CONFIG_USB_CONSOLE_TX_BUF_SIZE 2048 + /* * Enable USB serial console crc32 computation. * Also makes console output block on overrun. |