xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: xen-devel@lists.xen.org
Cc: patches@linaro.org, ian.campbell@citrix.com,
	Julien Grall <julien.grall@linaro.org>,
	Stefano.Stabellini@eu.citrix.com
Subject: [PATCH] xen/arm: avoid lost characters with early_printk
Date: Thu, 23 May 2013 15:50:11 +0100	[thread overview]
Message-ID: <1369320611-24956-1-git-send-email-julien.grall@linaro.org> (raw)

Introduce the function early_flush to wait until the UART has finished to
transfer the character.
When early printk is enabled, it's possible to loose the last characters if:
    - the UART is initialized by the UART driver
    - Xen hang

This is result to a truncated message. To be sure that the message is fully
transfered by early_printk, add a call to early_flush. This will avoid lost
characters.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
---
 xen/arch/arm/arm32/debug.S  |    7 +++++++
 xen/arch/arm/arm64/debug.S  |    7 +++++++
 xen/arch/arm/early_printk.c |    7 +++++++
 3 files changed, 21 insertions(+)

diff --git a/xen/arch/arm/arm32/debug.S b/xen/arch/arm/arm32/debug.S
index 1bfbfc1..92f5724 100644
--- a/xen/arch/arm/arm32/debug.S
+++ b/xen/arch/arm/arm32/debug.S
@@ -32,6 +32,13 @@ early_putch:
         early_uart_transmit r1, r0
         mov   pc, lr
 
+.globl early_flush
+/* Flush the UART - this function is called by C */
+early_flush:
+        ldr   r1, =FIXMAP_ADDR(FIXMAP_CONSOLE)  /* r1 := VA UART base address */
+        early_uart_ready r1, r2
+        mov   pc, lr
+
 /*
  * Local variables:
  * mode: ASM
diff --git a/xen/arch/arm/arm64/debug.S b/xen/arch/arm/arm64/debug.S
index 38b7c74..c7b5e6c 100644
--- a/xen/arch/arm/arm64/debug.S
+++ b/xen/arch/arm/arm64/debug.S
@@ -32,6 +32,13 @@ early_putch:
         early_uart_transmit x15, w0
         ret
 
+.globl early_flush
+/* Flush the UART - this function is called by C */
+early_flush:
+        ldr   x15, =FIXMAP_ADDR(FIXMAP_CONSOLE)  /* x15 := VA UART base address */
+        early_uart_ready x15, 1
+        ret
+
 /*
  * Local variables:
  * mode: ASM
diff --git a/xen/arch/arm/early_printk.c b/xen/arch/arm/early_printk.c
index 5950323..ca151a5 100644
--- a/xen/arch/arm/early_printk.c
+++ b/xen/arch/arm/early_printk.c
@@ -16,6 +16,7 @@
 #include <asm/early_printk.h>
 
 void early_putch(char c);
+void early_flush(void);
 
 /* Early printk buffer */
 static char __initdata buf[512];
@@ -34,6 +35,12 @@ static void __init early_vprintk(const char *fmt, va_list args)
 {
     vsnprintf(buf, sizeof(buf), fmt, args);
     early_puts(buf);
+
+    /*
+     * Wait the UART has finished to transfer all characters before
+     * to continue. This will avoid lost characters if Xen abort.
+     */
+    early_flush();
 }
 
 void __init early_printk(const char *fmt, ...)
-- 
1.7.10.4

             reply	other threads:[~2013-05-23 14:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-23 14:50 Julien Grall [this message]
2013-05-30  9:00 ` [PATCH] xen/arm: avoid lost characters with early_printk Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1369320611-24956-1-git-send-email-julien.grall@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=Stefano.Stabellini@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=patches@linaro.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).