Skip to contentSkip to conversation

tty: serial: 8250: omap: restore registers on shutdown

PATCH In review John Ogness 2 participants 2 messages Jan 22, 2016 – Jan 23, 2016 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty: serial: 8250: omap: restore registers on shutdown

If DMA is active during a shutdown, a delayed restore of the registers may be pending. The restore must be performed after the DMA is stopped, otherwise the delayed restore remains pending and will fire upon the first DMA TX complete of a totally different serial session.

---
This patch was originally posted and discussed here:
http://lkml.kernel.org/r/[email protected]

The patch was not accepted because Peter expressed dissatisfaction with the entire deferred implementation. (This patch fixes a bug in that implementation.) However, no alternative solution was determined and the bug continues to exist.

Although we can certainly continue to debate about an alternate solution to the deferred implementation, I think it makes sense to at least fix the existing bug until an alternative exists.

The bug can be easily produced with a kill -9 on a process transmitting on the serial port.

patch against next-20160122

 drivers/tty/serial/8250/8250_omap.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/tty/serial/8250/8250_omap.c +7 -1
index a2c0734..0ffec67 100644
@@ -664,9 +664,15 @@ static void omap_8250_shutdown(struct uart_port *port)
 	up->ier = 0;
 	serial_out(up, UART_IER, 0);
 
-	if (up->dma)
+	if (up->dma) {
 		serial8250_release_dma(up);
 
+		if (priv->delayed_restore) {
+			priv->delayed_restore = 0;
+			omap8250_restore_regs(up);
+		}
+	}
+
 	/*
 	 * Disable break condition and FIFOs
 	 */
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 7 lines · John Ogness

If DMA is active during a shutdown, a delayed restore of the registers may be pending. The restore must be performed after the DMA is stopped, otherwise the delayed restore remains pending and will fire upon the first DMA TX complete of a totally different serial session.

Quoted 8 lines

---
This patch was originally posted and discussed here:
http://lkml.kernel.org/r/[email protected]

The patch was not accepted because Peter expressed dissatisfaction with the entire deferred implementation. (This patch fixes a bug in that implementation.) However, no alternative solution was determined and the bug continues to exist.

Yeah, I made that comment a while ago and still no one's fixed that. What gives?

Regards,
Peter Hurley

Quoted 34 lines

Although we can certainly continue to debate about an alternate solution to the deferred implementation, I think it makes sense to at least fix the existing bug until an alternative exists.

The bug can be easily produced with a kill -9 on a process transmitting on the serial port.

patch against next-20160122

 drivers/tty/serial/8250/8250_omap.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/tty/serial/8250/8250_omap.c +7 -1
index a2c0734..0ffec67 100644
@@ -664,9 +664,15 @@ static void omap_8250_shutdown(struct uart_port *port)
 	up->ier = 0;
 	serial_out(up, UART_IER, 0);
 
-	if (up->dma)
+	if (up->dma) {
 		serial8250_release_dma(up);
 
+		if (priv->delayed_restore) {
+			priv->delayed_restore = 0;
+			omap8250_restore_regs(up);
+		}
+	}
+
 	/*
 	 * Disable break condition and FIFOs
 	 */