android_kernel_oneplus_msm8998/drivers/tty/serial
Geert Uytterhoeven f833783b26 serial: sh-sci: Fix TX DMA buffer flushing and workqueue races
[ Upstream commit 8493eab02608b0e82f67b892aa72882e510c31d0 ]

When uart_flush_buffer() is called, the .flush_buffer() callback zeroes
the tx_dma_len field.  This may race with the work queue function
handling transmit DMA requests:

  1. If the buffer is flushed before the first DMA API call,
     dmaengine_prep_slave_single() may be called with a zero length,
     causing the DMA request to never complete, leading to messages
     like:

        rcar-dmac e7300000.dma-controller: Channel Address Error happen

     and, with debug enabled:

	sh-sci e6e88000.serial: sci_dma_tx_work_fn: ffff800639b55000: 0...0, cookie 126

     and DMA timeouts.

  2. If the buffer is flushed after the first DMA API call, but before
     the second, dma_sync_single_for_device() may be called with a zero
     length, causing the transmit data not to be flushed to RAM, and
     leading to stale data being output.

Fix this by:
  1. Letting sci_dma_tx_work_fn() return immediately if the transmit
     buffer is empty,
  2. Extending the critical section to cover all DMA preparational work,
     so tx_dma_len stays consistent for all of it,
  3. Using local copies of circ_buf.head and circ_buf.tail, to make sure
     they match the actual operation above.

Reported-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Suggested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Tested-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Link: https://lore.kernel.org/r/20190624123540.20629-2-geert+renesas@glider.be
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-08-04 09:34:58 +02:00
..
8250 dmaengine: idma64: Use actual device for DMA transfers 2019-06-22 08:18:21 +02:00
cpm_uart tty: serial: cpm_uart - fix init when SMC is relocated 2019-08-04 09:34:56 +02:00
jsm
21285.c
68328serial.c tty: Remove tty_port::close_wait 2015-10-17 21:11:29 -07:00
altera_jtaguart.c
altera_uart.c serial: altera_uart: Use of_property_read_u32 instead of open-coding it 2015-10-04 17:47:49 +01:00
amba-pl010.c
amba-pl011.c serial: amba-pl011: fix incorrect integer size in pl011_fifo_to_tty() 2015-10-17 21:29:21 -07:00
apbuart.c tty: serial: apbuart: Fix module autoload for OF platform driver 2015-10-04 19:09:21 +01:00
apbuart.h
ar933x_uart.c
arc_uart.c serial: arc_uart: Fix out-of-bounds access through DT alias 2018-05-30 07:49:15 +02:00
atmel_serial.c tty/serial: atmel: RS485 HD w/DMA: enable RX after TX is stopped 2019-04-27 09:33:47 +02:00
bcm63xx_uart.c bcm63xx_uart: Use the device name when registering an interrupt 2015-11-20 16:19:54 -08:00
bfin_sport_uart.c
bfin_sport_uart.h
bfin_uart.c
clps711x.c serial: mctrl-gpio: rename init function 2015-10-04 18:46:43 +01:00
crisv10.c tty: Remove tty_port::close_wait 2015-10-17 21:11:29 -07:00
crisv10.h
digicolor-usart.c tty/serial: digicolor: Fix digicolor-usart already registered warning 2019-08-04 09:34:56 +02:00
dz.c
dz.h
earlycon-arm-semihost.c
earlycon.c serial: earlycon: Add missing spinlock initialization 2015-12-12 23:05:28 -08:00
efm32-uart.c serial: efm32: Fix parity management in 'efm32_uart_console_get_options()' 2017-06-26 07:13:09 +02:00
etraxfs-uart.c serial: etraxfs-uart: Fix crash 2015-11-20 16:19:54 -08:00
fsl_lpuart.c serial: fsl_lpuart: fix maximum acceptable baud rate with over-sampling 2019-03-23 08:44:19 +01:00
icom.c
icom.h
ifx6x60.c serial: ifx6x60: fix use-after-free on module unload 2017-06-14 13:16:20 +02:00
ifx6x60.h
imx.c serial: imx: restore handshaking irq for imx1 2018-10-10 08:52:08 +02:00
ioc3_serial.c
ioc4_serial.c
ip22zilog.c
ip22zilog.h
Kconfig serial: fsl_lpuart: Fix earlycon support 2015-11-20 16:19:54 -08:00
kgdb_nmi.c
kgdboc.c Disable kgdboc failed by echo space to /sys/module/kgdboc/parameters/kgdboc 2019-04-03 06:23:28 +02:00
lantiq.c
lpc32xx_hs.c tty: serial: lpc32xx_hs: fix handling platform_get_irq result 2015-10-04 19:09:21 +01:00
m32r_sio.c
m32r_sio.h
m32r_sio_reg.h
Makefile
max310x.c tty: max310x: Fix invalid baudrate divisors calculator 2019-08-04 09:34:56 +02:00
max3100.c spi: Drop owner assignment from spi_drivers 2015-10-28 10:30:17 +09:00
mcf.c
men_z135_uart.c tty: serial: men_z135_uart.c: use mcb memory region size instead of hardcoded one 2015-10-17 21:05:43 -07:00
meson_uart.c
mpc52xx_uart.c
mpsc.c tty: disable unbind for old 74xx based serial/mpsc console port 2015-10-17 21:18:30 -07:00
msm_serial.c tty: serial: msm_serial: avoid system lockup condition 2019-08-04 09:34:56 +02:00
msm_serial.h tty: serial: msm: Add RX DMA support 2015-10-04 19:15:17 +01:00
mux.c parisc: serial/mux: Convert to uart_console_device instead of open-coded 2015-10-22 15:44:28 +02:00
mxs-auart.c serial: mxs-auart: Fix out-of-bounds access through serial port index 2018-05-30 07:49:15 +02:00
netx-serial.c
nwpserial.c
of_serial.c serial: Enable Freescale 16550 workaround on arm 2015-10-17 21:05:46 -07:00
omap-serial.c serial: omap: Fix EFR write on RTS deassertion 2017-11-24 08:32:24 +01:00
pch_uart.c
pmac_zilog.c
pmac_zilog.h
pnx8xxx_uart.c
pxa.c
rp2.c
sa1100.c
samsung.c tty: serial: samsung: Properly set flags in autoCTS mode 2019-02-20 10:13:10 +01:00
samsung.h
sb1250-duart.c
sc16is7xx.c sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init() 2019-05-16 19:44:57 +02:00
sccnxp.c Fix serial console on SNI RM400 machines 2018-04-13 19:50:17 +02:00
serial-tegra.c serial: tegra: Add helper function for handling RX buffer 2015-10-17 21:07:57 -07:00
serial_core.c tty: Remove tty_port::close_wait 2015-10-17 21:11:29 -07:00
serial_ks8695.c
serial_mctrl_gpio.c serial: mctrl_gpio: Add missing module license 2018-05-02 07:53:43 -07:00
serial_mctrl_gpio.h serial: fix mctrl helper functions 2015-10-17 21:21:07 -07:00
serial_txx9.c
sh-sci.c serial: sh-sci: Fix TX DMA buffer flushing and workqueue races 2019-08-04 09:34:58 +02:00
sh-sci.h
sirfsoc_uart.c
sirfsoc_uart.h
sn_console.c
sprd_serial.c serial: sprd: clear timeout interrupt only rather than all interrupts 2019-04-03 06:23:19 +02:00
st-asc.c tty/serial: st-asc: drop the use of IRQF_NO_SUSPEND 2015-10-04 19:11:05 +01:00
stm32-usart.c tty/serial: st-asc: drop the use of IRQF_NO_SUSPEND 2015-10-04 19:11:05 +01:00
suncore.c drivers/tty: add missing of_node_put() 2018-12-21 14:09:52 +01:00
sunhv.c sunhv: Fix device naming inconsistency between sunhv_console and sunhv_reg 2019-06-22 08:18:25 +02:00
sunsab.c
sunsab.h
sunsu.c
sunzilog.c
sunzilog.h
tilegx.c
timbuart.c
timbuart.h
uartlite.c
ucc_uart.c QE-UART: add "fsl,t1040-ucc-uart" to of_device_id 2016-06-07 18:14:35 -07:00
vr41xx_siu.c
vt8500_serial.c
xilinx_uartps.c serial: uartps: console_setup() can't be placed to init section 2019-04-27 09:33:58 +02:00
zs.c
zs.h