aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2014-07-31 14:30:03 +1000
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-08-08 16:07:26 +1000
commit451e6a755e58e692d1ec8ffb1b1416a0a0c47604 (patch)
treecb61365796c0f4ea47c5ccc0d40c045dbdbd2857
parent904a3b51a20102fb504c498a55d31ce87c525643 (diff)
downloadskiboot-451e6a755e58e692d1ec8ffb1b1416a0a0c47604.zip
skiboot-451e6a755e58e692d1ec8ffb1b1416a0a0c47604.tar.gz
skiboot-451e6a755e58e692d1ec8ffb1b1416a0a0c47604.tar.bz2
Write log messages with log_level > PR_NOTICE only to in memory log
We modify write() (adding console_write()) which calls down to a modified __flush_console() which can now decide if it's flushing the added console contents to the console drivers or not. A future patch may add support for changing PR_NOTICE to some other level 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.c4
-rw-r--r--core/console.c40
-rw-r--r--hw/fsp/fsp-console.c2
-rw-r--r--include/console.h5
4 files changed, 36 insertions, 15 deletions
diff --git a/core/console-log.c b/core/console-log.c
index 6a70e57..3d1b43f 100644
--- a/core/console-log.c
+++ b/core/console-log.c
@@ -24,6 +24,7 @@
#include "skiboot.h"
#include "unistd.h"
#include "stdio.h"
+#include "console.h"
#include "timebase.h"
static int vprlog(int log_level, const char *fmt, va_list ap)
@@ -34,7 +35,8 @@ static int vprlog(int log_level, const char *fmt, va_list ap)
count = snprintf(buffer, sizeof(buffer), "[%lu,%d] ",
mftb(), log_level);
count+= vsnprintf(buffer+count, sizeof(buffer)-count, fmt, ap);
- write(0, buffer, count);
+
+ console_write((log_level > PR_NOTICE) ? false : true, buffer, count);
return count;
}
diff --git a/core/console.c b/core/console.c
index 5794151..9b41962 100644
--- a/core/console.c
+++ b/core/console.c
@@ -81,9 +81,11 @@ void clear_console(void)
/*
* Flush the console buffer into the driver, returns true
- * if there is more to go
+ * if there is more to go.
+ * Optionally can skip flushing to drivers, leaving messages
+ * just in memory console.
*/
-bool __flush_console(void)
+bool __flush_console(bool flush_to_drivers)
{
struct cpu_thread *cpu = this_cpu();
size_t req, len = 0;
@@ -124,18 +126,27 @@ bool __flush_console(void)
more_flush = false;
if (con_out > con_in) {
req = INMEM_CON_OUT_LEN - con_out;
- unlock(&con_lock);
- len = con_driver->write(con_buf + con_out, req);
- lock(&con_lock);
+ if (!flush_to_drivers) {
+ len = req;
+ } else {
+ unlock(&con_lock);
+ len = con_driver->write(con_buf + con_out,
+ req);
+ lock(&con_lock);
+ }
con_out = (con_out + len) % INMEM_CON_OUT_LEN;
if (len < req)
goto bail;
}
if (con_out < con_in) {
- unlock(&con_lock);
- len = con_driver->write(con_buf + con_out,
- con_in - con_out);
- lock(&con_lock);
+ if (!flush_to_drivers) {
+ len = con_in - con_out;
+ } else {
+ unlock(&con_lock);
+ len = con_driver->write(con_buf + con_out,
+ con_in - con_out);
+ lock(&con_lock);
+ }
con_out = (con_out + len) % INMEM_CON_OUT_LEN;
}
} while(more_flush);
@@ -149,7 +160,7 @@ bool flush_console(void)
bool ret;
lock(&con_lock);
- ret = __flush_console();
+ ret = __flush_console(true);
unlock(&con_lock);
return ret;
@@ -206,7 +217,7 @@ static void write_char(char c)
inmem_write(c);
}
-ssize_t write(int fd __unused, const void *buf, size_t count)
+ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count)
{
/* We use recursive locking here as we can get called
* from fairly deep debug path
@@ -221,7 +232,7 @@ ssize_t write(int fd __unused, const void *buf, size_t count)
write_char(c);
}
- __flush_console();
+ __flush_console(flush_to_drivers);
if (need_unlock)
unlock(&con_lock);
@@ -229,6 +240,11 @@ ssize_t write(int fd __unused, const void *buf, size_t count)
return count;
}
+ssize_t write(int fd __unused, const void *buf, size_t count)
+{
+ return console_write(true, buf, count);
+}
+
ssize_t read(int fd __unused, void *buf, size_t req_count)
{
bool need_unlock = lock_recursive(&con_lock);
diff --git a/hw/fsp/fsp-console.c b/hw/fsp/fsp-console.c
index 858f56a..d14e520 100644
--- a/hw/fsp/fsp-console.c
+++ b/hw/fsp/fsp-console.c
@@ -667,7 +667,7 @@ void fsp_console_poll(void *data __unused)
if (sb->next_out == sb->next_in)
continue;
if (fs->log_port)
- __flush_console();
+ __flush_console(true);
else {
#ifdef OPAL_DEBUG_CONSOLE_POLL
if (debug < 5) {
diff --git a/include/console.h b/include/console.h
index 791f770..8a47bad 100644
--- a/include/console.h
+++ b/include/console.h
@@ -17,6 +17,7 @@
#ifndef __CONSOLE_H
#define __CONSOLE_H
+#include "unistd.h"
#include <lock.h>
/*
@@ -56,9 +57,11 @@ extern struct lock con_lock;
extern bool dummy_console_enabled(void);
extern void force_dummy_console(void);
extern bool flush_console(void);
-extern bool __flush_console(void);
+extern bool __flush_console(bool flush_to_drivers);
extern void set_console(struct con_ops *driver);
+ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count);
+
extern void clear_console(void);
extern void memcons_add_properties(void);
extern void dummy_console_add_nodes(void);