From patchwork Thu Apr 20 07:15:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 752663 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3w7qrg0rL5z9s4s for ; Thu, 20 Apr 2017 17:15:15 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3w7qrg07xpzDqKs for ; Thu, 20 Apr 2017 17:15:15 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [103.22.144.67]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3w7qrY0dJ9zDqJg for ; Thu, 20 Apr 2017 17:15:09 +1000 (AEST) Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 3w7qrX6hKyz9s4s; Thu, 20 Apr 2017 17:15:08 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id DFA1CEEEE8A; Thu, 20 Apr 2017 17:15:08 +1000 (AEST) From: Michael Neuling To: stewart@linux.vnet.ibm.com Date: Thu, 20 Apr 2017 17:15:00 +1000 Message-Id: <20170420071500.1674-1-mikey@neuling.org> X-Mailer: git-send-email 2.11.0 Subject: [Skiboot] [PATCH] console: Set log level from nvram X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: skiboot@lists.ozlabs.org, mikey@neuling.org, cyrilbur@gmail.com MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This adds two new nvram options to set the console log level for the driver/uart and in memory. These are called log-level-memory and log-level-driver. These are only set once we have nvram inited. To set them you do: nvram -p ibm,skiboot --update-config log-level-memory=9 nvram -p ibm,skiboot --update-config log-level-driver=9 You can also use the named versions of emerg, alert, crit, err, warning, notice, printf, info, debug, trace or insane. ie. nvram -p ibm,skiboot --update-config log-level-driver=insane Suggested-by: Benjamin Herrenschmidt Signed-off-by: Michael Neuling Reviewed-by: Cyril Bur --- core/init.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/skiboot.h | 4 +++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/core/init.c b/core/init.c index 6b8137c8c7..9d4d185dda 100644 --- a/core/init.c +++ b/core/init.c @@ -68,6 +68,8 @@ struct debug_descriptor debug_descriptor = { .state_flags = 0, .memcons_phys = (uint64_t)&memcons, .trace_mask = 0, /* All traces disabled by default */ + /* console log level: + * high 4 bits in memory, low 4 bits driver (e.g. uart). */ #ifdef DEBUG .console_log_levels = (PR_DEBUG << 4) | PR_DEBUG, #else @@ -615,6 +617,61 @@ static void dt_init_misc(void) dt_fixups(); } +static u8 console_get_level(const char *s) +{ + if (strcmp(s, "emerg") == 0) + return PR_EMERG; + if (strcmp(s, "alert") == 0) + return PR_ALERT; + if (strcmp(s, "crit") == 0) + return PR_CRIT; + if (strcmp(s, "err") == 0) + return PR_ERR; + if (strcmp(s, "warning") == 0) + return PR_WARNING; + if (strcmp(s, "notice") == 0) + return PR_NOTICE; + if (strcmp(s, "printf") == 0) + return PR_PRINTF; + if (strcmp(s, "info") == 0) + return PR_INFO; + if (strcmp(s, "debug") == 0) + return PR_DEBUG; + if (strcmp(s, "trace") == 0) + return PR_TRACE; + if (strcmp(s, "insane") == 0) + return PR_INSANE; + /* Assume it's a number instead */ + return atoi(s); +} + +static void console_log_level(void) +{ + const char *s; + u8 level; + + /* console log level: + * high 4 bits in memory, low 4 bits driver (e.g. uart). */ + s = nvram_query("log-level-driver"); + if (s) { + level = console_get_level(s); + debug_descriptor.console_log_levels = + (debug_descriptor.console_log_levels & 0xf0 ) | + (level & 0x0f); + prlog(PR_NOTICE, "console: Setting driver log level to %i\n", + level & 0x0f); + } + s = nvram_query("log-level-memory"); + if (s) { + level = console_get_level(s); + debug_descriptor.console_log_levels = + (debug_descriptor.console_log_levels & 0x0f ) | + ((level & 0x0f) << 4); + prlog(PR_NOTICE, "console: Setting memory log level to %i\n", + level & 0x0f); + } +} + typedef void (*ctorcall_t)(void); static void __nomcount do_ctors(void) @@ -921,6 +978,9 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt) /* Read in NVRAM and set it up */ nvram_init(); + /* Set the console level */ + console_log_level(); + /* Secure/Trusted Boot init. We look for /ibm,secureboot in DT */ stb_init(); diff --git a/include/skiboot.h b/include/skiboot.h index 2b1f8a577e..5c8b0c854d 100644 --- a/include/skiboot.h +++ b/include/skiboot.h @@ -91,7 +91,9 @@ static inline bool opal_booting(void) return !(debug_descriptor.state_flags & OPAL_BOOT_COMPLETE); } -/* Console logging */ +/* Console logging + * Update console_get_level() if you add here + */ #define PR_EMERG 0 #define PR_ALERT 1 #define PR_CRIT 2