Commit b2202821 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Greg Kroah-Hartman

tty: serial: 8250_dma: handle error on TX submit

Right now it is possible that serial8250_tx_dma() fails and returns
-EBUSY. The caller (serial8250_start_tx()) will then enable
UART_IER_THRI which will generate an interrupt once the TX FIFO is
empty.
In serial8250_handle_irq() nothing will happen because up->dma is set
and so serial8250_tx_chars() won't be invoked. We end up with plenty of
interrupts and some "too much work for irq" output.

This patch introduces dma_tx_err in struct uart_8250_port to signal that
the last invocation of serial8250_tx_dma() failed so we can fill the TX
FIFO manually. Should the next invocation of serial8250_start_tx()
succeed then the dma_tx_err flag along with the THRI bit is removed and
DMA only usage may continue.
Reviewed-by: default avatarTony Lindgren <tony@atomide.com>
Tested-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 61929cf0
...@@ -41,6 +41,7 @@ struct uart_8250_dma { ...@@ -41,6 +41,7 @@ struct uart_8250_dma {
size_t tx_size; size_t tx_size;
unsigned char tx_running:1; unsigned char tx_running:1;
unsigned char tx_err: 1;
}; };
struct old_serial_port { struct old_serial_port {
......
...@@ -1597,7 +1597,8 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) ...@@ -1597,7 +1597,8 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
status = serial8250_rx_chars(up, status); status = serial8250_rx_chars(up, status);
} }
serial8250_modem_status(up); serial8250_modem_status(up);
if (!up->dma && (status & UART_LSR_THRE)) if ((!up->dma || (up->dma && up->dma->tx_err)) &&
(status & UART_LSR_THRE))
serial8250_tx_chars(up); serial8250_tx_chars(up);
spin_unlock_irqrestore(&port->lock, flags); spin_unlock_irqrestore(&port->lock, flags);
......
...@@ -36,8 +36,16 @@ static void __dma_tx_complete(void *param) ...@@ -36,8 +36,16 @@ static void __dma_tx_complete(void *param)
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_write_wakeup(&p->port); uart_write_wakeup(&p->port);
if (!uart_circ_empty(xmit) && !uart_tx_stopped(&p->port)) if (!uart_circ_empty(xmit) && !uart_tx_stopped(&p->port)) {
serial8250_tx_dma(p); int ret;
ret = serial8250_tx_dma(p);
if (ret) {
dma->tx_err = 1;
p->ier |= UART_IER_THRI;
serial_port_out(&p->port, UART_IER, p->ier);
}
}
spin_unlock_irqrestore(&p->port.lock, flags); spin_unlock_irqrestore(&p->port.lock, flags);
} }
...@@ -69,6 +77,7 @@ int serial8250_tx_dma(struct uart_8250_port *p) ...@@ -69,6 +77,7 @@ int serial8250_tx_dma(struct uart_8250_port *p)
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;
struct dma_async_tx_descriptor *desc; struct dma_async_tx_descriptor *desc;
int ret;
if (uart_tx_stopped(&p->port) || dma->tx_running || if (uart_tx_stopped(&p->port) || dma->tx_running ||
uart_circ_empty(xmit)) uart_circ_empty(xmit))
...@@ -80,8 +89,10 @@ int serial8250_tx_dma(struct uart_8250_port *p) ...@@ -80,8 +89,10 @@ int serial8250_tx_dma(struct uart_8250_port *p)
dma->tx_addr + xmit->tail, dma->tx_addr + xmit->tail,
dma->tx_size, DMA_MEM_TO_DEV, dma->tx_size, DMA_MEM_TO_DEV,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK); DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (!desc) if (!desc) {
return -EBUSY; ret = -EBUSY;
goto err;
}
dma->tx_running = 1; dma->tx_running = 1;
...@@ -94,8 +105,17 @@ int serial8250_tx_dma(struct uart_8250_port *p) ...@@ -94,8 +105,17 @@ int serial8250_tx_dma(struct uart_8250_port *p)
UART_XMIT_SIZE, DMA_TO_DEVICE); UART_XMIT_SIZE, DMA_TO_DEVICE);
dma_async_issue_pending(dma->txchan); dma_async_issue_pending(dma->txchan);
if (dma->tx_err) {
dma->tx_err = 0;
if (p->ier & UART_IER_THRI) {
p->ier &= ~UART_IER_THRI;
serial_out(p, UART_IER, p->ier);
}
}
return 0; return 0;
err:
dma->tx_err = 1;
return ret;
} }
EXPORT_SYMBOL_GPL(serial8250_tx_dma); EXPORT_SYMBOL_GPL(serial8250_tx_dma);
......
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