[Skiboot] [PATCH] uart: fix uart_opal_flush to take console lock over uart_con_flush

Nicholas Piggin npiggin at gmail.com
Mon Apr 9 13:49:54 AEST 2018


Cc: Russell Currey <ruscur at russell.cc>
Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
 hw/lpc-uart.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/hw/lpc-uart.c b/hw/lpc-uart.c
index 3224de9f..74a86b13 100644
--- a/hw/lpc-uart.c
+++ b/hw/lpc-uart.c
@@ -218,7 +218,7 @@ static uint8_t *out_buf;
 static uint32_t out_buf_prod;
 static uint32_t out_buf_cons;
 
-/* Asynchronous flush */
+/* Asynchronous flush, uart_lock must be held */
 static int64_t uart_con_flush(void)
 {
 	bool tx_was_full = tx_full;
@@ -388,10 +388,16 @@ static int64_t uart_opal_read(int64_t term_number, int64_t *length,
 
 static int64_t uart_opal_flush(int64_t term_number)
 {
+	int64_t rc;
+
 	if (term_number != 0)
 		return OPAL_PARAMETER;
 
-	return uart_con_flush();
+	lock(&uart_lock);
+	rc = uart_con_flush();
+	unlock(&uart_lock);
+
+	return rc;
 }
 
 static void __uart_do_poll(u8 trace_ctx)
-- 
2.17.0



More information about the Skiboot mailing list