From f899a3445d037658fd9a3fe5191cb6f17a553e0c Mon Sep 17 00:00:00 2001 From: Anton Staaf Date: Wed, 22 Oct 2014 13:10:25 -0700 Subject: USB-console: Don't wait in interrupt contexts Previously the USB console code would wait for up to 30 ms for the USB packet buffer to become available for transmission, even if it was called from an interrupt context. This doesn't work because, even if we were OK with waiting this long in interrupt contexts, which we are not, we rightly assert that we are not in an interrupt context in task_wait_event, which usleep calls. This solution is a quick fix to only wait when not called from within an interrupt context. The correct solution is likely to decouple the printf code from directly calling the console driver code, instead we should place a queue between the driver and printf logic. Signed-off-by: Anton Staaf BRANCH=None BUG=None TEST=make buildall -j Enable USB console on discovery board and manually test. Change-Id: I5b6f7bbb77f75132c75935f8fda01e652a236ae0 Reviewed-on: https://chromium-review.googlesource.com/225867 Tested-by: Anton Staaf Reviewed-by: Vincent Palatin Commit-Queue: Anton Staaf --- chip/stm32/usb_console.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chip/stm32/usb_console.c b/chip/stm32/usb_console.c index a8b219bb87..47e31711e0 100644 --- a/chip/stm32/usb_console.c +++ b/chip/stm32/usb_console.c @@ -146,7 +146,8 @@ static int usb_wait_console(void) */ if (last_tx_ok) { while (usb_console_tx_valid() || !is_reset) { - if (timestamp_expired(deadline, NULL)) { + if (timestamp_expired(deadline, NULL) || + in_interrupt_context()) { last_tx_ok = 0; return EC_ERROR_TIMEOUT; } -- cgit v1.2.1