]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.13/mips-ath79-make-bootconsole-wait-for-both-thre-and-temt.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.13 / mips-ath79-make-bootconsole-wait-for-both-thre-and-temt.patch
CommitLineData
87d2113e
GKH
1From f5b556c94c8490d42fea79d7b4ae0ecbc291e69d Mon Sep 17 00:00:00 2001
2From: Matthias Schiffer <mschiffer@universe-factory.net>
3Date: Thu, 24 Mar 2016 16:02:52 +0100
4Subject: MIPS: ath79: make bootconsole wait for both THRE and TEMT
5
6From: Matthias Schiffer <mschiffer@universe-factory.net>
7
8commit f5b556c94c8490d42fea79d7b4ae0ecbc291e69d upstream.
9
10This makes the ath79 bootconsole behave the same way as the generic 8250
11bootconsole.
12
13Also waiting for TEMT (transmit buffer is empty) instead of just THRE
14(transmit buffer is not full) ensures that all characters have been
15transmitted before the real serial driver starts reconfiguring the serial
16controller (which would sometimes result in garbage being transmitted.)
17This change does not cause a visible performance loss.
18
19In addition, this seems to fix a hang observed in certain configurations on
20many AR7xxx/AR9xxx SoCs during autoconfig of the real serial driver.
21
22A more complete follow-up patch will disable 8250 autoconfig for ath79
23altogether (the serial controller is detected as a 16550A, which is not
24fully compatible with the ath79 serial, and the autoconfig may lead to
25undefined behavior on ath79.)
26
27Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
28Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
29Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
30
31---
32 arch/mips/ath79/early_printk.c | 6 ++++--
33 1 file changed, 4 insertions(+), 2 deletions(-)
34
35--- a/arch/mips/ath79/early_printk.c
36+++ b/arch/mips/ath79/early_printk.c
37@@ -31,13 +31,15 @@ static inline void prom_putchar_wait(voi
38 } while (1);
39 }
40
41+#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
42+
43 static void prom_putchar_ar71xx(unsigned char ch)
44 {
45 void __iomem *base = (void __iomem *)(KSEG1ADDR(AR71XX_UART_BASE));
46
47- prom_putchar_wait(base + UART_LSR * 4, UART_LSR_THRE, UART_LSR_THRE);
48+ prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY);
49 __raw_writel(ch, base + UART_TX * 4);
50- prom_putchar_wait(base + UART_LSR * 4, UART_LSR_THRE, UART_LSR_THRE);
51+ prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY);
52 }
53
54 static void prom_putchar_ar933x(unsigned char ch)