diff options
author | Bin Meng <bmeng.cn@gmail.com> | 2021-09-13 16:07:21 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2021-09-13 16:07:21 +0100 |
commit | 62a3f63182a7cda98bdc168ed841507befca014f (patch) | |
tree | 7d697f49b5eb1a33dd397c1f317da8eb33bd4622 | |
parent | a89b91addf2b28613a89b842f501c903a819de68 (diff) | |
download | qemu-62a3f63182a7cda98bdc168ed841507befca014f.zip qemu-62a3f63182a7cda98bdc168ed841507befca014f.tar.gz qemu-62a3f63182a7cda98bdc168ed841507befca014f.tar.bz2 |
hw/char: cadence_uart: Disable transmit when input clock is disabled
At present when input clock is disabled, any character transmitted
to tx fifo can still show on the serial line, which is wrong.
Fixes: b636db306e06 ("hw/char/cadence_uart: add clock support")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Message-id: 20210901124521.30599-3-bmeng.cn@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | hw/char/cadence_uart.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index b4b5e8a..154be34 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -327,6 +327,11 @@ static gboolean cadence_uart_xmit(void *do_not_use, GIOCondition cond, static void uart_write_tx_fifo(CadenceUARTState *s, const uint8_t *buf, int size) { + /* ignore characters when unclocked or in reset */ + if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { + return; + } + if ((s->r[R_CR] & UART_CR_TX_DIS) || !(s->r[R_CR] & UART_CR_TX_EN)) { return; } |