[Skiboot] [RFC PATCH 1/1] AWAN CHIP HACK: Flush console buffer to memory

Ryan Grimm grimm at linux.ibm.com
Thu Sep 9 04:39:01 AEST 2021


Flush console buffer to memory every 128 bytes so utilties that read the
DIMMs will be able to access the console.

Also flush the memcons structure so we know when the console is updated.

Signed-off-by: Ryan Grimm <grimm at linux.ibm.com>
---
 core/console.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/core/console.c b/core/console.c
index 2a1509025..ee2dac110 100644
--- a/core/console.c
+++ b/core/console.c
@@ -174,6 +174,9 @@ bool flush_console(void)
 	return ret;
 }
 
+static size_t total_bytes = 0;
+static int total_cache_lines = 0;
+
 static void inmem_write(char c)
 {
 	uint32_t opos;
@@ -186,6 +189,16 @@ static void inmem_write(char c)
 		con_wrapped = true;
 	}
 
+	total_bytes++;
+	if (total_bytes > 127) {
+		asm volatile("dcbf %0,%1"
+		     :
+		     : "a" (INMEM_CON_START), "b" ((total_cache_lines % (INMEM_CON_LEN / 128)) * 128)
+		     : "memory");
+		total_cache_lines++;
+		total_bytes = 0;
+	}
+
 	/*
 	 * We must always re-generate memcons.out_pos because
 	 * under some circumstances, the console script will
@@ -247,6 +260,10 @@ ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count)
 	if (need_unlock)
 		unlock(&con_lock);
 
+	asm volatile("dcbf %0,%1"
+		     :
+		     : "r" (0), "b" (&memcons)
+		     : "memory");
 	return count;
 }
 
-- 
2.25.1



More information about the Skiboot mailing list