serial: bfin-uart: Don't access tty circular buffer in TX DMA interrupt after it...
authorSonic Zhang <sonic.zhang@analog.com>
Tue, 13 Mar 2012 07:51:55 +0000 (15:51 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Mar 2012 21:33:39 +0000 (14:33 -0700)
When kernel reboot, tty circular buffer is reset before last TX DMA interrupt is called,
while the buffer tail is updated in TX DMA interrupt handler. So, don't update the buffer
tail if it is reset.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/bfin_uart.c

index 26953bfa6922f4ffbebc8da4bb7a2ac60f672695..5832fdef11e9dea8444acb0cb740df5355b547eb 100644 (file)
@@ -535,11 +535,13 @@ static irqreturn_t bfin_serial_dma_tx_int(int irq, void *dev_id)
                 *              when start a new tx.
                 */
                UART_CLEAR_IER(uart, ETBEI);
-               xmit->tail = (xmit->tail + uart->tx_count) & (UART_XMIT_SIZE - 1);
                uart->port.icount.tx += uart->tx_count;
+               if (!uart_circ_empty(xmit)) {
+                       xmit->tail = (xmit->tail + uart->tx_count) & (UART_XMIT_SIZE - 1);
 
-               if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
-                       uart_write_wakeup(&uart->port);
+                       if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
+                               uart_write_wakeup(&uart->port);
+               }
 
                bfin_serial_dma_tx_chars(uart);
        }