diff mbox series

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

Message ID 20210908183901.3773783-2-grimm@linux.ibm.com
State New
Headers show
Series AWAN HACK to flush console | expand

Checks

Context Check Description
snowpatch_ozlabs/github-Docker_builds_and_checks success Successfully ran 8 jobs.

Commit Message

Ryan Grimm Sept. 8, 2021, 6:39 p.m. UTC
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@linux.ibm.com>
---
 core/console.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
diff mbox series

Patch

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;
 }