diff mbox series

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

Message ID 20210128033655.1029577-1-iris@modwiz.com (mailing list archive)
State New, archived
Headers show
Series hw/char/exynos4210_uart: Fix buffer size reporting with FIFO disabled | expand

Commit Message

Iris Johnson Jan. 28, 2021, 3:36 a.m. UTC
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.

Buglink: https://bugs.launchpad.net/qemu/+bug/1913344
Signed-off-by: Iris Johnson <iris@modwiz.com>
---
 hw/char/exynos4210_uart.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Peter Maydell Feb. 2, 2021, 11:07 a.m. UTC | #1
On Thu, 28 Jan 2021 at 03:36, Iris Johnson <iris@modwiz.com> wrote:
>
> 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.
>
> Buglink: https://bugs.launchpad.net/qemu/+bug/1913344
> Signed-off-by: Iris Johnson <iris@modwiz.com>
> ---
>  hw/char/exynos4210_uart.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)



Applied to target-arm.next, thanks.

-- PMM
diff mbox series

Patch

diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c
index 6361df2ad3..9b21d201b3 100644
--- a/hw/char/exynos4210_uart.c
+++ b/hw/char/exynos4210_uart.c
@@ -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)