Skip to content

Commit

Permalink
atmel_serial: avoid stopping pdc during transmission
Browse files Browse the repository at this point in the history
I found a problem related to losing data during pdc transmission in
atmel_serial: connect ttyS1 with ttyS2 using a loopback cable, send 30
byte of packet from one to the other and waiting for 30 byte.  On the
other side just read and echo the data received.

We always call atmel_tx_dma() from the tasklet regardless of what interrupt
triggered it.

Signed-off-by: michael <trimarchi@gandalf.sssup.it>
Acked-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Michael Trimarchi authored and Linus Torvalds committed Apr 2, 2008
1 parent dd135eb commit ba0657f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions drivers/serial/atmel_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@

/* PDC registers */
#define UART_PUT_PTCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_PTCR)
#define UART_GET_TCR(port) __raw_readl((port)->membase + ATMEL_PDC_TCR)
#define UART_GET_PTSR(port) __raw_readl((port)->membase + ATMEL_PDC_PTSR)

#define UART_PUT_RPR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_RPR)
Expand Down Expand Up @@ -562,17 +563,22 @@ static void atmel_tx_dma(struct uart_port *port)
struct atmel_dma_buffer *pdc = &atmel_port->pdc_tx;
int count;

/* nothing left to transmit? */
if (UART_GET_TCR(port))
return;

xmit->tail += pdc->ofs;
xmit->tail &= UART_XMIT_SIZE - 1;

port->icount.tx += pdc->ofs;
pdc->ofs = 0;

if (!uart_circ_empty(xmit)) {
/* more to transmit - setup next transfer */
/* more to transmit - setup next transfer */

/* disable PDC transmit */
UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS);
/* disable PDC transmit */
UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS);

if (!uart_circ_empty(xmit)) {
dma_sync_single_for_device(port->dev,
pdc->dma_addr,
pdc->dma_size,
Expand All @@ -586,11 +592,6 @@ static void atmel_tx_dma(struct uart_port *port)
/* re-enable PDC transmit and interrupts */
UART_PUT_PTCR(port, ATMEL_PDC_TXTEN);
UART_PUT_IER(port, ATMEL_US_ENDTX | ATMEL_US_TXBUFE);
} else {
/* nothing left to transmit - disable the transmitter */

/* disable PDC transmit */
UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS);
}

if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
Expand Down

0 comments on commit ba0657f

Please sign in to comment.