Subject: [PATCH 1/2] serial: Add flush_buffer() operation to uart_ops

Serial drivers using DMA (like the atmel_serial driver) tend to get very
confused when the xmit buffer is flushed and nobody told them.  They
also tend to spew a lot of garbage since the DMA engine keeps running
after the buffer is flushed and possibly refilled with unrelated data.

This patch adds a new flush_buffer operation to the uart_ops struct,
along with a call to it from uart_flush_buffer() right after the xmit
buffer has been cleared. The driver can implement this in order to
syncronize its internal DMA state with the xmit buffer when the buffer
is flushed.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Acked-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Haavard Skinnemoen 2008-07-16 21:52:36 +01:00 committed by Linus Torvalds
parent 15648f154a
commit 6bb0e3a59a
3 changed files with 14 additions and 0 deletions

View file

@ -186,6 +186,17 @@ hardware.
Locking: port_sem taken. Locking: port_sem taken.
Interrupts: caller dependent. Interrupts: caller dependent.
flush_buffer(port)
Flush any write buffers, reset any DMA state and stop any
ongoing DMA transfers.
This will be called whenever the port->info->xmit circular
buffer is cleared.
Locking: port->lock taken.
Interrupts: locally disabled.
This call must not sleep
set_termios(port,termios,oldtermios) set_termios(port,termios,oldtermios)
Change the port parameters, including word length, parity, stop Change the port parameters, including word length, parity, stop
bits. Update read_status_mask and ignore_status_mask to indicate bits. Update read_status_mask and ignore_status_mask to indicate

View file

@ -573,6 +573,8 @@ static void uart_flush_buffer(struct tty_struct *tty)
spin_lock_irqsave(&port->lock, flags); spin_lock_irqsave(&port->lock, flags);
uart_circ_clear(&state->info->xmit); uart_circ_clear(&state->info->xmit);
if (port->ops->flush_buffer)
port->ops->flush_buffer(port);
spin_unlock_irqrestore(&port->lock, flags); spin_unlock_irqrestore(&port->lock, flags);
tty_wakeup(tty); tty_wakeup(tty);
} }

View file

@ -190,6 +190,7 @@ struct uart_ops {
void (*break_ctl)(struct uart_port *, int ctl); void (*break_ctl)(struct uart_port *, int ctl);
int (*startup)(struct uart_port *); int (*startup)(struct uart_port *);
void (*shutdown)(struct uart_port *); void (*shutdown)(struct uart_port *);
void (*flush_buffer)(struct uart_port *);
void (*set_termios)(struct uart_port *, struct ktermios *new, void (*set_termios)(struct uart_port *, struct ktermios *new,
struct ktermios *old); struct ktermios *old);
void (*set_ldisc)(struct uart_port *); void (*set_ldisc)(struct uart_port *);