From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] console: flush consoles on newline when debugging
Date: Wed, 13 Mar 2024 10:40:25 +0100 [thread overview]
Message-ID: <20240313094025.3390337-1-a.fatoum@pengutronix.de> (raw)
For debugging hangs, CONFIG_DEBUG_PROBES and CONFIG_DEBUG_INITCALLS are
useful tools to pinpoint where the issue is. FOr issues that lock up the
SoC, their output can be misleading if we have bigger UART FIFO and not
all output has managed to make it out.
Add a new DEBUG_FLUSH_LINE_BREAK to make debugging this easier.
The option is unnecessary outside of debugging, so for now we don't add
a prompt by default and select it as needed.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/Kconfig | 12 ++++++++++++
common/console.c | 5 ++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/common/Kconfig b/common/Kconfig
index 33903aa249b7..6c0de894faf5 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1703,8 +1703,19 @@ config DEBUG_AT91_UART_BASE
Specify UART port base address on which barebox low-level
debug messages should be output.
+config DEBUG_FLUSH_LINE_BREAK
+ bool "Flush consoles on new line" if COMPILE_TEST
+ help
+ Many serial drivers configure and use hardware FIFOs as not to
+ delay the boot. When debuging some king of bugs, such as clock
+ issues that hang the SoC, this can falsify debugging output,
+ because the UART doesn't output a submitted message fully, before
+ the SoC hangs. This option will flush serial FIFOs when processing
+ the new line feed characters.
+
config DEBUG_INITCALLS
bool "Trace initcalls"
+ select DEBUG_FLUSH_LINE_BREAK
help
If enabled this will print initcall traces.
@@ -1719,6 +1730,7 @@ config DEBUG_PBL
config DEBUG_PROBES
bool "Trace driver probes/removes"
+ select DEBUG_FLUSH_LINE_BREAK
help
If enabled this will log driver probe and remove traces. If DEBUG_LL is enabled,
probes will be printed even before registering consoles. If it's disabled, they
diff --git a/common/console.c b/common/console.c
index 03b76b122b2b..9ca92a74a8f3 100644
--- a/common/console.c
+++ b/common/console.c
@@ -277,8 +277,11 @@ static int __console_puts(struct console_device *cdev, const char *s,
size_t i;
for (i = 0; i < nbytes; i++) {
- if (*s == '\n')
+ if (*s == '\n') {
cdev->putc(cdev, '\r');
+ if (IS_ENABLED(CONFIG_DEBUG_FLUSH_LINE_BREAK) && cdev->flush)
+ cdev->flush(cdev);
+ }
cdev->putc(cdev, *s);
s++;
--
2.39.2
reply other threads:[~2024-03-13 9:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240313094025.3390337-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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