summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2014-07-31 14:30:04 +1000
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-08-08 16:07:26 +1000
commit68218760dc200b268487d005da8b0567d405e3c1 (patch)
treedfc327f6561da1e9e78b07b08ba9c03eedda2c7d
parent451e6a755e58e692d1ec8ffb1b1416a0a0c47604 (diff)
downloadtalos-skiboot-68218760dc200b268487d005da8b0567d405e3c1.tar.gz
talos-skiboot-68218760dc200b268487d005da8b0567d405e3c1.zip
Make log level thresholds dynamic in debug_descriptor rather than static
This enables (advanced) users to vary what level of output they want at runtime in the memory console and through console drivers (fsp/uart) You can vary two things by poking in the debug descriptor: a) what log level is printed at all e.g. only turn on PR_TRACE at specific points during runtime b) what log level goes out the fsp/uart console defaults to PR_PRINTF We use two 4bit numbers (1 byte) for this in debug descriptor (saving some space, not needlessly wasting space that we may want in future). The default is 0x75 (7=PR_DEBUG to in memory console, 5=PR_PRINTF to drivers) If you write 0x77 you will get debug info on uart/fsp console as well as in memory. If you write 0x95 you get PR_INSANE in memory but still only PR_NOTICE through drivers. People who write something like 0x1f will get a very quiet boot indeed. A future patch would be to (when possible) peek at device tree entries for if we should change the default. A future patch would add an OPAL API to get/set this. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r--core/console-log.c16
-rw-r--r--core/init.c5
-rw-r--r--include/skiboot.h6
3 files changed, 25 insertions, 2 deletions
diff --git a/core/console-log.c b/core/console-log.c
index 3d1b43fc..a9556ea8 100644
--- a/core/console-log.c
+++ b/core/console-log.c
@@ -31,12 +31,26 @@ static int vprlog(int log_level, const char *fmt, va_list ap)
{
int count;
char buffer[320];
+ bool flush_to_drivers = true;
+
+ /* It's safe to return 0 when we "did" something here
+ * as only printf cares about how much we wrote, and
+ * if you change log_level to below PR_PRINTF then you
+ * get everything you deserve.
+ * By default, only PR_DEBUG and higher are stored in memory.
+ * PR_TRACE and PR_INSANE are for those having a bad day.
+ */
+ if (log_level > (debug_descriptor.console_log_levels >> 4))
+ return 0;
count = snprintf(buffer, sizeof(buffer), "[%lu,%d] ",
mftb(), log_level);
count+= vsnprintf(buffer+count, sizeof(buffer)-count, fmt, ap);
- console_write((log_level > PR_NOTICE) ? false : true, buffer, count);
+ if (log_level > (debug_descriptor.console_log_levels & 0x0f))
+ flush_to_drivers = false;
+
+ console_write(flush_to_drivers, buffer, count);
return count;
}
diff --git a/core/init.c b/core/init.c
index 3d72ce5d..03af34ec 100644
--- a/core/init.c
+++ b/core/init.c
@@ -60,6 +60,7 @@ struct debug_descriptor debug_descriptor = {
.version = DEBUG_DESC_VERSION,
.memcons_phys = (uint64_t)&memcons,
.trace_mask = 0, /* All traces disabled by default */
+ .console_log_levels = (PR_DEBUG << 4) | PR_NOTICE,
};
static bool try_load_elf64_le(struct elf_hdr *header)
@@ -488,6 +489,10 @@ void __noreturn main_cpu_entry(const void *fdt, u32 master_cpu)
clear_console();
printf("SkiBoot %s starting...\n", gitid);
+ printf("initial console log level: memory %d, driver %d\n",
+ (debug_descriptor.console_log_levels >> 4),
+ (debug_descriptor.console_log_levels & 0x0f));
+ prlog(PR_TRACE, "You will not see this\n");
/* Initialize boot cpu's cpu_thread struct */
init_boot_cpu();
diff --git a/include/skiboot.h b/include/skiboot.h
index 79f85ce2..ddc6b4ac 100644
--- a/include/skiboot.h
+++ b/include/skiboot.h
@@ -58,7 +58,11 @@ struct debug_descriptor {
u8 eye_catcher[8]; /* "OPALdbug" */
#define DEBUG_DESC_VERSION 1
u32 version;
- u32 reserved[3];
+ u8 console_log_levels; /* high 4 bits in memory,
+ * low 4 bits driver (e.g. uart). */
+ u8 reserved1;
+ u16 reserved2;
+ u32 reserved[2];
/* Memory console */
u64 memcons_phys;
OpenPOWER on IntegriCloud