android_kernel_sony_sdm845/drivers/tty
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Geert Uytterhoeven 7e55003b57 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:33:40 +02:00
..
hvc hvc_opal: don't set tb_ticks_per_usec in udbg_init_opal_common() 2018-08-03 07:55:14 +02:00
ipwireless tty: ipwireless: fix missing checks for ioremap 2019-05-31 06:48:30 -07:00
serial serial: sh-sci: Fix TX DMA buffer flushing and workqueue races 2019-08-04 09:33:40 +02:00
vt tty/vt: fix write/write race in ioctl(KDSKBSENT) handler 2019-05-21 18:48:59 +02:00
amiserial.c
bfin_jtag_comm.c
cyclades.c
ehv_bytechan.c
goldfish.c tty: goldfish: Fix a parameter of a call to free_irq 2017-10-08 10:26:05 +02:00
isicom.c
Kconfig tty: ldisc: add sysctl to prevent autoloading of ldiscs 2019-04-17 08:36:44 +02:00
Makefile
metag_da.c
mips_ejtag_fdc.c
moxa.c
moxa.h
mxser.c
mxser.h
n_gsm.c tty: n_gsm: Fix DLCI handling for ADM mode if debug & 2 is not set 2018-05-01 15:13:06 -07:00
n_hdlc.c tty/n_hdlc: fix __might_sleep warning 2019-01-31 08:12:35 +01:00
n_r3964.c
n_tracerouter.c
n_tracesink.c
n_tracesink.h
n_tty.c tty: wipe buffer if not echoing data 2018-12-01 09:44:25 +01:00
nozomi.c
pty.c tty: Fix data race in tty_insert_flip_string_fixed_flag 2018-08-03 07:55:22 +02:00
rocket.c tty: rocket: fix incorrect forward declaration of 'rp_init()' 2019-07-10 09:55:46 +02:00
rocket.h
rocket_int.h
synclink.c
synclink_gt.c
synclinkmp.c
sysrq.c sysrq : fix Show Regs call trace on ARM 2017-12-09 22:01:49 +01:00
tty_audit.c
tty_buffer.c tty: increase the default flip buffer limit to 2*640K 2019-04-05 22:29:13 +02:00
tty_io.c tty: ldisc: add sysctl to prevent autoloading of ldiscs 2019-04-17 08:36:44 +02:00
tty_ioctl.c termios, tty/tty_baudrate.c: fix buffer overrun 2018-11-21 09:26:00 +01:00
tty_ldisc.c tty: ldisc: add sysctl to prevent autoloading of ldiscs 2019-04-17 08:36:44 +02:00
tty_ldsem.c tty/ldsem: Wake up readers after timed out down_write() 2019-01-23 08:10:52 +01:00
tty_mutex.c
tty_port.c tty: do not set TTY_IO_ERROR flag if console port 2018-12-13 09:20:30 +01:00