linux/drivers/tty/serial/8250
Ilpo Järvinen a7b9ce39fb serial: 8250_dw: Ensure BUSY is deasserted
DW UART cannot write to LCR, DLL, and DLH while BUSY is asserted.
Existance of BUSY depends on uart_16550_compatible, if UART HW is
configured with it those registers can always be written.

There currently is dw8250_force_idle() which attempts to achieve
non-BUSY state by disabling FIFO, however, the solution is unreliable
when Rx keeps getting more and more characters.

Create a sequence of operations that ensures UART cannot keep BUSY
asserted indefinitely. The new sequence relies on enabling loopback mode
temporarily to prevent incoming Rx characters keeping UART BUSY.

Ensure no Tx in ongoing while the UART is switches into the loopback
mode (requires exporting serial8250_fifo_wait_for_lsr_thre() and adding
DMA Tx pause/resume functions).

According to tests performed by Adriana Nicolae <adriana@arista.com>,
simply disabling FIFO or clearing FIFOs only once does not always
ensure BUSY is deasserted but up to two tries may be needed. This could
be related to ongoing Rx of a character (a guess, not known for sure).
Therefore, retry FIFO clearing a few times (retry limit 4 is arbitrary
number but using, e.g., p->fifosize seems overly large). Tests
performed by others did not exhibit similar challenge but it does not
seem harmful to leave the FIFO clearing loop in place for all DW UARTs
with BUSY functionality.

Use the new dw8250_idle_enter/exit() to do divisor writes and LCR
writes. In case of plain LCR writes, opportunistically try to update
LCR first and only invoke dw8250_idle_enter() if the write did not
succeed (it has been observed that in practice most LCR writes do
succeed without complications).

This issue was first reported by qianfan Zhao who put lots of debugging
effort into understanding the solution space.

