2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00
linux/drivers/tty/serial
John Keeping 9e512eaaf8 serial: 8250: Fix fifo underflow on flush
When flushing the serial port's buffer, uart_flush_buffer() calls
kfifo_reset() but if there is an outstanding DMA transfer then the
completion function will consume data from the kfifo via
uart_xmit_advance(), underflowing and leading to ongoing DMA as the
driver tries to transmit another 2^32 bytes.

This is readily reproduced with serial-generic and amidi sending even
short messages as closing the device on exit will wait for the fifo to
drain and in the underflow case amidi hangs for 30 seconds on exit in
tty_wait_until_sent().  A trace of that gives:

     kworker/1:1-84    [001]    51.769423: bprint:               serial8250_tx_dma: tx_size=3 fifo_len=3
           amidi-763   [001]    51.769460: bprint:               uart_flush_buffer: resetting fifo
 irq/21-fe530000-76    [000]    51.769474: bprint:               __dma_tx_complete: tx_size=3
 irq/21-fe530000-76    [000]    51.769479: bprint:               serial8250_tx_dma: tx_size=4096 fifo_len=4294967293
 irq/21-fe530000-76    [000]    51.781295: bprint:               __dma_tx_complete: tx_size=4096
 irq/21-fe530000-76    [000]    51.781301: bprint:               serial8250_tx_dma: tx_size=4096 fifo_len=4294963197
 irq/21-fe530000-76    [000]    51.793131: bprint:               __dma_tx_complete: tx_size=4096
 irq/21-fe530000-76    [000]    51.793135: bprint:               serial8250_tx_dma: tx_size=4096 fifo_len=4294959101
 irq/21-fe530000-76    [000]    51.804949: bprint:               __dma_tx_complete: tx_size=4096

Since the port lock is held in when the kfifo is reset in
uart_flush_buffer() and in __dma_tx_complete(), adding a flush_buffer
hook to adjust the outstanding DMA byte count is sufficient to avoid the
kfifo underflow.

