Skip to contentSkip to conversation

drivers/exynos4210: Wait the end of last transfer before initializing the UART

PATCH In review Julien Grall 2 participants 4 messages May 22, 2013 – May 23, 2013 Arm Samsung Exynos

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/exynos4210: Wait the end of last transfer before initializing the UART

When early printk is enabled by the user, it's possible to loose the last characters if the UART is initialized without waiting that the last transfer was completed.

---
 xen/drivers/char/exynos4210-uart.c |    6 ++++++
 1 file changed, 6 insertions(+)
xen/drivers/char/exynos4210-uart.c +6 -0
index f7971da..13758d4 100644
@@ -104,6 +104,12 @@ static void __init exynos4210_uart_init_preirq(struct serial_port *port)
     unsigned int divisor;
     uint32_t ulcon;
 
+#ifdef EARLY_PRINTK
+    /* Flush the UART */
+    while ( !(exynos4210_read(uart, UTRSTAT) &  UTRSTAT_TX_EMPTY) )
+        cpu_relax();
+#endif
+
     /* reset, TX/RX disables */
     exynos4210_write(uart, UCON, 0);
 
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 3 lines · Julien Grall

When early printk is enabled by the user, it's possible to loose the last characters if the UART is initialized without waiting that the last transfer was completed.

It might actually be useful to do this in early_printk, i.e. a new early_uart_flush or so called from puts and early_puts (or even just from the putch hook).

Any opinions?

Perhaps we should take this fix as is for 4.3 and look at the alternatives for 4.4?

Quoted 22 lines
---
 xen/drivers/char/exynos4210-uart.c |    6 ++++++
 1 file changed, 6 insertions(+)
xen/drivers/char/exynos4210-uart.c +6 -0
index f7971da..13758d4 100644
@@ -104,6 +104,12 @@ static void __init exynos4210_uart_init_preirq(struct serial_port *port)
     unsigned int divisor;
     uint32_t ulcon;
 
+#ifdef EARLY_PRINTK
+    /* Flush the UART */
+    while ( !(exynos4210_read(uart, UTRSTAT) &  UTRSTAT_TX_EMPTY) )
+        cpu_relax();
+#endif
+
     /* reset, TX/RX disables */
     exynos4210_write(uart, UCON, 0);
 
#2 lore raw
Quoted 8 lines · Ian Campbell
Quoted 3 lines · Julien Grall

When early printk is enabled by the user, it's possible to loose the last characters if the UART is initialized without waiting that the last transfer was completed.

It might actually be useful to do this in early_printk, i.e. a new early_uart_flush or so called from puts and early_puts (or even just from the putch hook).

BTW, my concern here is crashing without flushing the buffer and therefore missing a useful message or having a misleading log...

#3 lore raw
Quoted 6 lines · Ian Campbell
Quoted 5 lines · Ian Campbell
Quoted 3 lines · Julien Grall

When early printk is enabled by the user, it's possible to loose the last characters if the UART is initialized without waiting that the last transfer was completed.

Quoted 8 lines
Quoted 3 lines

It might actually be useful to do this in early_printk, i.e. a new early_uart_flush or so called from puts and early_puts (or even just from the putch hook).

BTW, my concern here is crashing without flushing the buffer and therefore missing a useful message or having a misleading log...

Right. The change is not complicate, so I will create early_uart_flush and call it in early_printk.

Signature · 1 line
Julien