Commit f0f54a80 authored by Soren Brinkmann's avatar Soren Brinkmann Committed by Greg Kroah-Hartman

tty: xuartps: Use spinlock to serialize HW access

Instead of disabling the IRQ, use the spin lock to serialize accesses to
the HW. This protects the driver from interference of non-IRQ callbacks
with each other and makes the driver more consistent in its
serialization method.
Signed-off-by: default avatarSoren Brinkmann <soren.brinkmann@xilinx.com>
Reviewed-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e3538c37
...@@ -945,12 +945,10 @@ static void cdns_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) ...@@ -945,12 +945,10 @@ static void cdns_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
#ifdef CONFIG_CONSOLE_POLL #ifdef CONFIG_CONSOLE_POLL
static int cdns_uart_poll_get_char(struct uart_port *port) static int cdns_uart_poll_get_char(struct uart_port *port)
{ {
u32 imr;
int c; int c;
unsigned long flags;
/* Disable all interrupts */ spin_lock_irqsave(&port->lock, flags);
imr = readl(port->membase + CDNS_UART_IMR_OFFSET);
writel(imr, port->membase + CDNS_UART_IDR_OFFSET);
/* Check if FIFO is empty */ /* Check if FIFO is empty */
if (readl(port->membase + CDNS_UART_SR_OFFSET) & CDNS_UART_SR_RXEMPTY) if (readl(port->membase + CDNS_UART_SR_OFFSET) & CDNS_UART_SR_RXEMPTY)
...@@ -959,19 +957,16 @@ static int cdns_uart_poll_get_char(struct uart_port *port) ...@@ -959,19 +957,16 @@ static int cdns_uart_poll_get_char(struct uart_port *port)
c = (unsigned char) readl( c = (unsigned char) readl(
port->membase + CDNS_UART_FIFO_OFFSET); port->membase + CDNS_UART_FIFO_OFFSET);
/* Enable interrupts */ spin_unlock_irqrestore(&port->lock, flags);
writel(imr, port->membase + CDNS_UART_IER_OFFSET);
return c; return c;
} }
static void cdns_uart_poll_put_char(struct uart_port *port, unsigned char c) static void cdns_uart_poll_put_char(struct uart_port *port, unsigned char c)
{ {
u32 imr; unsigned long flags;
/* Disable all interrupts */ spin_lock_irqsave(&port->lock, flags);
imr = readl(port->membase + CDNS_UART_IMR_OFFSET);
writel(imr, port->membase + CDNS_UART_IDR_OFFSET);
/* Wait until FIFO is empty */ /* Wait until FIFO is empty */
while (!(readl(port->membase + CDNS_UART_SR_OFFSET) & while (!(readl(port->membase + CDNS_UART_SR_OFFSET) &
...@@ -986,8 +981,7 @@ static void cdns_uart_poll_put_char(struct uart_port *port, unsigned char c) ...@@ -986,8 +981,7 @@ static void cdns_uart_poll_put_char(struct uart_port *port, unsigned char c)
CDNS_UART_SR_TXEMPTY)) CDNS_UART_SR_TXEMPTY))
cpu_relax(); cpu_relax();
/* Enable interrupts */ spin_unlock_irqrestore(&port->lock, flags);
writel(imr, port->membase + CDNS_UART_IER_OFFSET);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment