Commit 73631813 authored by Jiada Wang's avatar Jiada Wang Committed by Greg Kroah-Hartman

serial: imx: use locking to stop concurrent access of UCR1

Several places are accessing the UCR1 register without locking.
This probably will cause a race issue when another thread
is accessing the same register.
Add locking to preventing concurrent access of the UCR1 register.
Signed-off-by: default avatarJiada Wang <jiada_wang@mentor.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 55d8693a
...@@ -731,6 +731,9 @@ static int start_rx_dma(struct imx_port *sport); ...@@ -731,6 +731,9 @@ static int start_rx_dma(struct imx_port *sport);
static void imx_dma_rxint(struct imx_port *sport) static void imx_dma_rxint(struct imx_port *sport)
{ {
unsigned long temp; unsigned long temp;
unsigned long flags;
spin_lock_irqsave(&sport->port.lock, flags);
temp = readl(sport->port.membase + USR2); temp = readl(sport->port.membase + USR2);
if ((temp & USR2_RDR) && !sport->dma_is_rxing) { if ((temp & USR2_RDR) && !sport->dma_is_rxing) {
...@@ -744,6 +747,8 @@ static void imx_dma_rxint(struct imx_port *sport) ...@@ -744,6 +747,8 @@ static void imx_dma_rxint(struct imx_port *sport)
/* tell the DMA to receive the data. */ /* tell the DMA to receive the data. */
start_rx_dma(sport); start_rx_dma(sport);
} }
spin_unlock_irqrestore(&sport->port.lock, flags);
} }
static irqreturn_t imx_int(int irq, void *dev_id) static irqreturn_t imx_int(int irq, void *dev_id)
...@@ -873,6 +878,9 @@ static int imx_setup_ufcr(struct imx_port *sport, unsigned int mode) ...@@ -873,6 +878,9 @@ static int imx_setup_ufcr(struct imx_port *sport, unsigned int mode)
static void imx_rx_dma_done(struct imx_port *sport) static void imx_rx_dma_done(struct imx_port *sport)
{ {
unsigned long temp; unsigned long temp;
unsigned long flags;
spin_lock_irqsave(&sport->port.lock, flags);
/* Enable this interrupt when the RXFIFO is empty. */ /* Enable this interrupt when the RXFIFO is empty. */
temp = readl(sport->port.membase + UCR1); temp = readl(sport->port.membase + UCR1);
...@@ -884,6 +892,8 @@ static void imx_rx_dma_done(struct imx_port *sport) ...@@ -884,6 +892,8 @@ static void imx_rx_dma_done(struct imx_port *sport)
/* Is the shutdown waiting for us? */ /* Is the shutdown waiting for us? */
if (waitqueue_active(&sport->dma_wait)) if (waitqueue_active(&sport->dma_wait))
wake_up(&sport->dma_wait); wake_up(&sport->dma_wait);
spin_unlock_irqrestore(&sport->port.lock, flags);
} }
/* /*
...@@ -1194,9 +1204,11 @@ static void imx_shutdown(struct uart_port *port) ...@@ -1194,9 +1204,11 @@ static void imx_shutdown(struct uart_port *port)
dmaengine_terminate_all(sport->dma_chan_tx); dmaengine_terminate_all(sport->dma_chan_tx);
dmaengine_terminate_all(sport->dma_chan_rx); dmaengine_terminate_all(sport->dma_chan_rx);
} }
spin_lock_irqsave(&sport->port.lock, flags);
imx_stop_tx(port); imx_stop_tx(port);
imx_stop_rx(port); imx_stop_rx(port);
imx_disable_dma(sport); imx_disable_dma(sport);
spin_unlock_irqrestore(&sport->port.lock, flags);
imx_uart_dma_exit(sport); imx_uart_dma_exit(sport);
} }
......
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