Fixes: c49436b657 ("serial: 8250_dw: Improve unwritable LCR workaround")
Fixes: 7d4008ebb1 ("tty: add a DesignWare 8250 driver")
Cc: stable <stable@kernel.org>
Reported-by: qianfan Zhao <qianfanguijin@163.com>
Link: https://lore.kernel.org/linux-serial/289bb78a-7509-1c5c-2923-a04ed3b6487d@163.com/
Reported-by: Adriana Nicolae <adriana@arista.com>
Link: https://lore.kernel.org/linux-serial/20250819182322.3451959-1-adriana@arista.com/
Reported-by: Bandal, Shankar <shankar.bandal@intel.com>
Tested-by: Bandal, Shankar <shankar.bandal@intel.com>
Tested-by: Murthy, Shanth <shanth.murthy@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://patch.msgid.link/20260203171049.4353-8-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-03-12 15:34:29 +01:00
..
8250.h serial: 8250_dw: Ensure BUSY is deasserted 2026-03-12 15:34:29 +01:00
8250_accent.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_acorn.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
8250_aspeed_vuart.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
8250_bcm2835aux.c serial: 8250: Provide flag for IER toggling for RS485 2025-01-10 16:08:25 +01:00
8250_bcm7271.c serial: 8250: Switch to use hrtimer_setup() 2025-02-20 15:38:28 +01:00
8250_boca.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_ce4100.c serial: 8520_ce4100: Reuse mem_serial_in() in ce4100_mem_serial_in() 2025-07-09 13:44:50 +02:00
8250_core.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
8250_dfl.c tty: serial: 8250: add DFL bus driver for Altera 16550. 2023-01-19 16:07:40 +01:00
8250_dma.c serial: 8250: Fix TX deadlock when using DMA 2026-03-12 15:29:59 +01:00
8250_dw.c serial: 8250_dw: Ensure BUSY is deasserted 2026-03-12 15:34:29 +01:00
8250_dwlib.c serial: remove quot_frac from serial8250_do_set_divisor() 2024-08-07 13:13:35 +02:00
8250_dwlib.h serial: 8250_dw: Revert "Move definitions to the shared header" 2024-06-04 14:07:58 +02:00
8250_early.c serial: switch uart_port::iotype to enum uart_iotype 2025-04-25 13:46:31 +02:00
8250_em.c serial: 8250: sanitize uart_port::serial_{in,out}() types 2025-06-17 13:42:34 +02:00
8250_exar.c Merge 6.18-rc3 into tty-next 2025-10-27 08:17:40 +01:00
8250_exar_st16c554.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_fintek.c serial: 8250_fintek: Add support for F81216E 2024-11-12 13:05:38 +01:00
8250_fourport.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_fsl.c serial: 8250: use serial_port_in/out() helpers 2025-03-20 08:00:52 -07:00
8250_hp300.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
8250_hub6.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_ingenic.c serial: 8250: sanitize uart_port::serial_{in,out}() types 2025-06-17 13:42:34 +02:00
8250_ioc3.c DT updates for ralink, mobileye and ralink 2025-07-31 11:08:55 -07:00
8250_keba.c serial: 8250_keba: Use dev_err_probe() 2025-12-17 15:06:32 +01:00
8250_loongson.c serial: 8250: longson: Fix NULL vs IS_ERR() bug in probe 2025-12-17 15:11:00 +01:00
8250_lpc18xx.c serial: 8250: sanitize uart_port::serial_{in,out}() types 2025-06-17 13:42:34 +02:00
8250_lpss.c serial: 8250_lpss: copy dma_param using devm_kmemdup() 2024-01-04 16:21:51 +01:00
8250_men_mcb.c 8250_men_mcb: drop unneeded MODULE_ALIAS 2026-01-16 14:25:05 +01:00
8250_mid.c serial: 8250_mid: Remove 8250_pci usage 2023-09-18 11:14:43 +02:00
8250_mtk.c serial: 8250_mtk: Enable baud clock and manage in runtime PM 2025-10-22 12:13:54 +02:00
8250_ni.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
8250_of.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
8250_omap.c serial: 8250_omap: Remove custom deprecated baud setting routine 2026-01-23 17:24:54 +01:00
8250_parisc.c tty: add missing MODULE_DESCRIPTION() macros 2024-06-24 16:10:11 +02:00
8250_pci.c serial: 8250_pci: add support for the AX99100 2026-03-12 15:31:51 +01:00
8250_pci1xxxx.c serial: 8250_pcilib: Replace deprecated PCI functions 2025-10-22 12:06:53 +02:00
8250_pcilib.c serial: 8250_pcilib: Replace deprecated PCI functions 2025-10-22 12:06:53 +02:00
8250_pcilib.h serial: 8250_pcilib: Replace deprecated PCI functions 2025-10-22 12:06:53 +02:00
8250_pericom.c serial: 8250_pericom: Use UART_LCR_DLAB 2022-06-27 14:33:15 +02:00
8250_platform.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
8250_pnp.c serial: 8250_pnp: Remove unneeded ->iotype assignment 2025-02-04 14:44:53 +01:00
8250_port.c serial: 8250_dw: Ensure BUSY is deasserted 2026-03-12 15:34:29 +01:00
8250_pxa.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
8250_rsa.c TTY/Serial changes for 6.19-rc1 2025-12-06 18:38:19 -08:00
8250_rt288x.c serial: 8250: sanitize uart_port::serial_{in,out}() types 2025-06-17 13:42:34 +02:00
8250_tegra.c serial: Switch back to struct platform_driver::remove() 2024-10-11 08:13:28 +02:00
8250_uniphier.c serial: 8250: sanitize uart_port::serial_{in,out}() types 2025-06-17 13:42:34 +02:00
Kconfig serial: 8250: fix ordering of entries for menu display 2026-01-16 14:25:16 +01:00
Makefile TTY/Serial changes for 6.19-rc1 2025-12-06 18:38:19 -08:00
serial_cs.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00