summaryrefslogtreecommitdiff
path: root/zephyr/shim
diff options
context:
space:
mode:
authorAndrew McRae <amcrae@google.com>2023-01-16 16:51:05 +1100
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-01-17 02:07:40 +0000
commit435ced35da433c5eccf33b30711d106e6b3e7307 (patch)
treeb61b386301affeb99052352478daf356b711be97 /zephyr/shim
parente36a0bf504f7e091e964a66d20d30b27e01fae57 (diff)
downloadchrome-ec-435ced35da433c5eccf33b30711d106e6b3e7307.tar.gz
console: Optionally drop output from ISRsstabilize-15317.B-main
Optionally drop console output originating from interrupt level, to avoid printk locking up the EC for any length of time. BUG=b:265594963 TEST=Verify that logs from ISRs are not printed. BRANCH=none Change-Id: Ib6241d66bb3ec518439b46860804d928fd3fcfdf Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4165986 Reviewed-by: Peter Marheine <pmarheine@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'zephyr/shim')
-rw-r--r--zephyr/shim/src/console.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/zephyr/shim/src/console.c b/zephyr/shim/src/console.c
index 60e698f2c0..c3ab2f7cd7 100644
--- a/zephyr/shim/src/console.c
+++ b/zephyr/shim/src/console.c
@@ -392,15 +392,21 @@ static void handle_sprintf_rv(int rv, size_t *len)
static void zephyr_print(const char *buff, size_t size)
{
/*
- * shell_* functions can not be used in ISRs so use printk instead.
+ * shell_* functions can not be used in ISRs so optionally use
+ * printk instead.
* If the shell is about to be (or is) stopped, use printk, since the
* output may be stalled and the shell mutex held.
* Also, console_buf_notify_chars uses a mutex, which may not be
* locked in ISRs.
*/
- if (k_is_in_isr() || shell_stopped ||
+ bool in_isr = k_is_in_isr();
+
+ if (in_isr || shell_stopped ||
shell_zephyr->ctx->state != SHELL_STATE_ACTIVE) {
- printk("%s", buff);
+ if (IS_ENABLED(CONFIG_PLATFORM_EC_ISR_CONSOLE_OUTPUT) ||
+ !in_isr) {
+ printk("%s", buff);
+ }
} else {
shell_fprintf(shell_zephyr, SHELL_NORMAL, "%s", buff);
if (IS_ENABLED(CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE))