summaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/8250/8250_dma.c
diff options
context:
space:
mode:
authorLoic Poulain <loic.poulain@intel.com>2014-04-24 11:34:48 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-04-25 00:18:02 +0200
commitf8fd1b0350d3a4581125f5eda6528f5a2c5f9183 (patch)
treef350e27d766290b1a14ea59d5bc5d40e87f77eb2 /drivers/tty/serial/8250/8250_dma.c
parent8250_core: Fix unwanted TX chars write (diff)
downloadlinux-f8fd1b0350d3a4581125f5eda6528f5a2c5f9183.tar.xz
linux-f8fd1b0350d3a4581125f5eda6528f5a2c5f9183.zip
serial: 8250: Fix thread unsafe __dma_tx_complete function
__dma_tx_complete is not protected against concurrent call of serial8250_tx_dma. it can lead to circular tail index corruption or parallel call of serial_tx_dma on the same data portion. This patch fixes this issue by holding the port lock. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/8250/8250_dma.c')
-rw-r--r--drivers/tty/serial/8250/8250_dma.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c
index 7046769608d4..ab9096dc3849 100644
--- a/drivers/tty/serial/8250/8250_dma.c
+++ b/drivers/tty/serial/8250/8250_dma.c
@@ -20,12 +20,15 @@ static void __dma_tx_complete(void *param)
struct uart_8250_port *p = param;
struct uart_8250_dma *dma = p->dma;
struct circ_buf *xmit = &p->port.state->xmit;
-
- dma->tx_running = 0;
+ unsigned long flags;
dma_sync_single_for_cpu(dma->txchan->device->dev, dma->tx_addr,
UART_XMIT_SIZE, DMA_TO_DEVICE);
+ spin_lock_irqsave(&p->port.lock, flags);
+
+ dma->tx_running = 0;
+
xmit->tail += dma->tx_size;
xmit->tail &= UART_XMIT_SIZE - 1;
p->port.icount.tx += dma->tx_size;
@@ -35,6 +38,8 @@ static void __dma_tx_complete(void *param)
if (!uart_circ_empty(xmit) && !uart_tx_stopped(&p->port))
serial8250_tx_dma(p);
+
+ spin_unlock_irqrestore(&p->port.lock, flags);
}
static void __dma_rx_complete(void *param)