qemu/hw/char
Philippe Mathieu-Daudé 543671d990 hw/char/sh_serial: Return correct number of empty RX FIFO elements
In the IOCanReadHandler sh_serial_can_receive(), if the Serial
Control Register 'Receive Enable' bit is set (bit 4), then we
return a size of (1 << 4) which happens to be equal to 16, so
effectively SH_RX_FIFO_LENGTH.

The IOReadHandler, sh_serial_receive1() takes care to receive
multiple chars, but if the FIFO is partly filled, we only process
the number of free slots in the FIFO, discarding the other chars!

Fix by returning how many elements the FIFO can queue in the
IOCanReadHandler, so we don't have to process more than that in
the IOReadHandler, thus not discarding anything.

Remove the now unnecessary check on 's->rx_cnt < SH_RX_FIFO_LENGTH'
in IOReadHandler, reducing the block indentation.

Fixes: 63242a007a ("SH4: Serial controller improvement")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Luc Michel <luc.michel@amd.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20250220092903.3726-10-philmd@linaro.org>
2025-03-04 14:45:34 +01:00
..
avr_usart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
bcm2835_aux.c hw/char/bcm2835_aux: Really use RX FIFO depth 2025-03-04 14:45:34 +01:00
cadence_uart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
cmsdk-apb-uart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
debugcon.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
digic-uart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
diva-gsp.c hw/char: Add emulation of Diva GSP PCI management boards 2025-02-04 22:57:34 +01:00
escc.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
exynos4210_uart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
goldfish_tty.c Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
grlib_apbuart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
ibex_uart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
imx_serial.c hw/char/imx_serial: Really use RX FIFO depth 2025-03-04 14:45:34 +01:00
ipoctal232.c hw/ipack: Remove legacy qemu_allocate_irqs() use 2025-01-31 19:36:44 +01:00
Kconfig hw/char: Add emulation of Diva GSP PCI management boards 2025-02-04 22:57:34 +01:00
mcf_uart.c hw/char/mcf_uart: Really use RX FIFO depth 2025-03-04 14:45:34 +01:00
mchp_pfsoc_mmuart.c hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
meson.build hw/char: Add emulation of Diva GSP PCI management boards 2025-02-04 22:57:34 +01:00
nrf51_uart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
omap_uart.c * pc: Add a description for the i8042 property 2024-10-04 19:28:37 +01:00
parallel-isa.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
parallel.c Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
pl011.c hw/char/pl011: Really use RX FIFO depth 2025-03-04 14:45:34 +01:00
renesas_sci.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
riscv_htif.c hw/char/riscv_htif: Convert HTIF_DEBUG() to trace events 2025-01-19 09:44:35 +10:00
sclpconsole-lm.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
sclpconsole.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
serial-isa.c Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
serial-mm.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
serial-pci-multi.c hw/char/pci-multi: Convert legacy qemu_allocate_irqs to qemu_init_irq 2025-01-31 19:36:44 +01:00
serial-pci.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
serial.c Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
sh_serial.c hw/char/sh_serial: Return correct number of empty RX FIFO elements 2025-03-04 14:45:34 +01:00
shakti_uart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
sifive_uart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
spapr_vty.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
stm32f2xx_usart.c hw/char/stm32f2xx_usart: replace print with trace 2025-01-13 17:16:04 +01:00
stm32l4x5_usart.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
terminal3270.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
trace-events hw/char/pl011: Improve RX flow tracing events 2025-03-04 14:45:34 +01:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
virtio-console.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
virtio-serial-bus.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
xen_console.c hw/xen: Fix errp handling in xen_console 2025-01-15 17:09:11 +00:00
xilinx_uartlite.c hw/char/xilinx_uartlite: Make device endianness configurable 2025-02-16 14:34:51 +01:00