[Skiboot] [RFC PATCH 07/12] core/console: Rename con_out to flush_head

Oliver O'Halloran oohall at gmail.com
Tue May 19 15:46:28 AEST 2020


Skiboot acts as a producer and consumer of the skiboot log buffer. In
the role of a consumer skiboot writes the contents of the log buffer to
the host console using the internal console driver. In order to do that
we need to keep track how much of the log buffer has been written to the
console.

To do that we use con_out to track the offset of the last flushed
postition. Rename the variable to reflect it's actual usage.

Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
 core/console.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/core/console.c b/core/console.c
index 3ef360fe0c65..e18c4c3213bb 100644
--- a/core/console.c
+++ b/core/console.c
@@ -20,9 +20,9 @@ static char *con_buf = (char *)INMEM_CON_START;
 /*
  * Skiboot is both the producer and consumer of the memcons. On the consumer
  * side we need to keep track of how much of the log buffer has been written
- * out to the console which is what con_out is for.
+ * out to the console which is what flush_head is for.
  */
-static size_t con_out;
+static size_t flush_head;
 static bool con_wrapped;
 
 /* Internal console driver ops */
@@ -109,7 +109,7 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock)
 	static bool in_flush, more_flush;
 
 	/* Is there anything to flush ? Bail out early if not */
-	if (memcons.out_pos == con_out || !con_driver)
+	if (memcons.out_pos == flush_head || !con_driver)
 		return false;
 
 	/*
@@ -145,10 +145,10 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock)
 
 	/*
 	 * NB: this must appear after the in_flush check since it modifies
-	 *     con_out.
+	 *     flush_head.
 	 */
 	if (!flush_to_drivers) {
-		con_out = memcons.out_pos;
+		flush_head = memcons.out_pos;
 		in_flush = false;
 		return false;
 	}
@@ -156,17 +156,17 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock)
 	do {
 		more_flush = false;
 
-		if (con_out > memcons.out_pos) {
-			req = INMEM_CON_OUT_LEN - con_out;
+		if (flush_head > memcons.out_pos) {
+			req = INMEM_CON_OUT_LEN - flush_head;
 			more_flush = true;
 		} else
-			req = memcons.out_pos - con_out;
+			req = memcons.out_pos - flush_head;
 
 		unlock(&con_lock);
-		len = con_driver->write(con_buf + con_out, req);
+		len = con_driver->write(con_buf + flush_head, req);
 		lock(&con_lock);
 
-		con_out = (con_out + len) % INMEM_CON_OUT_LEN;
+		flush_head = (flush_head + len) % INMEM_CON_OUT_LEN;
 
 		/* write error? */
 		if (len < req)
@@ -174,7 +174,7 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock)
 	} while(more_flush);
 
 	in_flush = false;
-	return con_out != memcons.out_pos;
+	return flush_head != memcons.out_pos;
 }
 
 bool flush_console(void)
@@ -219,8 +219,8 @@ static void write_char(char c)
 	inmem_write(c);
 
 	/* If head reaches tail, push tail around & drop chars */
-	if (con_out == memcons.desc->out_pos)
-		con_out = (memcons.desc->out_pos + 1) % memcons.desc->obuf_size;
+	if (flush_head == memcons.desc->out_pos)
+		flush_head = (memcons.desc->out_pos + 1) % memcons.desc->obuf_size;
 }
 
 ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count)
-- 
2.26.2



More information about the Skiboot mailing list