All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/26] tty: drop low-latency workarounds
@ 2021-04-21  9:54 Johan Hovold
  2021-04-21  9:54 ` [PATCH 01/26] tty: mxser: drop low-latency workaround Johan Hovold
                   ` (26 more replies)
  0 siblings, 27 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold

The infamous low_latency behaviour of tty_flip_buffer_push(), which
meant that data could be pushed to the line discipline immediately
instead of being deferred to a work queue, was finally removed in 2014.

Since then there's no need for drivers to keep hacks to temporarily drop
the port lock during receive processing but this pattern has been
reproduced in later added drivers nonetheless.

Note that several of these workarounds were added by a series posted in
2013, which ended up being merged despite having completely nonsensical
commit messages. As it turned out, it was just the RT patch set which
effectively enabled the low_latency flag for serial drivers that did not
handle it.

There's of course nothing wrong releasing the port lock before calling
tty_flip_buffer_push(), and some drivers still do after this series, but
let's get rid of the completely unnecessary unlock-and-reacquire
pattern.

Johan


Johan Hovold (26):
  tty: mxser: drop low-latency workaround
  serial: altera_jtaguart: drop low-latency workaround
  serial: altera_uart: drop low-latency workaround
  serial: amba-pl010: drop low-latency workaround
  serial: amba-pl011: drop low-latency workaround
  serial: apbuart: drop low-latency workaround
  serial: ar933x: drop low-latency workaround
  serial: arc_uart: drop low-latency workaround
  serial: atmel_serial: drop low-latency workaround
  serial: bcm63xx: drop low-latency workaround
  serial: icom: drop low-latency workaround
  serial: lpc32xx_hs: drop low-latency workaround
  serial: mcf: drop low-latency workaround
  serial: meson: drop low-latency workaround
  serial: mpc52xx_uart: drop low-latency workaround
  serial: msm_serial: drop low-latency workaround
  serial: owl: drop low-latency workaround
  serial: rda: drop low-latency workaround
  serial: rp2: drop low-latency workaround
  serial: sa1100: drop low-latency workaround
  serial: txx9: drop low-latency workaround
  serial: sifive: drop low-latency workaround
  serial: sunsu: drop low-latency workaround
  serial: timbuart: drop low-latency workaround
  serial: vt8500: drop low-latency workaround
  serial: xilinx_uartps: drop low-latency workaround

 drivers/tty/mxser.c                  |  7 -------
 drivers/tty/serial/altera_jtaguart.c |  2 --
 drivers/tty/serial/altera_uart.c     |  2 --
 drivers/tty/serial/amba-pl010.c      |  2 --
 drivers/tty/serial/amba-pl011.c      |  2 --
 drivers/tty/serial/apbuart.c         |  2 --
 drivers/tty/serial/ar933x_uart.c     |  2 --
 drivers/tty/serial/arc_uart.c        |  2 --
 drivers/tty/serial/atmel_serial.c    | 18 ------------------
 drivers/tty/serial/bcm63xx_uart.c    |  2 --
 drivers/tty/serial/icom.c            |  2 --
 drivers/tty/serial/lpc32xx_hs.c      |  2 --
 drivers/tty/serial/mcf.c             |  2 --
 drivers/tty/serial/meson_uart.c      |  2 --
 drivers/tty/serial/mpc52xx_uart.c    |  2 --
 drivers/tty/serial/msm_serial.c      |  4 ----
 drivers/tty/serial/owl-uart.c        |  2 --
 drivers/tty/serial/rda-uart.c        |  2 --
 drivers/tty/serial/rp2.c             |  2 --
 drivers/tty/serial/sa1100.c          |  2 --
 drivers/tty/serial/serial_txx9.c     |  4 ++--
 drivers/tty/serial/sifive.c          |  2 --
 drivers/tty/serial/sunsu.c           |  4 ----
 drivers/tty/serial/timbuart.c        |  2 --
 drivers/tty/serial/vt8500_serial.c   |  2 --
 drivers/tty/serial/xilinx_uartps.c   |  3 +--
 26 files changed, 3 insertions(+), 77 deletions(-)

-- 
2.26.3


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH 01/26] tty: mxser: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
@ 2021-04-21  9:54 ` Johan Hovold
  2021-04-22  5:59   ` Jiri Slaby
  2021-04-21  9:54 ` [PATCH 02/26] serial: altera_jtaguart: " Johan Hovold
                   ` (25 subsequent siblings)
  26 siblings, 1 reply; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold

Commit 67d2bc58afdd ("Char: mxser_new, fix recursive locking") worked
around the infamous low_latency behaviour of tty_flip_buffer_push() by
simply dropping and reacquiring the port lock in the interrupt handler.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks around.

Link: https://lore.kernel.org/lkml/3018694794025219@wsc.cz/T/#m06b04c640a7b6f41afb3d34a4cf29b1df4935d3a
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/mxser.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 2d8e76263a25..16a852ecbe8a 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -2155,14 +2155,7 @@ static void mxser_receive_chars(struct tty_struct *tty,
 	port->mon_data.rxcnt += cnt;
 	port->mon_data.up_rxcnt += cnt;
 
-	/*
-	 * We are called from an interrupt context with &port->slock
-	 * being held. Drop it temporarily in order to prevent
-	 * recursive locking.
-	 */
-	spin_unlock(&port->slock);
 	tty_flip_buffer_push(&port->port);
-	spin_lock(&port->slock);
 }
 
 static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port)
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 02/26] serial: altera_jtaguart: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
  2021-04-21  9:54 ` [PATCH 01/26] tty: mxser: drop low-latency workaround Johan Hovold
@ 2021-04-21  9:54 ` Johan Hovold
  2021-04-21 10:03   ` Tobias Klauser
  2021-04-21  9:54 ` [PATCH 03/26] serial: altera_uart: " Johan Hovold
                   ` (24 subsequent siblings)
  26 siblings, 1 reply; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold, Tobias Klauser

Commit 53dd0ba7a6f4 ("tty: serial: altera_jtag: drop uart_port->lock
before calling tty_flip_buffer_push()") claimed to address a locking
issue but only provided a dubious lockdep splat from an unrelated
driver, which in the end turned out to be due a broken local change
carried by the author.

Unfortunately these patches were merged before the issue had been
analysed properly so the commit messages makes no sense whatsoever.

The real issue was first seen on RT which at the time effectively always
set the low_latency flag for all serial drivers by patching
tty_flip_buffer_push(). This in turn revealed that many drivers did not
handle the infamous low_latency behaviour which meant that data was
pushed immediately to the line discipline instead of being deferred to a
work queue.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks
around.

Link: https://lore.kernel.org/linux-serial/cover.1376923198.git.viresh.kumar@linaro.org/
Cc: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/altera_jtaguart.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c
index d0ca9cf29b62..23c4e0e79694 100644
--- a/drivers/tty/serial/altera_jtaguart.c
+++ b/drivers/tty/serial/altera_jtaguart.c
@@ -131,9 +131,7 @@ static void altera_jtaguart_rx_chars(struct altera_jtaguart *pp)
 		uart_insert_char(port, 0, 0, ch, flag);
 	}
 
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(&port->state->port);
-	spin_lock(&port->lock);
 }
 
 static void altera_jtaguart_tx_chars(struct altera_jtaguart *pp)
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 03/26] serial: altera_uart: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
  2021-04-21  9:54 ` [PATCH 01/26] tty: mxser: drop low-latency workaround Johan Hovold
  2021-04-21  9:54 ` [PATCH 02/26] serial: altera_jtaguart: " Johan Hovold
@ 2021-04-21  9:54 ` Johan Hovold
  2021-04-21 10:03   ` Tobias Klauser
  2021-04-21  9:54 ` [PATCH 04/26] serial: amba-pl010: " Johan Hovold
                   ` (23 subsequent siblings)
  26 siblings, 1 reply; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold, Tobias Klauser

Commit dd085ed8ef6c ("tty: serial: altera: drop uart_port->lock before
calling tty_flip_buffer_push()") claimed to address a locking
issue but only provided a dubious lockdep splat from an unrelated
driver, which in the end turned out to be due a broken local change
carried by the author.

Unfortunately these patches were merged before the issue had been
analysed properly so the commit messages makes no sense whatsoever.

The real issue was first seen on RT which at the time effectively always
set the low_latency flag for all serial drivers by patching
tty_flip_buffer_push(). This in turn revealed that many drivers did not
handle the infamous low_latency behaviour which meant that data was
pushed immediately to the line discipline instead of being deferred to a
work queue.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks
around.

Link: https://lore.kernel.org/linux-serial/cover.1376923198.git.viresh.kumar@linaro.org/
Cc: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/altera_uart.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/altera_uart.c b/drivers/tty/serial/altera_uart.c
index 0e487ce091ac..7c5f4e966b59 100644
--- a/drivers/tty/serial/altera_uart.c
+++ b/drivers/tty/serial/altera_uart.c
@@ -243,9 +243,7 @@ static void altera_uart_rx_chars(struct altera_uart *pp)
 				 flag);
 	}
 
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(&port->state->port);
-	spin_lock(&port->lock);
 }
 
 static void altera_uart_tx_chars(struct altera_uart *pp)
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 04/26] serial: amba-pl010: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (2 preceding siblings ...)
  2021-04-21  9:54 ` [PATCH 03/26] serial: altera_uart: " Johan Hovold
