serial: sh-sci: Fix race condition causing garbage during shutdown
If DMA is enabled and used, a burst of old data may be seen on the
serial console during "poweroff" or "reboot". uart_flush_buffer()
clears the circular buffer, but sci_port.tx_dma_len is not reset.
This leads to a circular buffer overflow, dumping (UART_XMIT_SIZE -
sci_port.tx_dma_len) bytes.
To fix this, add a .flush_buffer() callback that resets
sci_port.tx_dma_len.
Inspired by commit 31ca2c63fd
("tty/serial: atmel: fix race
condition (TX+DMA)").
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
7fbcf3afe6
commit
1cf4a7efdc
|
@ -1558,7 +1558,16 @@ static void sci_free_dma(struct uart_port *port)
|
||||||
if (s->chan_rx)
|
if (s->chan_rx)
|
||||||
sci_rx_dma_release(s, false);
|
sci_rx_dma_release(s, false);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
|
static void sci_flush_buffer(struct uart_port *port)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* In uart_flush_buffer(), the xmit circular buffer has just been
|
||||||
|
* cleared, so we have to reset tx_dma_len accordingly.
|
||||||
|
*/
|
||||||
|
to_sci_port(port)->tx_dma_len = 0;
|
||||||
|
}
|
||||||
|
#else /* !CONFIG_SERIAL_SH_SCI_DMA */
|
||||||
static inline void sci_request_dma(struct uart_port *port)
|
static inline void sci_request_dma(struct uart_port *port)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1566,7 +1575,9 @@ static inline void sci_request_dma(struct uart_port *port)
|
||||||
static inline void sci_free_dma(struct uart_port *port)
|
static inline void sci_free_dma(struct uart_port *port)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
#define sci_flush_buffer NULL
|
||||||
|
#endif /* !CONFIG_SERIAL_SH_SCI_DMA */
|
||||||
|
|
||||||
static irqreturn_t sci_rx_interrupt(int irq, void *ptr)
|
static irqreturn_t sci_rx_interrupt(int irq, void *ptr)
|
||||||
{
|
{
|
||||||
|
@ -2581,6 +2592,7 @@ static const struct uart_ops sci_uart_ops = {
|
||||||
.break_ctl = sci_break_ctl,
|
.break_ctl = sci_break_ctl,
|
||||||
.startup = sci_startup,
|
.startup = sci_startup,
|
||||||
.shutdown = sci_shutdown,
|
.shutdown = sci_shutdown,
|
||||||
|
.flush_buffer = sci_flush_buffer,
|
||||||
.set_termios = sci_set_termios,
|
.set_termios = sci_set_termios,
|
||||||
.pm = sci_pm,
|
.pm = sci_pm,
|
||||||
.type = sci_type,
|
.type = sci_type,
|
||||||
|
|
Loading…
Reference in New Issue