Fixes: 9ee4b83e51 ("serial: 8250: Add support for dmaengine")
Cc: stable <stable@kernel.org>
Signed-off-by: John Keeping <jkeeping@inmusicbrands.com>
Link: https://lore.kernel.org/r/20250208124148.1189191-1-jkeeping@inmusicbrands.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-02-14 09:50:55 +01:00
..
8250 serial: 8250: Fix fifo underflow on flush 2025-02-14 09:50:55 +01:00
jsm tty: serial: switch from circ_buf to kfifo 2024-04-09 15:28:03 +02:00
21285.c
altera_jtaguart.c serial: altera_jtaguart: Use KBUILD_MODNAME 2024-12-04 16:35:53 +01:00
altera_uart.c serial: altera_uart: Use KBUILD_MODNAME 2024-12-14 15:39:57 +01:00
amba-pl010.c serial: amba-pl010: Switch to irq_get_nr_irqs() 2024-10-16 21:56:58 +02:00
amba-pl011.c serial: amba-pl011: Fix RTS handling in RS485 mode 2024-12-23 19:04:16 +01:00
apbuart.c
apbuart.h
ar933x_uart.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
arc_uart.c tty: serial: switch from circ_buf to kfifo 2024-04-09 15:28:03 +02:00
atmel_serial.c tty: atmel_serial: Use of_property_present() for non-boolean properties 2025-01-10 16:07:50 +01:00
atmel_serial.h
bcm63xx_uart.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
clps711x.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
cpm_uart.c TTY / Serial driver updates for 6.13-rc1 2024-11-30 09:03:16 -08:00
cpm_uart.h
digicolor-usart.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
dz.c tty: serial: switch from circ_buf to kfifo 2024-04-09 15:28:03 +02:00
dz.h
earlycon-riscv-sbi.c
earlycon-semihost.c
earlycon.c init: Don't proxy console= to earlycon 2024-10-01 14:11:39 +02:00
esp32_acm.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
esp32_uart.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
fsl_linflexuart.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
fsl_lpuart.c tty: serial: fsl_lpuart: flush RX and TX FIFO when lpuart shutdown 2025-01-07 11:50:05 +01:00
icom.c tty: serial: switch from circ_buf to kfifo 2024-04-09 15:28:03 +02:00
imx_earlycon.c
imx.c serial: imx: Use uart_port_lock_irq() instead of uart_port_lock() 2024-12-23 19:01:40 +01:00
ip22zilog.c tty: serial: switch from circ_buf to kfifo 2024-04-09 15:28:03 +02:00
ip22zilog.h
Kconfig tty: serial: atmel: make it selectable for ARCH_LAN969X 2025-01-10 16:06:57 +01:00
kgdb_nmi.c serial: kgdb_nmi: Remove unused knock code 2025-01-17 12:52:27 +01:00
kgdboc.c serial: kgdboc: Fix NMI-safety problems from keyboard reset code 2024-04-26 17:14:10 +01:00
lantiq.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
liteuart.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
lpc32xx_hs.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
ma35d1_serial.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
Makefile serial: sc16is7xx: rename Kconfig CONFIG_SERIAL_SC16IS7XX_CORE 2024-06-04 14:10:28 +02:00
max310x.c tty: serial: max310x: convert to use maple tree register cache 2024-04-09 16:50:36 +02:00
max3100.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
mcf.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
men_z135_uart.c module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
meson_uart.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
milbeaut_usio.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
mpc52xx_uart.c serial: mpc52xx: Fix typo in mpc52xx_uart.c 2024-12-04 16:41:58 +01:00
mps2-uart.c
msm_serial.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
mux.c
mvebu-uart.c tty: serial: switch from circ_buf to kfifo 2024-04-09 15:28:03 +02:00
mxs-auart.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
omap-serial.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
owl-uart.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
pch_uart.c tty: serial: switch from circ_buf to kfifo 2024-04-09 15:28:03 +02:00
pic32_uart.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
pmac_zilog.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
pmac_zilog.h
pxa.c serial: pxa: Use uart_prepare_sysrq_char(). 2024-03-02 22:06:21 +01:00
qcom_geni_serial.c Merge 6.12-rc4 into tty-next 2024-10-21 08:51:39 +02:00
rda-uart.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
rp2.c serial: rp2: Replace deprecated PCI functions 2024-10-30 16:07:38 -05:00
sa1100.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
samsung_tty.c tty: serial: samsung: Add Exynos8895 compatible 2024-11-04 02:02:45 +01:00
sb1250-duart.c tty: serial: switch from circ_buf to kfifo 2024-04-09 15:28:03 +02:00
sc16is7xx_i2c.c module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
sc16is7xx_spi.c module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
sc16is7xx.c serial: sc16is7xx: Fix IRQ number check behavior 2025-02-04 14:42:42 +01:00
sc16is7xx.h serial: sc16is7xx: split into core and I2C/SPI parts (sc16is7xx_regcfg) 2024-04-11 14:08:08 +02:00
sccnxp.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
serial_base_bus.c Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
serial_base.h serial: core: Add serial_base_match_and_update_preferred_console() 2024-07-04 15:41:44 +02:00
serial_core.c Driver core and debugfs updates 2025-01-28 12:25:12 -08:00
serial_ctrl.c
serial_mctrl_gpio.c tty: add missing MODULE_DESCRIPTION() macros 2024-06-24 16:10:11 +02:00
serial_mctrl_gpio.h
serial_port.c serial: port: Make ->iotype validation global in __uart_read_properties() 2025-02-04 14:44:44 +01:00
serial_txx9.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
serial-tegra.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
sh-sci.c serial: sh-sci: Increment the runtime usage counter for the earlycon device 2025-01-17 12:54:37 +01:00
sh-sci.h
sifive.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
sprd_serial.c serial: sprd: Add support for sc9632 2024-11-13 15:14:17 +01:00
st-asc.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
stm32-usart.c serial: stm32: use port lock wrappers for break control 2024-12-23 19:01:54 +01:00
stm32-usart.h
suncore.c
sunhv.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
sunplus-uart.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
sunsab.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
sunsab.h
sunsu.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
sunzilog.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
sunzilog.h
tegra-tcu.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
timbuart.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
timbuart.h
uartlite.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
ucc_uart.c TTY / Serial driver updates for 6.13-rc1 2024-11-30 09:03:16 -08:00
vt8500_serial.c
xilinx_uartps.c tty: xilinx_uartps: split sysrq handling 2025-01-13 06:46:50 +01:00
zs.c tty: serial: switch from circ_buf to kfifo 2024-04-09 15:28:03 +02:00
zs.h