0015-ar71xx-make-bootconsole-wait-for-both-THRE-and-TEMT.patch 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Thu, 24 Mar 2016 18:30:26 +0100
  3. Subject: ar71xx: make bootconsole wait for both THRE and TEMT
  4. Original commit message:
  5. 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. diff --git a/target/linux/ar71xx/patches-3.18/103-MIPS-ath79-make-bootconsole-wait-for-both-THRE-and-T.patch b/target/linux/ar71xx/patches-3.18/103-MIPS-ath79-make-bootconsole-wait-for-both-THRE-and-T.patch
  20. new file mode 100644
  21. index 0000000..7be14ab
  22. --- /dev/null
  23. +++ b/target/linux/ar71xx/patches-3.18/103-MIPS-ath79-make-bootconsole-wait-for-both-THRE-and-T.patch
  24. @@ -0,0 +1,54 @@
  25. +From f1ba020af5076172c9d29006a747ccf40027fedc Mon Sep 17 00:00:00 2001
  26. +Message-Id: <f1ba020af5076172c9d29006a747ccf40027fedc.1458840219.git.mschiffer@universe-factory.net>
  27. +From: Matthias Schiffer <mschiffer@universe-factory.net>
  28. +Date: Thu, 24 Mar 2016 15:34:05 +0100
  29. +Subject: [PATCH] MIPS: ath79: make bootconsole wait for both THRE and TEMT
  30. +
  31. +This makes the ath79 bootconsole behave the same way as the generic 8250
  32. +bootconsole.
  33. +
  34. +Also waiting for TEMT (transmit buffer is empty) instead of just THRE
  35. +(transmit buffer is not full) ensures that all characters have been
  36. +transmitted before the real serial driver starts reconfiguring the serial
  37. +controller (which would sometimes result in garbage being transmitted.)
  38. +This change does not cause a visible performance loss.
  39. +
  40. +In addition, this seems to fix a hang observed in certain configurations on
  41. +many AR7xxx/AR9xxx SoCs during autoconfig of the real serial driver.
  42. +
  43. +A more complete follow-up patch will disable 8250 autoconfig for ath79
  44. +altogether (the serial controller is detected as a 16550A, which is not
  45. +fully compatible with the ath79 serial, and the autoconfig may lead to
  46. +undefined behavior on ath79.)
  47. +
  48. +Cc: <stable@vger.kernel.org>
  49. +Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
  50. +---
  51. + arch/mips/ath79/early_printk.c | 6 ++++--
  52. + 1 file changed, 4 insertions(+), 2 deletions(-)
  53. +
  54. +diff --git a/arch/mips/ath79/early_printk.c b/arch/mips/ath79/early_printk.c
  55. +index b955faf..d1adc59 100644
  56. +--- a/arch/mips/ath79/early_printk.c
  57. ++++ b/arch/mips/ath79/early_printk.c
  58. +@@ -31,13 +31,15 @@ static inline void prom_putchar_wait(void __iomem *reg, u32 mask, u32 val)
  59. + } while (1);
  60. + }
  61. +
  62. ++#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
  63. ++
  64. + static void prom_putchar_ar71xx(unsigned char ch)
  65. + {
  66. + void __iomem *base = (void __iomem *)(KSEG1ADDR(AR71XX_UART_BASE));
  67. +
  68. +- prom_putchar_wait(base + UART_LSR * 4, UART_LSR_THRE, UART_LSR_THRE);
  69. ++ prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY);
  70. + __raw_writel(ch, base + UART_TX * 4);
  71. +- prom_putchar_wait(base + UART_LSR * 4, UART_LSR_THRE, UART_LSR_THRE);
  72. ++ prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY);
  73. + }
  74. +
  75. + static void prom_putchar_ar933x(unsigned char ch)
  76. +--
  77. +2.7.4
  78. +