@ 2021-04-21  9:54 ` Johan Hovold
  2021-04-21  9:54 ` [PATCH 05/26] serial: amba-pl011: " Johan Hovold
                   ` (22 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold, Russell King

Commit 2389b272168c ("[ARM] 4417/1: Serial: Fix AMBA drivers locking")
worked around the infamous low_latency behaviour of
tty_flip_buffer_push() by simply dropping and reacquiring the port lock
in the interrupt handler.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks around.

Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/amba-pl010.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c
index 3f96edfe569c..e744b953ca34 100644
--- a/drivers/tty/serial/amba-pl010.c
+++ b/drivers/tty/serial/amba-pl010.c
@@ -159,9 +159,7 @@ static void pl010_rx_chars(struct uart_amba_port *uap)
 	ignore_char:
 		status = readb(uap->port.membase + UART01x_FR);
 	}
-	spin_unlock(&uap->port.lock);
 	tty_flip_buffer_push(&uap->port.state->port);
-	spin_lock(&uap->port.lock);
 }
 
 static void pl010_tx_chars(struct uart_amba_port *uap)
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 05/26] serial: amba-pl011: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (3 preceding siblings ...)
  2021-04-21  9:54 ` [PATCH 04/26] serial: amba-pl010: " Johan Hovold
@ 2021-04-21  9:54 ` Johan Hovold
  2021-04-22  0:18   ` Linus Walleij
  2021-04-21  9:54 ` [PATCH 06/26] serial: apbuart: " Johan Hovold
                   ` (21 subsequent siblings)
  26 siblings, 1 reply; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold,
	Linus Walleij, Russell King

Commit ead76f329f77 ("ARM: 6763/1: pl011: add optional RX DMA to PL011
v2") added RX DMA support and also reproduced the workaround for the
infamous low_latency behaviour of tty_flip_buffer_push() by dropping and
reacquiring the port lock during receive processing.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks around.

Note that the port lock is also dropped in the PIO path
(see pl011_rx_chars), but it is not clear whether this is still needed
by the DMA code added by the aforementioned commit.

Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/amba-pl011.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 4ead0c9048a8..78682c12156a 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -937,12 +937,10 @@ static void pl011_dma_rx_chars(struct uart_amba_port *uap,
 		fifotaken = pl011_fifo_to_tty(uap);
 	}
 
-	spin_unlock(&uap->port.lock);
 	dev_vdbg(uap->port.dev,
 		 "Took %d chars from DMA buffer and %d chars from the FIFO\n",
 		 dma_count, fifotaken);
 	tty_flip_buffer_push(port);
-	spin_lock(&uap->port.lock);
 }
 
 static void pl011_dma_rx_irq(struct uart_amba_port *uap)
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 06/26] serial: apbuart: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (4 preceding siblings ...)
  2021-04-21  9:54 ` [PATCH 05/26] serial: amba-pl011: " Johan Hovold
@ 2021-04-21  9:54 ` Johan Hovold
  2021-04-21  9:54 ` [PATCH 07/26] serial: ar933x: " Johan Hovold
                   ` (20 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold

Commit 78d34d75c84d ("tty: serial: apbuart: drop uart_port->lock before
calling tty_flip_buffer_push()") claimed to address a locking
issue but only provided a dubious lockdep splat from an unrelated
driver, which in the end turned out to be due a broken local change
carried by the author.

Unfortunately these patches were merged before the issue had been
analysed properly so the commit messages makes no sense whatsoever.

The real issue was first seen on RT which at the time effectively always
set the low_latency flag for all serial drivers by patching
tty_flip_buffer_push(). This in turn revealed that many drivers did not
handle the infamous low_latency behaviour which meant that data was
pushed immediately to the line discipline instead of being deferred to a
work queue.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks
around.

Link: https://lore.kernel.org/linux-serial/cover.1376923198.git.viresh.kumar@linaro.org/
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/apbuart.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/apbuart.c b/drivers/tty/serial/apbuart.c
index e8d56e899ec7..d8c937bdf3f9 100644
--- a/drivers/tty/serial/apbuart.c
+++ b/drivers/tty/serial/apbuart.c
@@ -117,9 +117,7 @@ static void apbuart_rx_chars(struct uart_port *port)
 		status = UART_GET_STATUS(port);
 	}
 
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(&port->state->port);
-	spin_lock(&port->lock);
 }
 
 static void apbuart_tx_chars(struct uart_port *port)
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 07/26] serial: ar933x: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (5 preceding siblings ...)
  2021-04-21  9:54 ` [PATCH 06/26] serial: apbuart: " Johan Hovold
@ 2021-04-21  9:54 ` Johan Hovold
  2021-04-21  9:54 ` [PATCH 08/26] serial: arc_uart: " Johan Hovold
                   ` (19 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold

Commit b16c8e3eed12 ("tty: serial: ar933x: drop uart_port->lock before
calling tty_flip_buffer_push()") claimed to address a locking
issue but only provided a dubious lockdep splat from an unrelated
driver, which in the end turned out to be due a broken local change
carried by the author.

Unfortunately these patches were merged before the issue had been
analysed properly so the commit messages makes no sense whatsoever.

The real issue was first seen on RT which at the time effectively always
set the low_latency flag for all serial drivers by patching
tty_flip_buffer_push(). This in turn revealed that many drivers did not
handle the infamous low_latency behaviour which meant that data was
pushed immediately to the line discipline instead of being deferred to a
work queue.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks
around.

Link: https://lore.kernel.org/linux-serial/cover.1376923198.git.viresh.kumar@linaro.org/
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/ar933x_uart.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c
index c2be7cf91399..4379ca4842ae 100644
--- a/drivers/tty/serial/ar933x_uart.c
+++ b/drivers/tty/serial/ar933x_uart.c
@@ -385,9 +385,7 @@ static void ar933x_uart_rx_chars(struct ar933x_uart_port *up)
 			tty_insert_flip_char(port, ch, TTY_NORMAL);
 	} while (max_count-- > 0);
 
-	spin_unlock(&up->port.lock);
 	tty_flip_buffer_push(port);
-	spin_lock(&up->port.lock);
 }
 
 static void ar933x_uart_tx_chars(struct ar933x_uart_port *up)
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 08/26] serial: arc_uart: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (6 preceding siblings ...)
  2021-04-21  9:54 ` [PATCH 07/26] serial: ar933x: " Johan Hovold
@ 2021-04-21  9:54 ` Johan Hovold
  2021-04-21  9:54 ` [PATCH 09/26] serial: atmel_serial: " Johan Hovold
                   ` (18 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold, Vineet Gupta

Commit 3fa1200851c7 ("tty: serial: arc: drop uart_port->lock before
calling tty_flip_buffer_push()") claimed to address a locking
issue but only provided a dubious lockdep splat from an unrelated
driver, which in the end turned out to be due a broken local change
carried by the author.

Unfortunately these patches were merged before the issue had been
analysed properly so the commit messages makes no sense whatsoever.

The real issue was first seen on RT which at the time effectively always
set the low_latency flag for all serial drivers by patching
tty_flip_buffer_push(). This in turn revealed that many drivers did not
handle the infamous low_latency behaviour which meant that data was
pushed immediately to the line discipline instead of being deferred to a
work queue.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks
around.

Link: https://lore.kernel.org/linux-serial/cover.1376923198.git.viresh.kumar@linaro.org/
Cc: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/arc_uart.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
index 17c3fc398fc6..1a9444b6b57e 100644
--- a/drivers/tty/serial/arc_uart.c
+++ b/drivers/tty/serial/arc_uart.c
@@ -236,9 +236,7 @@ static void arc_serial_rx_chars(struct uart_port *port, unsigned int status)
 		if (!(uart_handle_sysrq_char(port, ch)))
 			uart_insert_char(port, status, RXOERR, ch, flg);
 
-		spin_unlock(&port->lock);
 		tty_flip_buffer_push(&port->state->port);
-		spin_lock(&port->lock);
 	} while (!((status = UART_GET_STATUS(port)) & RXEMPTY));
 }
 
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 09/26] serial: atmel_serial: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (7 preceding siblings ...)
  2021-04-21  9:54 ` [PATCH 08/26] serial: arc_uart: " Johan Hovold
@ 2021-04-21  9:54 ` Johan Hovold
  2021-04-21  9:54 ` [PATCH 10/26] serial: bcm63xx: " Johan Hovold
                   ` (17 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold, Richard Genoud

Commit 1ecc26bd2789 ("atmel_serial: split the interrupt handler") worked
around the infamous low_latency behaviour of tty_flip_buffer_push() by
dropping and reacquiring the port lock in the tasklet callback.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks around.

Cc: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/atmel_serial.c | 18 ------------------
 1 file changed, 18 deletions(-)

diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index a24e5c2b30bc..058886d9045b 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -1178,13 +1178,7 @@ static void atmel_rx_from_dma(struct uart_port *port)
 			       1,
 			       DMA_FROM_DEVICE);
 
-	/*
-	 * Drop the lock here since it might end up calling
-	 * uart_start(), which takes the lock.
-	 */
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(tport);
-	spin_lock(&port->lock);
 
 	atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_TIMEOUT);
 }
@@ -1576,13 +1570,7 @@ static void atmel_rx_from_ring(struct uart_port *port)
 		uart_insert_char(port, status, ATMEL_US_OVRE, c.ch, flg);
 	}
 
-	/*
-	 * Drop the lock here since it might end up calling
-	 * uart_start(), which takes the lock.
-	 */
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(&port->state->port);
-	spin_lock(&port->lock);
 }
 
 static void atmel_release_rx_pdc(struct uart_port *port)
@@ -1667,13 +1655,7 @@ static void atmel_rx_from_pdc(struct uart_port *port)
 		}
 	} while (head >= pdc->dma_size);
 
-	/*
-	 * Drop the lock here since it might end up calling
-	 * uart_start(), which takes the lock.
-	 */
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(tport);
-	spin_lock(&port->lock);
 
 	atmel_uart_writel(port, ATMEL_US_IER,
 			  ATMEL_US_ENDRX | ATMEL_US_TIMEOUT);
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 10/26] serial: bcm63xx: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (8 preceding siblings ...)
  2021-04-21  9:54 ` [PATCH 09/26] serial: atmel_serial: " Johan Hovold
@ 2021-04-21  9:54 ` Johan Hovold
  2021-04-21  9:54 ` [PATCH 11/26] serial: icom: " Johan Hovold
                   ` (16 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold

Commit b4d499241c34 ("tty: serial: bcm63xx: drop uart_port->lock before
calling tty_flip_buffer_push()") claimed to address a locking
issue but only provided a dubious lockdep splat from an unrelated
driver, which in the end turned out to be due a broken local change
carried by the author.

Unfortunately these patches were merged before the issue had been
analysed properly so the commit messages makes no sense whatsoever.

The real issue was first seen on RT which at the time effectively always
set the low_latency flag for all serial drivers by patching
tty_flip_buffer_push(). This in turn revealed that many drivers did not
handle the infamous low_latency behaviour which meant that data was
pushed immediately to the line discipline instead of being deferred to a
work queue.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks
around.

Link: https://lore.kernel.org/linux-serial/cover.1376923198.git.viresh.kumar@linaro.org/
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/bcm63xx_uart.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c
index 5674da2b76f0..5fb0e84f7fd1 100644
--- a/drivers/tty/serial/bcm63xx_uart.c
+++ b/drivers/tty/serial/bcm63xx_uart.c
@@ -294,9 +294,7 @@ static void bcm_uart_do_rx(struct uart_port *port)
 
 	} while (--max_count);
 
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(tty_port);
-	spin_lock(&port->lock);
 }
 
 /*
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 11/26] serial: icom: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (9 preceding siblings ...)
  2021-04-21  9:54 ` [PATCH 10/26] serial: bcm63xx: " Johan Hovold
@ 2021-04-21  9:54 ` Johan Hovold
  2021-04-21  9:54 ` [PATCH 12/26] serial: lpc32xx_hs: " Johan Hovold
                   ` (15 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold

Commit 5faf75d7fed2 ("tty: serial: icom: drop uart_port->lock before
calling tty_flip_buffer_push()") claimed to address a locking
issue but only provided a dubious lockdep splat from an unrelated
driver, which in the end turned out to be due a broken local change
carried by the author.

Unfortunately these patches were merged before the issue had been
analysed properly so the commit messages makes no sense whatsoever.

The real issue was first seen on RT which at the time effectively always
set the low_latency flag for all serial drivers by patching
tty_flip_buffer_push(). This in turn revealed that many drivers did not
handle the infamous low_latency behaviour which meant that data was
pushed immediately to the line discipline instead of being deferred to a
work queue.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks
around.

Link: https://lore.kernel.org/linux-serial/cover.1376923198.git.viresh.kumar@linaro.org/
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/icom.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/icom.c b/drivers/tty/serial/icom.c
index 94af7a5ea497..9e9abfc4824a 100644
--- a/drivers/tty/serial/icom.c
+++ b/drivers/tty/serial/icom.c
@@ -829,9 +829,7 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port)
 	}
 	icom_port->next_rcv = rcv_buff;
 
-	spin_unlock(&icom_port->uart_port.lock);
 	tty_flip_buffer_push(port);
-	spin_lock(&icom_port->uart_port.lock);
 }
 
 static void process_interrupt(u16 port_int_reg,
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 12/26] serial: lpc32xx_hs: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (10 preceding siblings ...)
  2021-04-21  9:54 ` [PATCH 11/26] serial: icom: " Johan Hovold
@ 2021-04-21  9:54 ` Johan Hovold
  2021-04-21  9:54 ` [PATCH 13/26] serial: mcf: " Johan Hovold
                   ` (14 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold

Commit ec128510905c ("tty: serial: lpc32xx_hs: drop uart_port->lock
before calling tty_flip_buffer_push()") claimed to address a locking
issue but only provided a dubious lockdep splat from an unrelated
driver, which in the end turned out to be due a broken local change
carried by the author.

Unfortunately these patches were merged before the issue had been
analysed properly so the commit messages makes no sense whatsoever.

The real issue was first seen on RT which at the time effectively always
set the low_latency flag for all serial drivers by patching
tty_flip_buffer_push(). This in turn revealed that many drivers did not
handle the infamous low_latency behaviour which meant that data was
pushed immediately to the line discipline instead of being deferred to a
work queue.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks
around.

Link: https://lore.kernel.org/linux-serial/cover.1376923198.git.viresh.kumar@linaro.org/
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/lpc32xx_hs.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/lpc32xx_hs.c b/drivers/tty/serial/lpc32xx_hs.c
index 1fa098d7aec4..b199d7859961 100644
--- a/drivers/tty/serial/lpc32xx_hs.c
+++ b/drivers/tty/serial/lpc32xx_hs.c
@@ -273,9 +273,7 @@ static void __serial_lpc32xx_rx(struct uart_port *port)
 		tmp = readl(LPC32XX_HSUART_FIFO(port->membase));
 	}
 
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(tport);
-	spin_lock(&port->lock);
 }
 
 static void __serial_lpc32xx_tx(struct uart_port *port)
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 13/26] serial: mcf: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (11 preceding siblings ...)
  2021-04-21  9:54 ` [PATCH 12/26] serial: lpc32xx_hs: " Johan Hovold
@ 2021-04-21  9:54 ` Johan Hovold
  2021-04-21  9:54 ` [PATCH 14/26] serial: meson: " Johan Hovold
                   ` (13 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold

Commit 5275ad70fed3 ("tty: serial: mcf: drop uart_port->lock before
calling tty_flip_buffer_push()") claimed to address a locking
issue but only provided a dubious lockdep splat from an unrelated
driver, which in the end turned out to be due a broken local change
carried by the author.

Unfortunately these patches were merged before the issue had been
analysed properly so the commit messages makes no sense whatsoever.

The real issue was first seen on RT which at the time effectively always
set the low_latency flag for all serial drivers by patching
tty_flip_buffer_push(). This in turn revealed that many drivers did not
handle the infamous low_latency behaviour which meant that data was
pushed immediately to the line discipline instead of being deferred to a
work queue.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks
around.

Link: https://lore.kernel.org/linux-serial/cover.1376923198.git.viresh.kumar@linaro.org/
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/mcf.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c
index 09c88c48fb7b..c7cec7d03620 100644
--- a/drivers/tty/serial/mcf.c
+++ b/drivers/tty/serial/mcf.c
@@ -319,9 +319,7 @@ static void mcf_rx_chars(struct mcf_uart *pp)
 		uart_insert_char(port, status, MCFUART_USR_RXOVERRUN, ch, flag);
 	}
 
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(&port->state->port);
-	spin_lock(&port->lock);
 }
 
 /****************************************************************************/
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 14/26] serial: meson: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (12 preceding siblings ...)
  2021-04-21  9:54 ` [PATCH 13/26] serial: mcf: " Johan Hovold
@ 2021-04-21  9:54 ` Johan Hovold
  2021-04-21  9:54 ` [PATCH 15/26] serial: mpc52xx_uart: " Johan Hovold
                   ` (12 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold

The meson driver has always carried an unnecessary workaround for the
infamous low_latency behaviour of tty_flip_buffer_push(), which had
already been removed by the time the driver was added by commit
ff7693d079e5 ("ARM: meson: serial: add MesonX SoC on-chip uart driver").

Specifically, since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks around.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/meson_uart.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
index 69eeef9edfa5..529cd0289056 100644
--- a/drivers/tty/serial/meson_uart.c
+++ b/drivers/tty/serial/meson_uart.c
@@ -226,9 +226,7 @@ static void meson_receive_chars(struct uart_port *port)
 
 	} while (!(readl(port->membase + AML_UART_STATUS) & AML_UART_RX_EMPTY));
 
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(tport);
-	spin_lock(&port->lock);
 }
 
 static irqreturn_t meson_uart_interrupt(int irq, void *dev_id)
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 15/26] serial: mpc52xx_uart: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (13 preceding siblings ...)
  2021-04-21  9:54 ` [PATCH 14/26] serial: meson: " Johan Hovold
@ 2021-04-21  9:54 ` Johan Hovold
  2021-04-21  9:54 ` [PATCH 16/26] serial: msm_serial: " Johan Hovold
                   ` (11 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold

Commit fbe543b412ce ("Fix a potential issue in mpc52xx uart driver")
worked around the infamous low_latency behaviour of
tty_flip_buffer_push() by simply dropping and reacquiring the port lock
in the interrupt handler.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks around.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/mpc52xx_uart.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c
index af1700445251..2704dc988e4a 100644
--- a/drivers/tty/serial/mpc52xx_uart.c
+++ b/drivers/tty/serial/mpc52xx_uart.c
@@ -1421,9 +1421,7 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port)
 		}
 	}
 
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(tport);
-	spin_lock(&port->lock);
 
 	return psc_ops->raw_rx_rdy(port);
 }
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 16/26] serial: msm_serial: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (14 preceding siblings ...)
  2021-04-21  9:54 ` [PATCH 15/26] serial: mpc52xx_uart: " Johan Hovold
@ 2021-04-21  9:54 ` Johan Hovold
  2021-04-21 17:44   ` Bjorn Andersson
  2021-04-21  9:55 ` [PATCH 17/26] serial: owl: " Johan Hovold
                   ` (10 subsequent siblings)
  26 siblings, 1 reply; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold, Andy Gross,
	Bjorn Andersson

Commit f77232dab25b ("tty: serial: msm: drop uart_port->lock before
calling tty_flip_buffer_push()") claimed to address a locking
issue but only provided a dubious lockdep splat from an unrelated
driver, which in the end turned out to be due a broken local change
carried by the author.

Unfortunately these patches were merged before the issue had been
analysed properly so the commit messages makes no sense whatsoever.

The real issue was first seen on RT which at the time effectively always
set the low_latency flag for all serial drivers by patching
tty_flip_buffer_push(). This in turn revealed that many drivers did not
handle the infamous low_latency behaviour which meant that data was
pushed immediately to the line discipline instead of being deferred to a
work queue.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks
around.

Link: https://lore.kernel.org/linux-serial/cover.1376923198.git.viresh.kumar@linaro.org/
Cc: Andy Gross <agross@kernel.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/msm_serial.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index 770c182e2208..fcef7a961430 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -757,9 +757,7 @@ static void msm_handle_rx_dm(struct uart_port *port, unsigned int misr)
 		count -= r_count;
 	}
 
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(tport);
-	spin_lock(&port->lock);
 
 	if (misr & (UART_IMR_RXSTALE))
 		msm_write(port, UART_CR_CMD_RESET_STALE_INT, UART_CR);
@@ -819,9 +817,7 @@ static void msm_handle_rx(struct uart_port *port)
 			tty_insert_flip_char(tport, c, flag);
 	}
 
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(tport);
-	spin_lock(&port->lock);
 }
 
 static void msm_handle_tx_pio(struct uart_port *port, unsigned int tx_count)
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 17/26] serial: owl: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (15 preceding siblings ...)
  2021-04-21  9:54 ` [PATCH 16/26] serial: msm_serial: " Johan Hovold
