linux/drivers/tty/serial/8250
Marek Vasut f6aa5beb45 serial: 8250: Fix clearing FIFOs in RS485 mode again
The 8250 FIFOs indeed need to be cleared after stopping transmission in
RS485 mode without SER_RS485_RX_DURING_TX flag set. But there are two
problems with the approach taken by the previous patch from Fixes tag.

First, serial8250_clear_fifos() should clear fifos, but what it really
does is it enables the FIFOs unconditionally if present, clears them
and then sets the FCR register to zero, which effectively disables the
FIFOs. In case the FIFO is disabled, enabling it and clearing it makes
no sense and in fact can trigger misbehavior of the 8250 core. Moreover,
the FCR register may contain other FIFO configuration bits which may not
be writable unconditionally and writing them incorrectly can trigger
misbehavior of the 8250 core too. (ie. AM335x UART swallows the first
byte and retransmits the last byte twice because of this FCR write).

Second, serial8250_clear_and_reinit_fifos() completely reloads the FCR,
but what really has to happen at the end of the RS485 transmission is
clearing of the FIFOs and nothing else.

This patch repairs serial8250_clear_fifos() so that it really only
clears the FIFOs by operating on FCR[2:1] bits and leaves all the
other bits alone. It also undoes serial8250_clear_and_reinit_fifos()
from __do_stop_tx_rs485() as serial8250_clear_fifos() is sufficient.

Signed-off-by: Marek Vasut <marex@denx.de>
Fixes: 2bed8a8e70 ("Clearing FIFOs in RS485 emulation mode causes subsequent transmits to break")
Cc: Daniel Jedrychowski <avistel@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: stable <stable@vger.kernel.org> # let it bake a bit before merging
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-18 16:07:25 +02:00
..
8250_accent.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_acorn.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_aspeed_vuart.c serial/aspeed-vuart: fix a couple mod_timer() calls 2018-05-14 13:51:11 +02:00
8250_bcm2835aux.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_boca.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_core.c serial: 8250: drop the printk from serial8250_interrupt() 2018-09-18 16:07:23 +02:00
8250_dma.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_dw.c serial: 8250_dw: Add ACPI support for uart on Broadcom SoC 2018-08-02 10:11:32 +02:00
8250_early.c serial: 8250_early: Setup divider when uartclk is passed 2018-04-25 14:56:12 +02:00
8250_em.c headers: separate linux/mod_devicetable.h from linux/platform_device.h 2018-07-07 17:52:26 +02:00
8250_exar_st16c554.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_exar.c serial: 8250_exar: Read INT0 from slave device, too 2018-08-02 10:11:35 +02:00
8250_fintek.c serial: 8250_fintek: Fix crash with baud rate B0 2017-11-08 13:09:35 +01:00
8250_fourport.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_fsl.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_gsc.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_hp300.c tty: add SPDX identifiers to all remaining files in drivers/tty/ 2017-11-08 13:08:12 +01:00
8250_hub6.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_ingenic.c serial: 8250_ingenic: Parse earlycon options 2018-01-09 16:49:14 +01:00
8250_lpc18xx.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_lpss.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_men_mcb.c 8250-men-mcb: add support for 16z025 and 16z057 2018-03-15 18:12:55 +01:00
8250_mid.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_moxa.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_mtk.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_of.c serial: 8250_of: Fix for lack of interrupt support 2018-09-18 16:07:25 +02:00
8250_omap.c serial: 8250_omap: Add support for AM654 UART controller 2018-06-28 21:23:44 +09:00
8250_pci.c serial: 8250_pci: Remove stalled entries in blacklist 2018-06-28 21:34:39 +09:00
8250_pnp.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_port.c serial: 8250: Fix clearing FIFOs in RS485 mode again 2018-09-18 16:07:25 +02:00
8250_pxa.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_uniphier.c serial: 8250_uniphier: fix error return code in uniphier_uart_probe() 2018-01-09 16:45:17 +01:00
8250.h tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
Kconfig serial: 8250_omap: Make 8250_omap driver driver depend on ARCH_K3 2018-09-18 16:07:24 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
serial_cs.c drivers/tty: add error handling for pcmcia_loop_config 2018-06-28 21:23:44 +09:00