serial: uartps: Move the spinlock after the read of the tx empty
authorShubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Fri, 24 May 2019 09:11:28 +0000 (14:41 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Feb 2020 21:32:23 +0000 (16:32 -0500)
commit 107475685abfdee504bb0ef4824f15797f6d2d4d upstream.

Currently we are doing a read of the status register.
Move the spinlock after that as the reads need not be spinlock
protected. This patch prevents relaxing the cpu with spinlock held.

Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Cc: Pavel Machek <pavel@denx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/xilinx_uartps.c

index 9826a15bfd8717425de45eabdd30dede67da3970..81657f09761cd764dfe8faa1d7552a54aac6a5bf 100644 (file)
@@ -690,8 +690,6 @@ static void cdns_uart_set_termios(struct uart_port *port,
        unsigned int ctrl_reg, mode_reg, val;
        int err;
 
-       spin_lock_irqsave(&port->lock, flags);
-
        /* Wait for the transmit FIFO to empty before making changes */
        if (!(readl(port->membase + CDNS_UART_CR) &
                                CDNS_UART_CR_TX_DIS)) {
@@ -703,6 +701,7 @@ static void cdns_uart_set_termios(struct uart_port *port,
                        return;
                }
        }
+       spin_lock_irqsave(&port->lock, flags);
 
        /* Disable the TX and RX to set baud rate */
        ctrl_reg = readl(port->membase + CDNS_UART_CR);