[PATCH] serial: xuartps: reset TX state to initial after write

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In commit d3755f5e6cd2 ("tty: xuartps: Force enable the UART in
xuartps_console_write") added some logic to enable TX before writing
and resetting it back to the original state. Uwe Kleine-König
discovered that commit e3538c37ee38 ("tty: xuartps: Beautify
read-modify writes") breaks that logic and always leaves TX enabled.
This commit reverts the unintended functional change.

Fixes: e3538c37ee38 ("tty: xuartps: Beautify read-modify writes")
Signed-off-by: Helmut Grohne <h.grohne@xxxxxxxxxx>
---
 drivers/tty/serial/xilinx_uartps.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Note that e3538c37ee38 partially hides a hardware race condition that
becomes visible again after applying this patch.

The recipient list is a combination of get_maintainer.pl output and the
reviewers of e3538c37ee38.

diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index cd46e64..acaf83c 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -1092,7 +1092,7 @@ static void cdns_uart_console_write(struct console *co, const char *s,
 {
 	struct uart_port *port = &cdns_uart_port[co->index];
 	unsigned long flags;
-	unsigned int imr, ctrl;
+	unsigned int imr, orig_ctrl, ctrl;
 	int locked = 1;
 
 	if (port->sysrq)
@@ -1110,7 +1110,7 @@ static void cdns_uart_console_write(struct console *co, const char *s,
 	 * Make sure that the tx part is enabled. Set the TX enable bit and
 	 * clear the TX disable bit to enable the transmitter.
 	 */
-	ctrl = readl(port->membase + CDNS_UART_CR);
+	orig_ctrl = ctrl = readl(port->membase + CDNS_UART_CR);
 	ctrl &= ~CDNS_UART_CR_TX_DIS;
 	ctrl |= CDNS_UART_CR_TX_EN;
 	writel(ctrl, port->membase + CDNS_UART_CR);
@@ -1118,7 +1118,7 @@ static void cdns_uart_console_write(struct console *co, const char *s,
 	uart_console_write(port, s, count, cdns_uart_console_putchar);
 	cdns_uart_console_wait_tx(port);
 
-	writel(ctrl, port->membase + CDNS_UART_CR);
+	writel(orig_ctrl, port->membase + CDNS_UART_CR);
 
 	/* restore interrupt state */
 	writel(imr, port->membase + CDNS_UART_IER);
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux