Commit f8fd1b03 authored by Loic Poulain's avatar Loic Poulain Committed by Greg Kroah-Hartman

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: default avatarLoic Poulain <loic.poulain@intel.com>
Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b08c9c31
...@@ -20,12 +20,15 @@ static void __dma_tx_complete(void *param) ...@@ -20,12 +20,15 @@ static void __dma_tx_complete(void *param)
struct uart_8250_port *p = param; struct uart_8250_port *p = param;
struct uart_8250_dma *dma = p->dma; struct uart_8250_dma *dma = p->dma;
struct circ_buf *xmit = &p->port.state->xmit; struct circ_buf *xmit = &p->port.state->xmit;
unsigned long flags;
dma->tx_running = 0;
dma_sync_single_for_cpu(dma->txchan->device->dev, dma->tx_addr, dma_sync_single_for_cpu(dma->txchan->device->dev, dma->tx_addr,
UART_XMIT_SIZE, DMA_TO_DEVICE); UART_XMIT_SIZE, DMA_TO_DEVICE);
spin_lock_irqsave(&p->port.lock, flags);
dma->tx_running = 0;
xmit->tail += dma->tx_size; xmit->tail += dma->tx_size;
xmit->tail &= UART_XMIT_SIZE - 1; xmit->tail &= UART_XMIT_SIZE - 1;
p->port.icount.tx += dma->tx_size; p->port.icount.tx += dma->tx_size;
...@@ -35,6 +38,8 @@ static void __dma_tx_complete(void *param) ...@@ -35,6 +38,8 @@ static void __dma_tx_complete(void *param)
if (!uart_circ_empty(xmit) && !uart_tx_stopped(&p->port)) if (!uart_circ_empty(xmit) && !uart_tx_stopped(&p->port))
serial8250_tx_dma(p); serial8250_tx_dma(p);
spin_unlock_irqrestore(&p->port.lock, flags);
} }
static void __dma_rx_complete(void *param) static void __dma_rx_complete(void *param)
......
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