mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2] console: flush consoles on newline when debugging
@ 2024-03-13 10:00 Ahmad Fatoum
  2024-03-13 11:38 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2024-03-13 10:00 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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>
---
v1 -> v2:
  - rename option to contain the prefix CONSOLE_
---
 common/Kconfig   | 12 ++++++++++++
 common/console.c |  5 ++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/common/Kconfig b/common/Kconfig
index 33903aa249b7..0000dac8740e 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -840,6 +840,16 @@ config CONSOLE_ALLOW_COLOR
 	  compile time default for colored console output. After boot it
 	  can be controlled using global.allow_color.
 
+config CONSOLE_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 CONSOLE_DISABLE_INPUT
 	prompt "Disable input on all consoles by default (non-interactive)"
 	def_bool CONSOLE_NONE
@@ -1705,6 +1715,7 @@ config DEBUG_AT91_UART_BASE
 
 config DEBUG_INITCALLS
 	bool "Trace initcalls"
+	select CONSOLE_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 CONSOLE_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..5a0fd66ab32d 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_CONSOLE_FLUSH_LINE_BREAK) && cdev->flush)
+				cdev->flush(cdev);
+		}
 
 		cdev->putc(cdev, *s);
 		s++;
-- 
2.39.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] console: flush consoles on newline when debugging
  2024-03-13 10:00 [PATCH v2] console: flush consoles on newline when debugging Ahmad Fatoum
@ 2024-03-13 11:38 ` Sascha Hauer
  2024-03-13 11:46   ` Ahmad Fatoum
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2024-03-13 11:38 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Wed, 13 Mar 2024 11:00:48 +0100, Ahmad Fatoum wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] console: flush consoles on newline when debugging
      https://git.pengutronix.de/cgit/barebox/commit/?id=50cbfd91b573 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] console: flush consoles on newline when debugging
  2024-03-13 11:38 ` Sascha Hauer
@ 2024-03-13 11:46   ` Ahmad Fatoum
  0 siblings, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-03-13 11:46 UTC (permalink / raw)
  To: Sascha Hauer, barebox

Hello Sascha,

On 13.03.24 12:38, Sascha Hauer wrote:
> 
> On Wed, 13 Mar 2024 11:00:48 +0100, Ahmad Fatoum wrote:
>> 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.

Thanks. I just noticed, I missed updating the message here
(CONSOLE_FLUSH_LINE_BREAK). Could you fix it?

Cheers,
Ahmad


>> The option is unnecessary outside of debugging, so for now we don't add
>> a prompt by default and select it as needed.
>>
>> [...]
> 
> Applied, thanks!
> 
> [1/1] console: flush consoles on newline when debugging
>       https://git.pengutronix.de/cgit/barebox/commit/?id=50cbfd91b573 (link may not be stable)
> 
> Best regards,

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-13 11:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-13 10:00 [PATCH v2] console: flush consoles on newline when debugging Ahmad Fatoum
2024-03-13 11:38 ` Sascha Hauer
2024-03-13 11:46   ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox