From: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] debug uart: don't print before initialization
Date: Sun, 7 Oct 2018 19:52:11 +0200 [thread overview]
Message-ID: <20181007175211.6727-1-simon.k.r.goldschmidt@gmail.com> (raw)
At least on socfpga gen5, _debug_uart_putc() can be called
before debug_uart_init(), which leaves us stuck in an
infinite loop in the ns16550 debug uart driver.
Since this prevents debugging startup problems instead
of helping, let's add a field to 'gd' that prevents
calling the _debug_uart_putc() until debug_uart_init()
has been called.
Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
---
include/asm-generic/global_data.h | 3 +++
include/debug_uart.h | 19 ++++++++++++++-----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index c83fc01b76..9de7f48476 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -122,6 +122,9 @@ typedef struct global_data {
struct list_head log_head; /* List of struct log_device */
int log_fmt; /* Mask containing log format info */
#endif
+#ifdef CONFIG_DEBUG_UART
+ int debug_uart_initialized; /* No print before debug_uart_init */
+#endif
} gd_t;
#endif
diff --git a/include/debug_uart.h b/include/debug_uart.h
index 34e8b2fc81..4133c5612c 100644
--- a/include/debug_uart.h
+++ b/include/debug_uart.h
@@ -128,9 +128,12 @@ void printhex8(uint value);
\
static inline void _printch(int ch) \
{ \
- if (ch == '\n') \
- _debug_uart_putc('\r'); \
- _debug_uart_putc(ch); \
+ DECLARE_GLOBAL_DATA_PTR; \
+ if (gd->debug_uart_initialized) { \
+ if (ch == '\n') \
+ _debug_uart_putc('\r'); \
+ _debug_uart_putc(ch); \
+ } \
} \
\
void printch(int ch) \
@@ -146,8 +149,12 @@ void printhex8(uint value);
\
static inline void printhex1(uint digit) \
{ \
- digit &= 0xf; \
- _debug_uart_putc(digit > 9 ? digit - 10 + 'a' : digit + '0'); \
+ DECLARE_GLOBAL_DATA_PTR; \
+ if (gd->debug_uart_initialized) { \
+ digit &= 0xf; \
+ _debug_uart_putc(digit > 9 ? digit - 10 + 'a' : \
+ digit + '0'); \
+ } \
} \
\
static inline void printhex(uint value, int digits) \
@@ -173,8 +180,10 @@ void printhex8(uint value);
\
void debug_uart_init(void) \
{ \
+ DECLARE_GLOBAL_DATA_PTR; \
board_debug_uart_init(); \
_debug_uart_init(); \
+ gd->debug_uart_initialized = 1; \
_DEBUG_UART_ANNOUNCE \
} \
--
2.17.1
next reply other threads:[~2018-10-07 17:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-07 17:52 Simon Goldschmidt [this message]
2018-10-09 3:40 ` [U-Boot] [PATCH] debug uart: don't print before initialization Simon Glass
2018-10-09 5:06 ` Simon Goldschmidt
2018-10-10 13:28 ` Simon Goldschmidt
2018-10-10 20:03 ` Simon Glass
2018-10-10 20:16 ` Simon Goldschmidt
2018-10-17 20:02 ` Simon Goldschmidt
2018-10-19 3:25 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181007175211.6727-1-simon.k.r.goldschmidt@gmail.com \
--to=simon.k.r.goldschmidt@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox