aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell Enderby <rte@gdn.net>2017-09-05 13:16:47 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-09-18 12:19:20 -0400
commit0e5ec4140c4a8a38c4ff7293c018eb7da69a30db (patch)
tree99d82c028fc3fe14592dc57b09eb386a76532e26
parent104583b504da8a3ad86d033b497cb6e58941a9a1 (diff)
serial: bcm63xx: fix timing issue.
Issue where unprintable characters can occur or output is cut off over the serial uart / linux console depending on timing. Problem occurs when changing the serial baud rate when setting up the new console.The bcm63xx driver does a disable and flush of the uart tx fifo while there is data still in the tx fifo. If the tx fifo still has data it is trying to send out, we need to wait until it is empty before disabling and flushing the uart. When we now go to change the uart parameters including speed we check if there is data currently in the tx fifo.If there is was mdelay(10) and check again.If it tries 3 times and still has data in it we just continue and sacrifice the tx fifo buffer. A cleaner and more preferred approach would be to remove : - spin_lock_irqsave() - bcm_uart_disable() - bcm_uart_flush() However it is not clear if the author put those in to fix another underlying issue.As a result this solution is a safer approach. Output before the fix: [0.306000] 14e00520.serial: ttyS0 at MMIO 0x14e00520 (irq = 9, base_baud = 1687500) is a° 0.315000] console[ttyS0] enabled Output verified after the fix: [0.315000] 14e00520.serial: ttyS0 at MMIO 0x14e00520 (irq = 9, base_baud = 1687500) is a bcm63xx_uart [0.334000] console[ttyS0] enabled Signed-off-by: Russell Enderby <rte@gdn.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/bcm63xx_uart.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c
index 583c9a0c7ecc..8c48c3784831 100644
--- a/drivers/tty/serial/bcm63xx_uart.c
+++ b/drivers/tty/serial/bcm63xx_uart.c
@@ -507,9 +507,14 @@ static void bcm_uart_set_termios(struct uart_port *port,
507{ 507{
508 unsigned int ctl, baud, quot, ier; 508 unsigned int ctl, baud, quot, ier;
509 unsigned long flags; 509 unsigned long flags;
510 int tries;
510 511
511 spin_lock_irqsave(&port->lock, flags); 512 spin_lock_irqsave(&port->lock, flags);
512 513
514 /* Drain the hot tub fully before we power it off for the winter. */
515 for (tries = 3; !bcm_uart_tx_empty(port) && tries; tries--)
516 mdelay(10);
517
513 /* disable uart while changing speed */ 518 /* disable uart while changing speed */
514 bcm_uart_disable(port); 519 bcm_uart_disable(port);
515 bcm_uart_flush(port); 520 bcm_uart_flush(port);