@ 2021-04-21  9:55 ` Johan Hovold
  2021-04-21  9:55 ` [PATCH 18/26] serial: rda: " Johan Hovold
                   ` (9 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold

The owl driver has always carried an unnecessary workaround for the
infamous low_latency behaviour of tty_flip_buffer_push(), which had
been removed years before the driver was added by commit fc60a8b675bd
("tty: serial: owl: Implement console driver").

Specifically, since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks around.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/owl-uart.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/owl-uart.c b/drivers/tty/serial/owl-uart.c
index abc6042f0378..91f1eb0058d7 100644
--- a/drivers/tty/serial/owl-uart.c
+++ b/drivers/tty/serial/owl-uart.c
@@ -247,9 +247,7 @@ static void owl_uart_receive_chars(struct uart_port *port)
 		stat = owl_uart_read(port, OWL_UART_STAT);
 	}
 
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(&port->state->port);
-	spin_lock(&port->lock);
 }
 
 static irqreturn_t owl_uart_irq(int irq, void *dev_id)
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 18/26] serial: rda: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (16 preceding siblings ...)
  2021-04-21  9:55 ` [PATCH 17/26] serial: owl: " Johan Hovold
@ 2021-04-21  9:55 ` Johan Hovold
  2021-04-21  9:55 ` [PATCH 19/26] serial: rp2: " Johan Hovold
                   ` (8 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold

The rda driver has always carried an unnecessary workaround for the
infamous low_latency behaviour of tty_flip_buffer_push(), which had
been removed years before the driver was added by commit c10b13325ced
("tty: serial: Add RDA8810PL UART driver").

Specifically, since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks around.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/rda-uart.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/rda-uart.c b/drivers/tty/serial/rda-uart.c
index 85366e059258..d550d8fa2fab 100644
--- a/drivers/tty/serial/rda-uart.c
+++ b/drivers/tty/serial/rda-uart.c
@@ -398,9 +398,7 @@ static void rda_uart_receive_chars(struct uart_port *port)
 		status = rda_uart_read(port, RDA_UART_STATUS);
 	}
 
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(&port->state->port);
-	spin_lock(&port->lock);
 }
 
 static irqreturn_t rda_interrupt(int irq, void *dev_id)
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 19/26] serial: rp2: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (17 preceding siblings ...)
  2021-04-21  9:55 ` [PATCH 18/26] serial: rda: " Johan Hovold
@ 2021-04-21  9:55 ` Johan Hovold
  2021-04-21  9:55 ` [PATCH 20/26] serial: sa1100: " Johan Hovold
                   ` (7 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold, Kevin Cernekee

Commit de7053c77123 ("tty: serial: rp2: drop uart_port->lock before
calling tty_flip_buffer_push()") claimed to address a locking
issue but only provided a dubious lockdep splat from an unrelated
driver, which in the end turned out to be due a broken local change
carried by the author.

Unfortunately these patches were merged before the issue had been
analysed properly so the commit messages makes no sense whatsoever.

The real issue was first seen on RT which at the time effectively always
set the low_latency flag for all serial drivers by patching
tty_flip_buffer_push(). This in turn revealed that many drivers did not
handle the infamous low_latency behaviour which meant that data was
pushed immediately to the line discipline instead of being deferred to a
work queue.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks
around.

Link: https://lore.kernel.org/linux-serial/cover.1376923198.git.viresh.kumar@linaro.org/
Cc: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/rp2.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/rp2.c b/drivers/tty/serial/rp2.c
index 5690c09cc041..d60abffab70e 100644
--- a/drivers/tty/serial/rp2.c
+++ b/drivers/tty/serial/rp2.c
@@ -424,9 +424,7 @@ static void rp2_rx_chars(struct rp2_uart_port *up)
 		up->port.icount.rx++;
 	}
 
-	spin_unlock(&up->port.lock);
 	tty_flip_buffer_push(port);
-	spin_lock(&up->port.lock);
 }
 
 static void rp2_tx_chars(struct rp2_uart_port *up)
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 20/26] serial: sa1100: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (18 preceding siblings ...)
  2021-04-21  9:55 ` [PATCH 19/26] serial: rp2: " Johan Hovold
@ 2021-04-21  9:55 ` Johan Hovold
  2021-04-21  9:55 ` [PATCH 21/26] serial: txx9: " Johan Hovold
                   ` (6 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold

Commit 53e0e6706c76 ("tty: serial: sa1100: drop uart_port->lock before
calling tty_flip_buffer_push()") claimed to address a locking
issue but only provided a dubious lockdep splat from an unrelated
driver, which in the end turned out to be due a broken local change
carried by the author.

Unfortunately these patches were merged before the issue had been
analysed properly so the commit messages makes no sense whatsoever.

The real issue was first seen on RT which at the time effectively always
set the low_latency flag for all serial drivers by patching
tty_flip_buffer_push(). This in turn revealed that many drivers did not
handle the infamous low_latency behaviour which meant that data was
pushed immediately to the line discipline instead of being deferred to a
work queue.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks
around.

Link: https://lore.kernel.org/linux-serial/cover.1376923198.git.viresh.kumar@linaro.org/
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/sa1100.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/sa1100.c b/drivers/tty/serial/sa1100.c
index f5fab1dd96bc..697b6a002a16 100644
--- a/drivers/tty/serial/sa1100.c
+++ b/drivers/tty/serial/sa1100.c
@@ -223,9 +223,7 @@ sa1100_rx_chars(struct sa1100_port *sport)
 			 UTSR0_TO_SM(UART_GET_UTSR0(sport));
 	}
 
-	spin_unlock(&sport->port.lock);
 	tty_flip_buffer_push(&sport->port.state->port);
-	spin_lock(&sport->port.lock);
 }
 
 static void sa1100_tx_chars(struct sa1100_port *sport)
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 21/26] serial: txx9: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (19 preceding siblings ...)
  2021-04-21  9:55 ` [PATCH 20/26] serial: sa1100: " Johan Hovold
@ 2021-04-21  9:55 ` Johan Hovold
  2021-04-21  9:55 ` [PATCH 22/26] serial: sifive: " Johan Hovold
                   ` (5 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold

Commit f5ee56cc184e ("[PATCH] txx9 serial update") worked around the
infamous low_latency behaviour of tty_flip_buffer_push() by simply
dropping and reacquiring the port lock in the interrupt handler.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks around.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/serial_txx9.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
index 7a07e7272de1..0a7e5b74bc1d 100644
--- a/drivers/tty/serial/serial_txx9.c
+++ b/drivers/tty/serial/serial_txx9.c
@@ -330,9 +330,9 @@ receive_chars(struct uart_txx9_port *up, unsigned int *status)
 		up->port.ignore_status_mask = next_ignore_status_mask;
 		disr = sio_in(up, TXX9_SIDISR);
 	} while (!(disr & TXX9_SIDISR_UVALID) && (max_count-- > 0));
-	spin_unlock(&up->port.lock);
+
 	tty_flip_buffer_push(&up->port.state->port);
-	spin_lock(&up->port.lock);
+
 	*status = disr;
 }
 
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 22/26] serial: sifive: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (20 preceding siblings ...)
  2021-04-21  9:55 ` [PATCH 21/26] serial: txx9: " Johan Hovold
@ 2021-04-21  9:55 ` Johan Hovold
  2021-04-21  9:55 ` [PATCH 23/26] serial: sunsu: " Johan Hovold
                   ` (4 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold,
	Palmer Dabbelt, Paul Walmsley

The sifive driver has always carried an unnecessary workaround for the
infamous low_latency behaviour of tty_flip_buffer_push() which had been
removed years before the driver was added by commit 45c054d0815b ("tty:
serial: add driver for the SiFive UART").

Specifically, since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks around.

Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/sifive.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/sifive.c b/drivers/tty/serial/sifive.c
index 328d5a78792f..0ac0371f943b 100644
--- a/drivers/tty/serial/sifive.c
+++ b/drivers/tty/serial/sifive.c
@@ -448,9 +448,7 @@ static void __ssp_receive_chars(struct sifive_serial_port *ssp)
 		uart_insert_char(&ssp->port, 0, 0, ch, TTY_NORMAL);
 	}
 
-	spin_unlock(&ssp->port.lock);
 	tty_flip_buffer_push(&ssp->port.state->port);
-	spin_lock(&ssp->port.lock);
 }
 
 /**
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 23/26] serial: sunsu: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (21 preceding siblings ...)
  2021-04-21  9:55 ` [PATCH 22/26] serial: sifive: " Johan Hovold
@ 2021-04-21  9:55 ` Johan Hovold
  2021-04-21 16:56   ` David Miller
  2021-04-21  9:55 ` [PATCH 24/26] serial: timbuart: " Johan Hovold
                   ` (3 subsequent siblings)
  26 siblings, 1 reply; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold, David S. Miller

The sunsu driver has been carrying a workaround for the infamous
low_latency behaviour of tty_flip_buffer_push() by dropping and
reacquiring the port lock in the interrupt handler since 2004.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks around.

Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/sunsu.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c
index 319e5ceb6130..12c2468f2b0e 100644
--- a/drivers/tty/serial/sunsu.c
+++ b/drivers/tty/serial/sunsu.c
@@ -466,12 +466,8 @@ static irqreturn_t sunsu_serial_interrupt(int irq, void *dev_id)
 		if (status & UART_LSR_THRE)
 			transmit_chars(up);
 
-		spin_unlock_irqrestore(&up->port.lock, flags);
-
 		tty_flip_buffer_push(&up->port.state->port);
 
-		spin_lock_irqsave(&up->port.lock, flags);
-
 	} while (!(serial_in(up, UART_IIR) & UART_IIR_NO_INT));
 
 	spin_unlock_irqrestore(&up->port.lock, flags);
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 24/26] serial: timbuart: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (22 preceding siblings ...)
  2021-04-21  9:55 ` [PATCH 23/26] serial: sunsu: " Johan Hovold
@ 2021-04-21  9:55 ` Johan Hovold
  2021-04-21  9:55 ` [PATCH 25/26] serial: vt8500: " Johan Hovold
                   ` (2 subsequent siblings)
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold

The timbuart driver has always carried a workaround for the infamous
low_latency behaviour of tty_flip_buffer_push() which required not
holding the port lock when the low_latency flag was set.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks
around.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/timbuart.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/timbuart.c b/drivers/tty/serial/timbuart.c
index 2126e6e6dfd1..08941eabe7b1 100644
--- a/drivers/tty/serial/timbuart.c
+++ b/drivers/tty/serial/timbuart.c
@@ -87,9 +87,7 @@ static void timbuart_rx_chars(struct uart_port *port)
 		tty_insert_flip_char(tport, ch, TTY_NORMAL);
 	}
 
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(tport);
-	spin_lock(&port->lock);
 
 	dev_dbg(port->dev, "%s - total read %d bytes\n",
 		__func__, port->icount.rx);
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 25/26] serial: vt8500: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (23 preceding siblings ...)
  2021-04-21  9:55 ` [PATCH 24/26] serial: timbuart: " Johan Hovold
@ 2021-04-21  9:55 ` Johan Hovold
  2021-04-21  9:55 ` [PATCH 26/26] serial: xilinx_uartps: " Johan Hovold
  2021-04-22 10:09 ` [PATCH 00/26] tty: drop low-latency workarounds Greg Kroah-Hartman
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold, Tony Prisk

Commit de49df58366f ("tty: serial: vt8500: drop uart_port->lock before
calling tty_flip_buffer_push()") claimed to address a locking
issue but only provided a dubious lockdep splat from an unrelated
driver, which in the end turned out to be due a broken local change
carried by the author.

Unfortunately these patches were merged before the issue had been
analysed properly so the commit messages makes no sense whatsoever.

The real issue was first seen on RT which at the time effectively always
set the low_latency flag for all serial drivers by patching
tty_flip_buffer_push(). This in turn revealed that many drivers did not
handle the infamous low_latency behaviour which meant that data was
pushed immediately to the line discipline instead of being deferred to a
work queue.

Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks
around.

Link: https://lore.kernel.org/linux-serial/cover.1376923198.git.viresh.kumar@linaro.org/
Cc: Tony Prisk <linux@prisktech.co.nz>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/vt8500_serial.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c
index 764e992438b2..c5edd56ff830 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -184,9 +184,7 @@ static void handle_rx(struct uart_port *port)
 			tty_insert_flip_char(tport, c, flag);
 	}
 
-	spin_unlock(&port->lock);
 	tty_flip_buffer_push(tport);
-	spin_lock(&port->lock);
 }
 
 static void handle_tx(struct uart_port *port)
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 26/26] serial: xilinx_uartps: drop low-latency workaround
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (24 preceding siblings ...)
  2021-04-21  9:55 ` [PATCH 25/26] serial: vt8500: " Johan Hovold
@ 2021-04-21  9:55 ` Johan Hovold
  2021-04-22 10:09 ` [PATCH 00/26] tty: drop low-latency workarounds Greg Kroah-Hartman
  26 siblings, 0 replies; 34+ messages in thread
From: Johan Hovold @ 2021-04-21  9:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-kernel, Johan Hovold, Michal Simek

Commit c8dbdc842d30 ("serial: xuartps: Rewrite the interrupt handling
logic") reworked the driver interrupt processing but also, without
comment, added an unnecessary workaround for the infamous low_latency
behaviour of tty_flip_buffer_push() which had been removed years
before.

Specifically, since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
tty_flip_buffer_push() always schedules a work item to push data to the
line discipline and there's no need to keep any low_latency hacks around.

Cc: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/xilinx_uartps.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index a14c5d996473..67a2db621e2b 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -301,9 +301,8 @@ static void cdns_uart_handle_rx(void *dev_id, unsigned int isrstatus)
 		tty_insert_flip_char(&port->state->port, data, status);
 		isrstatus = 0;
 	}
-	spin_unlock(&port->lock);
+
 	tty_flip_buffer_push(&port->state->port);
-	spin_lock(&port->lock);
 }
 
 /**
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH 03/26] serial: altera_uart: drop low-latency workaround
  2021-04-21  9:54 ` [PATCH 03/26] serial: altera_uart: " Johan Hovold
@ 2021-04-21 10:03   ` Tobias Klauser
  0 siblings, 0 replies; 34+ messages in thread
From: Tobias Klauser @ 2021-04-21 10:03 UTC (permalink / raw)
  To: Johan Hovold; +Cc: Greg Kroah-Hartman, Jiri Slaby, linux-serial, linux-kernel

On 2021-04-21 at 11:54:46 +0200, Johan Hovold <johan@kernel.org> wrote:
> Commit dd085ed8ef6c ("tty: serial: altera: drop uart_port->lock before
> calling tty_flip_buffer_push()") claimed to address a locking
> issue but only provided a dubious lockdep splat from an unrelated
> driver, which in the end turned out to be due a broken local change
> carried by the author.
> 
> Unfortunately these patches were merged before the issue had been
> analysed properly so the commit messages makes no sense whatsoever.
> 
> The real issue was first seen on RT which at the time effectively always
> set the low_latency flag for all serial drivers by patching
> tty_flip_buffer_push(). This in turn revealed that many drivers did not
> handle the infamous low_latency behaviour which meant that data was
> pushed immediately to the line discipline instead of being deferred to a
> work queue.
> 
> Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
> tty_flip_buffer_push() always schedules a work item to push data to the
> line discipline and there's no need to keep any low_latency hacks
> around.
> 
> Link: https://lore.kernel.org/linux-serial/cover.1376923198.git.viresh.kumar@linaro.org/
> Cc: Tobias Klauser <tklauser@distanz.ch>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Acked-by: Tobias Klauser <tklauser@distanz.ch>

Thanks

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 02/26] serial: altera_jtaguart: drop low-latency workaround
  2021-04-21  9:54 ` [PATCH 02/26] serial: altera_jtaguart: " Johan Hovold
@ 2021-04-21 10:03   ` Tobias Klauser
  0 siblings, 0 replies; 34+ messages in thread
From: Tobias Klauser @ 2021-04-21 10:03 UTC (permalink / raw)
  To: Johan Hovold; +Cc: Greg Kroah-Hartman, Jiri Slaby, linux-serial, linux-kernel

On 2021-04-21 at 11:54:45 +0200, Johan Hovold <johan@kernel.org> wrote:
> Commit 53dd0ba7a6f4 ("tty: serial: altera_jtag: drop uart_port->lock
> before calling tty_flip_buffer_push()") claimed to address a locking
> issue but only provided a dubious lockdep splat from an unrelated
> driver, which in the end turned out to be due a broken local change
> carried by the author.
> 
> Unfortunately these patches were merged before the issue had been
> analysed properly so the commit messages makes no sense whatsoever.
> 
> The real issue was first seen on RT which at the time effectively always
> set the low_latency flag for all serial drivers by patching
> tty_flip_buffer_push(). This in turn revealed that many drivers did not
> handle the infamous low_latency behaviour which meant that data was
> pushed immediately to the line discipline instead of being deferred to a
> work queue.
> 
> Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
> tty_flip_buffer_push() always schedules a work item to push data to the
> line discipline and there's no need to keep any low_latency hacks
> around.
> 
> Link: https://lore.kernel.org/linux-serial/cover.1376923198.git.viresh.kumar@linaro.org/
> Cc: Tobias Klauser <tklauser@distanz.ch>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Acked-by: Tobias Klauser <tklauser@distanz.ch>

Thanks

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 23/26] serial: sunsu: drop low-latency workaround
  2021-04-21  9:55 ` [PATCH 23/26] serial: sunsu: " Johan Hovold
@ 2021-04-21 16:56   ` David Miller
  0 siblings, 0 replies; 34+ messages in thread
From: David Miller @ 2021-04-21 16:56 UTC (permalink / raw)
  To: johan; +Cc: gregkh, jirislaby, linux-serial, linux-kernel

From: Johan Hovold <johan@kernel.org>
Date: Wed, 21 Apr 2021 11:55:06 +0200

> The sunsu driver has been carrying a workaround for the infamous
> low_latency behaviour of tty_flip_buffer_push() by dropping and
> reacquiring the port lock in the interrupt handler since 2004.
> 
> Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
> tty_flip_buffer_push() always schedules a work item to push data to the
> line discipline and there's no need to keep any low_latency hacks around.
> 
> Cc: "David S. Miller" <davem@davemloft.net>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 16/26] serial: msm_serial: drop low-latency workaround
  2021-04-21  9:54 ` [PATCH 16/26] serial: msm_serial: " Johan Hovold
@ 2021-04-21 17:44   ` Bjorn Andersson
  0 siblings, 0 replies; 34+ messages in thread
From: Bjorn Andersson @ 2021-04-21 17:44 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Greg Kroah-Hartman, Jiri Slaby, linux-serial, linux-kernel, Andy Gross

On Wed 21 Apr 04:54 CDT 2021, Johan Hovold wrote:

> Commit f77232dab25b ("tty: serial: msm: drop uart_port->lock before
> calling tty_flip_buffer_push()") claimed to address a locking
> issue but only provided a dubious lockdep splat from an unrelated
> driver, which in the end turned out to be due a broken local change
> carried by the author.
> 
> Unfortunately these patches were merged before the issue had been
> analysed properly so the commit messages makes no sense whatsoever.
> 
> The real issue was first seen on RT which at the time effectively always
> set the low_latency flag for all serial drivers by patching
> tty_flip_buffer_push(). This in turn revealed that many drivers did not
> handle the infamous low_latency behaviour which meant that data was
> pushed immediately to the line discipline instead of being deferred to a
> work queue.
> 
> Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
> tty_flip_buffer_push() always schedules a work item to push data to the
> line discipline and there's no need to keep any low_latency hacks
> around.
> 
> Link: https://lore.kernel.org/linux-serial/cover.1376923198.git.viresh.kumar@linaro.org/
> Cc: Andy Gross <agross@kernel.org>
> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>

Acked-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Regards,
Bjorn

> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  drivers/tty/serial/msm_serial.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
> index 770c182e2208..fcef7a961430 100644
> --- a/drivers/tty/serial/msm_serial.c
> +++ b/drivers/tty/serial/msm_serial.c
> @@ -757,9 +757,7 @@ static void msm_handle_rx_dm(struct uart_port *port, unsigned int misr)
>  		count -= r_count;
>  	}
>  
> -	spin_unlock(&port->lock);
>  	tty_flip_buffer_push(tport);
> -	spin_lock(&port->lock);
>  
>  	if (misr & (UART_IMR_RXSTALE))
>  		msm_write(port, UART_CR_CMD_RESET_STALE_INT, UART_CR);
> @@ -819,9 +817,7 @@ static void msm_handle_rx(struct uart_port *port)
>  			tty_insert_flip_char(tport, c, flag);
>  	}
>  
> -	spin_unlock(&port->lock);
>  	tty_flip_buffer_push(tport);
> -	spin_lock(&port->lock);
>  }
>  
>  static void msm_handle_tx_pio(struct uart_port *port, unsigned int tx_count)
> -- 
> 2.26.3
> 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 05/26] serial: amba-pl011: drop low-latency workaround
  2021-04-21  9:54 ` [PATCH 05/26] serial: amba-pl011: " Johan Hovold
@ 2021-04-22  0:18   ` Linus Walleij
  0 siblings, 0 replies; 34+ messages in thread
From: Linus Walleij @ 2021-04-22  0:18 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Greg Kroah-Hartman, Jiri Slaby, open list:SERIAL DRIVERS,
	linux-kernel, Russell King

On Wed, Apr 21, 2021 at 11:55 AM Johan Hovold <johan@kernel.org> wrote:

> Commit ead76f329f77 ("ARM: 6763/1: pl011: add optional RX DMA to PL011
> v2") added RX DMA support and also reproduced the workaround for the
> infamous low_latency behaviour of tty_flip_buffer_push() by dropping and
> reacquiring the port lock during receive processing.
>
> Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
> tty_flip_buffer_push() always schedules a work item to push data to the
> line discipline and there's no need to keep any low_latency hacks around.
>
> Note that the port lock is also dropped in the PIO path
> (see pl011_rx_chars), but it is not clear whether this is still needed
> by the DMA code added by the aforementioned commit.
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Russell King <linux@armlinux.org.uk>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Looks like the right thing to do to me! Thanks for digging this out.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 01/26] tty: mxser: drop low-latency workaround
  2021-04-21  9:54 ` [PATCH 01/26] tty: mxser: drop low-latency workaround Johan Hovold
@ 2021-04-22  5:59   ` Jiri Slaby
  0 siblings, 0 replies; 34+ messages in thread
From: Jiri Slaby @ 2021-04-22  5:59 UTC (permalink / raw)
  To: Johan Hovold, Greg Kroah-Hartman; +Cc: linux-serial, linux-kernel

On 21. 04. 21, 11:54, Johan Hovold wrote:
> Commit 67d2bc58afdd ("Char: mxser_new, fix recursive locking") worked
> around the infamous low_latency behaviour of tty_flip_buffer_push() by
> simply dropping and reacquiring the port lock in the interrupt handler.
> 
> Since commit a9c3f68f3cd8 ("tty: Fix low_latency BUG"),
> tty_flip_buffer_push() always schedules a work item to push data to the
> line discipline and there's no need to keep any low_latency hacks around.
> 
> Link: https://lore.kernel.org/lkml/3018694794025219@wsc.cz/T/#m06b04c640a7b6f41afb3d34a4cf29b1df4935d3a
> Signed-off-by: Johan Hovold <johan@kernel.org>

Reviewed-by: Jiri Slaby <jirislaby@kernel.org>

> ---
>   drivers/tty/mxser.c | 7 -------
>   1 file changed, 7 deletions(-)
> 
> diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
> index 2d8e76263a25..16a852ecbe8a 100644
> --- a/drivers/tty/mxser.c
> +++ b/drivers/tty/mxser.c
> @@ -2155,14 +2155,7 @@ static void mxser_receive_chars(struct tty_struct *tty,
>   	port->mon_data.rxcnt += cnt;
>   	port->mon_data.up_rxcnt += cnt;
>   
> -	/*
> -	 * We are called from an interrupt context with &port->slock
> -	 * being held. Drop it temporarily in order to prevent
> -	 * recursive locking.
> -	 */
> -	spin_unlock(&port->slock);
>   	tty_flip_buffer_push(&port->port);
> -	spin_lock(&port->slock);
>   }
>   
>   static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port)
> 

thanks,
-- 
js

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 00/26] tty: drop low-latency workarounds
  2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
                   ` (25 preceding siblings ...)
  2021-04-21  9:55 ` [PATCH 26/26] serial: xilinx_uartps: " Johan Hovold
@ 2021-04-22 10:09 ` Greg Kroah-Hartman
  26 siblings, 0 replies; 34+ messages in thread
From: Greg Kroah-Hartman @ 2021-04-22 10:09 UTC (permalink / raw)
  To: Johan Hovold; +Cc: Jiri Slaby, linux-serial, linux-kernel

On Wed, Apr 21, 2021 at 11:54:43AM +0200, Johan Hovold wrote:
> The infamous low_latency behaviour of tty_flip_buffer_push(), which
> meant that data could be pushed to the line discipline immediately
> instead of being deferred to a work queue, was finally removed in 2014.
> 
> Since then there's no need for drivers to keep hacks to temporarily drop
> the port lock during receive processing but this pattern has been
> reproduced in later added drivers nonetheless.
> 
> Note that several of these workarounds were added by a series posted in
> 2013, which ended up being merged despite having completely nonsensical
> commit messages. As it turned out, it was just the RT patch set which
> effectively enabled the low_latency flag for serial drivers that did not
> handle it.
> 
> There's of course nothing wrong releasing the port lock before calling
> tty_flip_buffer_push(), and some drivers still do after this series, but
> let's get rid of the completely unnecessary unlock-and-reacquire
> pattern.

Many thanks for cleaning up this old crud, all now applied.

greg k-h

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2021-04-22 10:09 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-21  9:54 [PATCH 00/26] tty: drop low-latency workarounds Johan Hovold
2021-04-21  9:54 ` [PATCH 01/26] tty: mxser: drop low-latency workaround Johan Hovold
2021-04-22  5:59   ` Jiri Slaby
2021-04-21  9:54 ` [PATCH 02/26] serial: altera_jtaguart: " Johan Hovold
2021-04-21 10:03   ` Tobias Klauser
2021-04-21  9:54 ` [PATCH 03/26] serial: altera_uart: " Johan Hovold
2021-04-21 10:03   ` Tobias Klauser
2021-04-21  9:54 ` [PATCH 04/26] serial: amba-pl010: " Johan Hovold
2021-04-21  9:54 ` [PATCH 05/26] serial: amba-pl011: " Johan Hovold
2021-04-22  0:18   ` Linus Walleij
2021-04-21  9:54 ` [PATCH 06/26] serial: apbuart: " Johan Hovold
2021-04-21  9:54 ` [PATCH 07/26] serial: ar933x: " Johan Hovold
2021-04-21  9:54 ` [PATCH 08/26] serial: arc_uart: " Johan Hovold
2021-04-21  9:54 ` [PATCH 09/26] serial: atmel_serial: " Johan Hovold
2021-04-21  9:54 ` [PATCH 10/26] serial: bcm63xx: " Johan Hovold
2021-04-21  9:54 ` [PATCH 11/26] serial: icom: " Johan Hovold
2021-04-21  9:54 ` [PATCH 12/26] serial: lpc32xx_hs: " Johan Hovold
2021-04-21  9:54 ` [PATCH 13/26] serial: mcf: " Johan Hovold
2021-04-21  9:54 ` [PATCH 14/26] serial: meson: " Johan Hovold
2021-04-21  9:54 ` [PATCH 15/26] serial: mpc52xx_uart: " Johan Hovold
2021-04-21  9:54 ` [PATCH 16/26] serial: msm_serial: " Johan Hovold
2021-04-21 17:44   ` Bjorn Andersson
2021-04-21  9:55 ` [PATCH 17/26] serial: owl: " Johan Hovold
2021-04-21  9:55 ` [PATCH 18/26] serial: rda: " Johan Hovold
2021-04-21  9:55 ` [PATCH 19/26] serial: rp2: " Johan Hovold
2021-04-21  9:55 ` [PATCH 20/26] serial: sa1100: " Johan Hovold
2021-04-21  9:55 ` [PATCH 21/26] serial: txx9: " Johan Hovold
2021-04-21  9:55 ` [PATCH 22/26] serial: sifive: " Johan Hovold
2021-04-21  9:55 ` [PATCH 23/26] serial: sunsu: " Johan Hovold
2021-04-21 16:56   ` David Miller
2021-04-21  9:55 ` [PATCH 24/26] serial: timbuart: " Johan Hovold
2021-04-21  9:55 ` [PATCH 25/26] serial: vt8500: " Johan Hovold
2021-04-21  9:55 ` [PATCH 26/26] serial: xilinx_uartps: " Johan Hovold
2021-04-22 10:09 ` [PATCH 00/26] tty: drop low-latency workarounds Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.