003-MIPS-ath79-make-bootconsole-wait-for-both-THRE-and-T.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From f1ba020af5076172c9d29006a747ccf40027fedc Mon Sep 17 00:00:00 2001
  2. Message-Id: <f1ba020af5076172c9d29006a747ccf40027fedc.1458840219.git.mschiffer@universe-factory.net>
  3. From: Matthias Schiffer <mschiffer@universe-factory.net>
  4. Date: Thu, 24 Mar 2016 15:34:05 +0100
  5. Subject: [PATCH] MIPS: ath79: make bootconsole wait for both THRE and TEMT
  6. This makes the ath79 bootconsole behave the same way as the generic 8250
  7. bootconsole.
  8. Also waiting for TEMT (transmit buffer is empty) instead of just THRE
  9. (transmit buffer is not full) ensures that all characters have been
  10. transmitted before the real serial driver starts reconfiguring the serial
  11. controller (which would sometimes result in garbage being transmitted.)
  12. This change does not cause a visible performance loss.
  13. In addition, this seems to fix a hang observed in certain configurations on
  14. many AR7xxx/AR9xxx SoCs during autoconfig of the real serial driver.
  15. A more complete follow-up patch will disable 8250 autoconfig for ath79
  16. altogether (the serial controller is detected as a 16550A, which is not
  17. fully compatible with the ath79 serial, and the autoconfig may lead to
  18. undefined behavior on ath79.)
  19. Cc: <stable@vger.kernel.org>
  20. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
  21. ---
  22. arch/mips/ath79/early_printk.c | 6 ++++--
  23. 1 file changed, 4 insertions(+), 2 deletions(-)
  24. diff --git a/arch/mips/ath79/early_printk.c b/arch/mips/ath79/early_printk.c
  25. index b955faf..d1adc59 100644
  26. --- a/arch/mips/ath79/early_printk.c
  27. +++ b/arch/mips/ath79/early_printk.c
  28. @@ -31,13 +31,15 @@ static inline void prom_putchar_wait(void __iomem *reg, u32 mask, u32 val)
  29. } while (1);
  30. }
  31. +#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
  32. +
  33. static void prom_putchar_ar71xx(unsigned char ch)
  34. {
  35. void __iomem *base = (void __iomem *)(KSEG1ADDR(AR71XX_UART_BASE));
  36. - prom_putchar_wait(base + UART_LSR * 4, UART_LSR_THRE, UART_LSR_THRE);
  37. + prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY);
  38. __raw_writel(ch, base + UART_TX * 4);
  39. - prom_putchar_wait(base + UART_LSR * 4, UART_LSR_THRE, UART_LSR_THRE);
  40. + prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY);
  41. }
  42. static void prom_putchar_ar933x(unsigned char ch)
  43. --
  44. 2.7.4