[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 14/16] hw/char/pl011: Consider TX FIFO overrun error
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v5 14/16] hw/char/pl011: Consider TX FIFO overrun error |
Date: |
Fri, 19 Jul 2024 20:10:39 +0200 |
When transmission is disabled, characters are still queued
to the FIFO which eventually overruns. Report that error
condition in the status register.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/char/pl011.c | 17 +++++++++++++++++
hw/char/trace-events | 1 +
2 files changed, 18 insertions(+)
diff --git a/hw/char/pl011.c b/hw/char/pl011.c
index 6394d6eb36..b8cde03f98 100644
--- a/hw/char/pl011.c
+++ b/hw/char/pl011.c
@@ -61,6 +61,9 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev
*chr)
/* Data Register, UARTDR */
#define DR_BE (1 << 10)
+/* Receive Status Register/Error Clear Register, UARTRSR/UARTECR */
+#define RSR_OE (1 << 3)
+
/* Interrupt status bits in UARTRIS, UARTMIS, UARTIMSC */
#define INT_OE (1 << 10)
#define INT_BE (1 << 9)
@@ -232,6 +235,13 @@ static gboolean pl011_xmit(void *do_not_use, GIOCondition
cond, void *opaque)
int bytes_consumed;
uint8_t data;
+ if (!(s->cr & CR_UARTEN)) {
+ qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled
UART\n");
+ }
+ if (!(s->cr & CR_TXE)) {
+ qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled TX
UART\n");
+ }
+
data = fifo8_pop(&s->xmit_fifo);
bytes_consumed = 1;
@@ -257,6 +267,13 @@ static void pl011_write_txdata(PL011State *s, uint8_t data)
qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled TX
UART\n");
}
+ if (fifo8_is_full(&s->xmit_fifo)) {
+ /* The FIFO is already full. Content remains valid. */
+ trace_pl011_fifo_tx_overrun();
+ s->rsr |= RSR_OE;
+ return;
+ }
+
trace_pl011_fifo_tx_put(data);
pl011_loopback_tx(s, data);
fifo8_push(&s->xmit_fifo, data);
diff --git a/hw/char/trace-events b/hw/char/trace-events
index 30d06a2383..4a9c0bd271 100644
--- a/hw/char/trace-events
+++ b/hw/char/trace-events
@@ -62,6 +62,7 @@ pl011_fifo_rx_put(uint32_t c, int read_count) "new char
0x%02x read_count now %d
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_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
- Re: [PATCH v5 09/16] tests/qtest: Update tests using PL011 UART, (continued)
- [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é, 2024/07/19
- [PATCH v5 14/16] hw/char/pl011: Consider TX FIFO overrun error,
Philippe Mathieu-Daudé <=