Skip to contentSkip to conversation

hw/char/exynos4210_uart: Fix buffer size reporting with FIFO disabled

PATCH Applied Iris Johnson 2 participants 2 messages Jan 28, 2021 – Feb 2, 2021 Arm Samsung Exynos

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/char/exynos4210_uart: Fix buffer size reporting with FIFO disabled

Currently the Exynos 4210 UART code always reports available FIFO space when the backend checks for buffer space. When the FIFO is disabled this is behavior causes the backend chardev code to replace the data before the guest can read it.

This patch changes adds the logic to report the capacity properly when the FIFO is not being used.

---
 hw/char/exynos4210_uart.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
hw/char/exynos4210_uart.c +5 -1
index 6361df2ad3..9b21d201b3 100644
@@ -553,7 +553,11 @@ static int exynos4210_uart_can_receive(void *opaque)
 {
     Exynos4210UartState *s = (Exynos4210UartState *)opaque;
 
-    return fifo_empty_elements_number(&s->rx);
+    if (s->reg[I_(UFCON)] & UFCON_FIFO_ENABLE) {
+        return fifo_empty_elements_number(&s->rx);
+    } else {
+        return !(s->reg[I_(UTRSTAT)] & UTRSTAT_Rx_BUFFER_DATA_READY);
+    }
 }
 
 static void exynos4210_uart_receive(void *opaque, const uint8_t *buf, int size)
Signature · 1 line
2.25.1
#1 lore raw
Quoted 6 lines · Iris Johnson

Currently the Exynos 4210 UART code always reports available FIFO space when the backend checks for buffer space. When the FIFO is disabled this is behavior causes the backend chardev code to replace the data before the guest can read it.

Quoted 8 lines

This patch changes adds the logic to report the capacity properly when the FIFO is not being used.

---
 hw/char/exynos4210_uart.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Applied to target-arm.next, thanks.

-- PMM