uart: fix uart_opal_flush to take console lock over uart_con_flush
Cc: Russell Currey
@@ -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)
