summaryrefslogtreecommitdiff
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
parente36a0bf504f7e091e964a66d20d30b27e01fae57 (diff)
downloadchrome-ec-stabilize-15317.B-main.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>
-rw-r--r--zephyr/Kconfig.console12
-rw-r--r--zephyr/program/nissa/program.conf2
-rw-r--r--zephyr/shim/src/console.c12
3 files changed, 23 insertions, 3 deletions
diff --git a/zephyr/Kconfig.console b/zephyr/Kconfig.console
index 74de199067..78a2233246 100644
--- a/zephyr/Kconfig.console
+++ b/zephyr/Kconfig.console
@@ -35,6 +35,18 @@ config SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE
config SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE
default 192
+config PLATFORM_EC_ISR_CONSOLE_OUTPUT
+ bool "Log in ISRs"
+ depends on CONSOLE
+ default y
+ help
+ If enabled, allowing console output when in interrupt service routines
+ via printk. If disabled, silently drop these messages.
+
+ Console output via printk is unbuffered, so console output when in ISRs
+ should be avoided if possible - larger amounts of output will prevent
+ the EC from timely interrupt servicing.
+
menuconfig PLATFORM_EC_HOSTCMD_CONSOLE
bool "Console Host Command"
depends on PLATFORM_EC_HOSTCMD
diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf
index 65a4914dc5..e22cbb4c0c 100644
--- a/zephyr/program/nissa/program.conf
+++ b/zephyr/program/nissa/program.conf
@@ -14,6 +14,8 @@ CONFIG_LTO=y
CONFIG_FLASH_SHELL=n
# EC default 1kB buffer seems unnecessarily large, Zephyr default is 8 bytes
CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE=128
+# Don't allow console output during ISRs
+CONFIG_PLATFORM_EC_ISR_CONSOLE_OUTPUT=n
# Standard shimmed features
CONFIG_PLATFORM_EC_BACKLIGHT_LID=y
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))