[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 15/16] hw/char/pl011: Drain TX FIFO when no backend connected
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v5 15/16] hw/char/pl011: Drain TX FIFO when no backend connected |
Date: |
Fri, 19 Jul 2024 20:10:40 +0200 |
When no character backend is connected, the PL011 frontend
just drains the FIFO.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/char/pl011.c | 13 +++++++++++++
hw/char/trace-events | 1 +
2 files changed, 14 insertions(+)
diff --git a/hw/char/pl011.c b/hw/char/pl011.c
index b8cde03f98..cfa3fd3da4 100644
--- a/hw/char/pl011.c
+++ b/hw/char/pl011.c
@@ -229,6 +229,13 @@ static void pl011_loopback_tx(PL011State *s, uint32_t
value)
pl011_fifo_rx_put(s, value);
}
+static void pl011_drain_tx(PL011State *s)
+{
+ trace_pl011_fifo_tx_drain(fifo8_num_used(&s->xmit_fifo));
+ pl011_reset_tx_fifo(s);
+ s->rsr &= ~RSR_OE;
+}
+
static gboolean pl011_xmit(void *do_not_use, GIOCondition cond, void *opaque)
{
PL011State *s = opaque;
@@ -242,6 +249,12 @@ static gboolean pl011_xmit(void *do_not_use, GIOCondition
cond, void *opaque)
qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled TX
UART\n");
}
+ if (!qemu_chr_fe_backend_connected(&s->chr)) {
+ /* Instant drain the fifo when there's no back-end. */
+ pl011_drain_tx(s);
+ return G_SOURCE_REMOVE;
+ }
+
data = fifo8_pop(&s->xmit_fifo);
bytes_consumed = 1;
diff --git a/hw/char/trace-events b/hw/char/trace-events
index 4a9c0bd271..bf586ba664 100644
--- a/hw/char/trace-events
+++ b/hw/char/trace-events
@@ -63,6 +63,7 @@ pl011_fifo_rx_full(void) "RX FIFO now full, RXFF set"
pl011_fifo_tx_put(uint8_t byte) "TX FIFO push char [0x%02x]"
pl011_fifo_tx_xmit(int count) "TX FIFO pop %d chars"
pl011_fifo_tx_overrun(void) "TX FIFO overrun"
+pl011_fifo_tx_drain(unsigned drained) "TX FIFO draining %u chars"
pl011_baudrate_change(unsigned int baudrate, uint64_t clock, uint32_t ibrd,
uint32_t fbrd) "new baudrate %u (clk: %" PRIu64 "hz, ibrd: %" PRIu32 ", fbrd:
%" PRIu32 ")"
# cmsdk-apb-uart.c
--
2.41.0
- [PATCH v5 09/16] tests/qtest: Update tests using PL011 UART, (continued)
- [PATCH v5 09/16] tests/qtest: Update tests using PL011 UART, Philippe Mathieu-Daudé, 2024/07/19
- [PATCH v5 10/16] hw/char/pl011: Check if receiver is enabled, Philippe Mathieu-Daudé, 2024/07/19
- [PATCH v5 13/16] hw/char/pl011: Introduce pl011_xmit() as GSource, Philippe Mathieu-Daudé, 2024/07/19
- [PATCH v5 11/16] hw/char/pl011: Rename RX FIFO methods, Philippe Mathieu-Daudé, 2024/07/19
- [RFC PATCH v5 16/16] hw/char/pl011: Implement TX FIFO, Philippe Mathieu-Daudé, 2024/07/19
- [PATCH v5 12/16] hw/char/pl011: Add transmit FIFO to PL011State, Philippe Mathieu-Daudé, 2024/07/19
- [PATCH v5 15/16] hw/char/pl011: Drain TX FIFO when no backend connected,
Philippe Mathieu-Daudé <=
- [PATCH v5 14/16] hw/char/pl011: Consider TX FIFO overrun error, Philippe Mathieu-Daudé, 2024/07/19