We've been using a base baud of 399193 to create the UART devices
while, at the same time, reporting a clock frequency that represents
a 230400 baud rate.
This pattern dates back to the initial RISC-V port and so far seems to
be doing okay. Linux thinks that we have a 230400 baud serials and
nothing seems of. Or better yet: no one has complained about a
potential bug in the UART devices since 2018.
All this said, set the UARTs baud rate in serial_mm_init() to match
what Linux has been seeing all this time.
Fixes: 04331d0b56a0 ("RISC-V VirtIO Machine")
Signed-off-by: Daniel Henrique Barboza <[email protected]>
---
hw/riscv/virt.c | 10 ++++++----
include/hw/riscv/virt.h | 2 ++
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index c4447d971b..03c17ce7d8 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -908,13 +908,15 @@ static void virt_machine_init(MachineState *machine)
VIRT_PLATFORM_BUS_NUM_IRQS);
serial_mm_init(system_memory, s->memmap[VIRT_UART0].base,
- 0, qdev_get_gpio_in(mmio_irqchip, UART0_IRQ), 399193,
- serial_hd(0), DEVICE_LITTLE_ENDIAN);
+ 0, qdev_get_gpio_in(mmio_irqchip, UART0_IRQ),
+ RISCV_VIRT_UART_BASE_BAUD,
+ serial_hd(0), DEVICE_LITTLE_ENDIAN);
if (serial_hd(1)) {
serial_mm_init(system_memory, s->memmap[VIRT_UART1].base,
- 0, qdev_get_gpio_in(mmio_irqchip, UART1_IRQ), 399193,
- serial_hd(1), DEVICE_LITTLE_ENDIAN);
+ 0, qdev_get_gpio_in(mmio_irqchip, UART1_IRQ),
+ RISCV_VIRT_UART_BASE_BAUD,
+ serial_hd(1), DEVICE_LITTLE_ENDIAN);
s->uart1_present = true;
}
diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h
index e516898f9a..f66d2f3342 100644
--- a/include/hw/riscv/virt.h
+++ b/include/hw/riscv/virt.h
@@ -121,6 +121,8 @@ enum {
#define VIRT_PLIC_SIZE(__num_context) \
(VIRT_PLIC_CONTEXT_BASE + (__num_context) * VIRT_PLIC_CONTEXT_STRIDE)
+#define RISCV_VIRT_UART_BASE_BAUD 230400
+
bool virt_is_acpi_enabled(RISCVVirtState *s);
bool virt_is_iommu_sys_enabled(RISCVVirtState *s);
void virt_acpi_setup(RISCVVirtState *vms);
--
2.43.0