summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@google.com>2021-08-09 12:38:27 -0600
committerCommit Bot <commit-bot@chromium.org>2021-08-11 03:19:17 +0000
commitf525ab7bc3e81039a63d56efd0539d0d2ba3dfb3 (patch)
treec06cb9c1b4328909036ac518681361834c6ea2de
parent586b90cfe982b238b4de4ace9015c088f0ba0e12 (diff)
downloadchrome-ec-f525ab7bc3e81039a63d56efd0539d0d2ba3dfb3.tar.gz
zephyr: shim: zephyr_print option to use printk
Some devices are not able to output fast enough using shell_fprintf and they timeout unrelated functionality. For this case it will be allowed to use a define CONFIG_PLATFORM_EC_CONSOLE_USES_PRINTK to force zephyr_print to use printk BUG=b:193585176 BRANCH=none TEST=zmake configure -b $PROJ_HAYATO Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I8a08fc730637e1d9e2b612b877572fac235a4be4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3082328 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--zephyr/Kconfig.console11
-rw-r--r--zephyr/shim/src/console.c10
2 files changed, 20 insertions, 1 deletions
diff --git a/zephyr/Kconfig.console b/zephyr/Kconfig.console
index 602a2ea26a..c1edee71d5 100644
--- a/zephyr/Kconfig.console
+++ b/zephyr/Kconfig.console
@@ -51,3 +51,14 @@ config PLATFORM_EC_HOSTCMD_CONSOLE_BUF_SIZE
modular arithmetic is used.
endif # PLATFORM_EC_HOSTCMD_CONSOLE
+
+config PLATFORM_EC_CONSOLE_USES_PRINTK
+ bool "Console uses printk"
+ depends on CONSOLE
+ help
+ Implement zephyr_print using printk for all cases instead
+ of using shell_fprintf for non-ISR uses in
+ shim/common/console.c.
+ Some devices have not been able to output to the console
+ fast enough using shell_fprintf and end up timing out
+ unrelated functionality.
diff --git a/zephyr/shim/src/console.c b/zephyr/shim/src/console.c
index ae3ae51deb..39176a45e0 100644
--- a/zephyr/shim/src/console.c
+++ b/zephyr/shim/src/console.c
@@ -274,7 +274,15 @@ static void zephyr_print(const char *buff, size_t size)
if (k_is_in_isr() || shell_zephyr->ctx->state != SHELL_STATE_ACTIVE)
printk("%s", buff);
else {
- shell_fprintf(shell_zephyr, SHELL_NORMAL, "%s", buff);
+ /*
+ * On some platforms, shell_* functions are not as fast
+ * as printk and they need the added speed to avoid
+ * timeouts.
+ */
+ if (IS_ENABLED(CONFIG_PLATFORM_EC_CONSOLE_USES_PRINTK))
+ printk("%s", buff);
+ else
+ shell_fprintf(shell_zephyr, SHELL_NORMAL, "%s", buff);
if (IS_ENABLED(CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE))
console_buf_notify_chars(buff, size);
}