From e613d704d12592dfc371d81957a3d83b0742fa7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Tue, 12 Feb 2019 14:16:21 +0200 Subject: console: Split loglevel for fast and slow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For fast CBMEM console use minimum BIOS_DEBUG level. For other consoles, Kconfig and/or nvram settings apply. Change-Id: Iff56a0a3182f258200cac80e013957d598cc2130 Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/31370 Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner --- src/console/init.c | 14 +++++++++++++- src/console/printk.c | 22 ++++++++++++++++------ src/include/console/console.h | 2 ++ src/soc/intel/quark/romstage/fsp2_0.c | 2 +- 4 files changed, 32 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/console/init.c b/src/console/init.c index 7d1f31a38b..b7cc43aef2 100644 --- a/src/console/init.c +++ b/src/console/init.c @@ -15,6 +15,7 @@ */ #include +#include #include #include #include @@ -64,7 +65,18 @@ static void init_log_level(void) int console_log_level(int msg_level) { - return (get_log_level() >= msg_level); + int log_level = get_log_level(); + + if (log_level < 0) + return CONSOLE_LOG_NONE; + + if (msg_level <= log_level) + return CONSOLE_LOG_ALL; + + if (IS_ENABLED(CONFIG_CONSOLE_CBMEM) && (msg_level <= BIOS_DEBUG)) + return CONSOLE_LOG_FAST; + + return 0; } asmlinkage void console_init(void) diff --git a/src/console/printk.c b/src/console/printk.c index 0a9d3bf8ae..6050620dca 100644 --- a/src/console/printk.c +++ b/src/console/printk.c @@ -17,6 +17,7 @@ * blatantly copied from linux/kernel/printk.c */ +#include #include #include #include @@ -36,18 +37,24 @@ void do_putchar(unsigned char byte) static void wrap_putchar(unsigned char byte, void *data) { - do_putchar(byte); + console_tx_byte(byte); +} + +static void wrap_putchar_cbmemc(unsigned char byte, void *data) +{ + __cbmemc_tx_byte(byte); } int vprintk(int msg_level, const char *fmt, va_list args) { - int i; + int i, log_this; if (IS_ENABLED(CONFIG_SQUELCH_EARLY_SMP) && ENV_CACHE_AS_RAM && !boot_cpu()) return 0; - if (!console_log_level(msg_level)) + log_this = console_log_level(msg_level); + if (log_this < CONSOLE_LOG_FAST) return 0; DISABLE_TRACE; @@ -59,9 +66,12 @@ int vprintk(int msg_level, const char *fmt, va_list args) spin_lock(&console_lock); #endif - i = vtxprintf(wrap_putchar, fmt, args, NULL); - - console_tx_flush(); + if (log_this == CONSOLE_LOG_FAST) { + i = vtxprintf(wrap_putchar_cbmemc, fmt, args, NULL); + } else { + i = vtxprintf(wrap_putchar, fmt, args, NULL); + console_tx_flush(); + } #ifdef __PRE_RAM__ #if IS_ENABLED(CONFIG_HAVE_ROMSTAGE_CONSOLE_SPINLOCK) diff --git a/src/include/console/console.h b/src/include/console/console.h index 33fe2dfd17..2b02334c8e 100644 --- a/src/include/console/console.h +++ b/src/include/console/console.h @@ -62,6 +62,8 @@ void do_putchar(unsigned char byte); #define printk(LEVEL, fmt, args...) \ do { do_printk(LEVEL, fmt, ##args); } while (0) +enum { CONSOLE_LOG_NONE = 0, CONSOLE_LOG_FAST, CONSOLE_LOG_ALL }; + #if IS_ENABLED(CONFIG_CONSOLE_OVERRIDE_LOGLEVEL) /* * This function should be implemented at mainboard level. diff --git a/src/soc/intel/quark/romstage/fsp2_0.c b/src/soc/intel/quark/romstage/fsp2_0.c index 23051bde6d..c237da5270 100644 --- a/src/soc/intel/quark/romstage/fsp2_0.c +++ b/src/soc/intel/quark/romstage/fsp2_0.c @@ -173,7 +173,7 @@ void platform_fsp_memory_init_params_cb(FSPM_UPD *fspm_upd, uint32_t version) upd->RankMask = config->RankMask; upd->RmuBaseAddress = (uintptr_t)rmu_data; upd->RmuLength = rmu_data_len; - upd->SerialPortWriteChar = console_log_level(BIOS_SPEW) + upd->SerialPortWriteChar = !!console_log_level(BIOS_SPEW) ? (uintptr_t)fsp_write_line : 0; upd->SmmTsegSize = IS_ENABLED(CONFIG_HAVE_SMI_HANDLER) ? config->SmmTsegSize : 0; -- cgit v1.2.3