diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2014-07-06 11:29:52 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-07-10 19:31:34 -0400 |
commit | c557d392fbf5badd693ea1946a4317c87a26a716 (patch) | |
tree | 10b1369df578934fa8d43fbef7c69fb523ac5ab9 | |
parent | cd3de83f147601356395b57a8673e9c5ff1e59d1 (diff) |
serial: Test for no tx data on tx restart
Commit 717f3bbab3c7628736ef738fdbf3d9a28578c26c,
'serial_core: Fix conditional start_tx on ring buffer not empty'
exposes an incorrect assumption in several drivers' start_tx methods;
the tx ring buffer can, in fact, be empty when restarting tx while
performing flow control.
Affected drivers:
sunsab.c
ip22zilog.c
pmac_zilog.c
sunzilog.c
m32r_sio.c
imx.c
Other in-tree serial drivers either are not affected or already
test for empty tx ring buffer before transmitting.
Test for empty tx ring buffer in start_tx() method, after transmitting
x_char (if applicable).
Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Seth Bollinger <sethb@digi.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Cc: stable <stable@vger.kernel.org> # 3.15
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/serial/imx.c | 3 | ||||
-rw-r--r-- | drivers/tty/serial/ip22zilog.c | 2 | ||||
-rw-r--r-- | drivers/tty/serial/m32r_sio.c | 8 | ||||
-rw-r--r-- | drivers/tty/serial/pmac_zilog.c | 3 | ||||
-rw-r--r-- | drivers/tty/serial/sunsab.c | 3 | ||||
-rw-r--r-- | drivers/tty/serial/sunzilog.c | 2 |
6 files changed, 18 insertions, 3 deletions
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index e2f93874989b..56bd9aa56151 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c | |||
@@ -567,6 +567,9 @@ static void imx_start_tx(struct uart_port *port) | |||
567 | struct imx_port *sport = (struct imx_port *)port; | 567 | struct imx_port *sport = (struct imx_port *)port; |
568 | unsigned long temp; | 568 | unsigned long temp; |
569 | 569 | ||
570 | if (uart_circ_empty(&port.state->xmit)) | ||
571 | return; | ||
572 | |||
570 | if (USE_IRDA(sport)) { | 573 | if (USE_IRDA(sport)) { |
571 | /* half duplex in IrDA mode; have to disable receive mode */ | 574 | /* half duplex in IrDA mode; have to disable receive mode */ |
572 | temp = readl(sport->port.membase + UCR4); | 575 | temp = readl(sport->port.membase + UCR4); |
diff --git a/drivers/tty/serial/ip22zilog.c b/drivers/tty/serial/ip22zilog.c index 1efd4c36ba0c..99b7b8697861 100644 --- a/drivers/tty/serial/ip22zilog.c +++ b/drivers/tty/serial/ip22zilog.c | |||
@@ -603,6 +603,8 @@ static void ip22zilog_start_tx(struct uart_port *port) | |||
603 | } else { | 603 | } else { |
604 | struct circ_buf *xmit = &port->state->xmit; | 604 | struct circ_buf *xmit = &port->state->xmit; |
605 | 605 | ||
606 | if (uart_circ_empty(xmit)) | ||
607 | return; | ||
606 | writeb(xmit->buf[xmit->tail], &channel->data); | 608 | writeb(xmit->buf[xmit->tail], &channel->data); |
607 | ZSDELAY(); | 609 | ZSDELAY(); |
608 | ZS_WSYNC(channel); | 610 | ZS_WSYNC(channel); |
diff --git a/drivers/tty/serial/m32r_sio.c b/drivers/tty/serial/m32r_sio.c index 68f2c53e0b54..5702828fb62e 100644 --- a/drivers/tty/serial/m32r_sio.c +++ b/drivers/tty/serial/m32r_sio.c | |||
@@ -266,9 +266,11 @@ static void m32r_sio_start_tx(struct uart_port *port) | |||
266 | if (!(up->ier & UART_IER_THRI)) { | 266 | if (!(up->ier & UART_IER_THRI)) { |
267 | up->ier |= UART_IER_THRI; | 267 | up->ier |= UART_IER_THRI; |
268 | serial_out(up, UART_IER, up->ier); | 268 | serial_out(up, UART_IER, up->ier); |
269 | serial_out(up, UART_TX, xmit->buf[xmit->tail]); | 269 | if (!uart_circ_empty(xmit)) { |
270 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | 270 | serial_out(up, UART_TX, xmit->buf[xmit->tail]); |
271 | up->port.icount.tx++; | 271 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); |
272 | up->port.icount.tx++; | ||
273 | } | ||
272 | } | 274 | } |
273 | while((serial_in(up, UART_LSR) & UART_EMPTY) != UART_EMPTY); | 275 | while((serial_in(up, UART_LSR) & UART_EMPTY) != UART_EMPTY); |
274 | #else | 276 | #else |
diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c index 8193635103ee..f7ad5b903055 100644 --- a/drivers/tty/serial/pmac_zilog.c +++ b/drivers/tty/serial/pmac_zilog.c | |||
@@ -653,6 +653,8 @@ static void pmz_start_tx(struct uart_port *port) | |||
653 | } else { | 653 | } else { |
654 | struct circ_buf *xmit = &port->state->xmit; | 654 | struct circ_buf *xmit = &port->state->xmit; |
655 | 655 | ||
656 | if (uart_circ_empty(xmit)) | ||
657 | goto out; | ||
656 | write_zsdata(uap, xmit->buf[xmit->tail]); | 658 | write_zsdata(uap, xmit->buf[xmit->tail]); |
657 | zssync(uap); | 659 | zssync(uap); |
658 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | 660 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); |
@@ -661,6 +663,7 @@ static void pmz_start_tx(struct uart_port *port) | |||
661 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | 663 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) |
662 | uart_write_wakeup(&uap->port); | 664 | uart_write_wakeup(&uap->port); |
663 | } | 665 | } |
666 | out: | ||
664 | pmz_debug("pmz: start_tx() done.\n"); | 667 | pmz_debug("pmz: start_tx() done.\n"); |
665 | } | 668 | } |
666 | 669 | ||
diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c index 80a58eca785b..2f57df9a71d9 100644 --- a/drivers/tty/serial/sunsab.c +++ b/drivers/tty/serial/sunsab.c | |||
@@ -427,6 +427,9 @@ static void sunsab_start_tx(struct uart_port *port) | |||
427 | struct circ_buf *xmit = &up->port.state->xmit; | 427 | struct circ_buf *xmit = &up->port.state->xmit; |
428 | int i; | 428 | int i; |
429 | 429 | ||
430 | if (uart_circ_empty(xmit)) | ||
431 | return; | ||
432 | |||
430 | up->interrupt_mask1 &= ~(SAB82532_IMR1_ALLS|SAB82532_IMR1_XPR); | 433 | up->interrupt_mask1 &= ~(SAB82532_IMR1_ALLS|SAB82532_IMR1_XPR); |
431 | writeb(up->interrupt_mask1, &up->regs->w.imr1); | 434 | writeb(up->interrupt_mask1, &up->regs->w.imr1); |
432 | 435 | ||
diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c index a85db8b87156..02df3940b95e 100644 --- a/drivers/tty/serial/sunzilog.c +++ b/drivers/tty/serial/sunzilog.c | |||
@@ -703,6 +703,8 @@ static void sunzilog_start_tx(struct uart_port *port) | |||
703 | } else { | 703 | } else { |
704 | struct circ_buf *xmit = &port->state->xmit; | 704 | struct circ_buf *xmit = &port->state->xmit; |
705 | 705 | ||
706 | if (uart_circ_empty(xmit)) | ||
707 | return; | ||
706 | writeb(xmit->buf[xmit->tail], &channel->data); | 708 | writeb(xmit->buf[xmit->tail], &channel->data); |
707 | ZSDELAY(); | 709 | ZSDELAY(); |
708 | ZS_WSYNC(channel); | 710 | ZS_WSYNC(channel); |