[PATCH] console: countdown: report who is interrupting

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Aug 6 01:12:03 PDT 2024


Fastboot and RATP automatically abort the boot countdown, so the user
can send more commands.

In cases where services talk either protocol unbeknownst to the user,
this can be very confusing, thus print an info message whenever this
happens.

Notably missing here is a printout when GPIO keys are triggered.
This is more complicated however, because getchar() only returns a
character without indication which console received it.
To debug such issues, the user can set global.autoboot_abort_key to
narrow down the culprit or enable CONFIG_INPUT_EVBUG.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 common/console_countdown.c  | 4 +++-
 common/fastboot.c           | 2 +-
 common/ratp/ratp.c          | 2 +-
 include/console_countdown.h | 2 +-
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/common/console_countdown.c b/common/console_countdown.c
index e41641aca23e..17f6fcd7aea7 100644
--- a/common/console_countdown.c
+++ b/common/console_countdown.c
@@ -13,8 +13,10 @@
 
 static bool console_countdown_timeout_abort;
 
-void console_countdown_abort(void)
+void console_countdown_abort(const char *reason)
 {
+	if (reason)
+		pr_info("\nCount down aborted by %s\n", reason);
 	console_countdown_timeout_abort = true;
 }
 
diff --git a/common/fastboot.c b/common/fastboot.c
index d283fc8fc098..532286703089 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -812,7 +812,7 @@ static void fb_run_command(struct fastboot *fb, const char *cmdbuf,
 	const struct cmd_dispatch_info *cmd;
 	int i;
 
-	console_countdown_abort();
+	console_countdown_abort("fastboot");
 
 	for (i = 0; i < num_commands; i++) {
 		cmd = &cmds[i];
diff --git a/common/ratp/ratp.c b/common/ratp/ratp.c
index fddb286e01bc..5cbdb8bd5f85 100644
--- a/common/ratp/ratp.c
+++ b/common/ratp/ratp.c
@@ -501,7 +501,7 @@ int barebox_ratp(struct console_device *cdev)
 
 	ctx->poller_registered = true;
 
-	console_countdown_abort();
+	console_countdown_abort("RATP");
 
 	console_set_active(&ctx->ratp_console, CONSOLE_STDOUT | CONSOLE_STDERR |
 			CONSOLE_STDIN);
diff --git a/include/console_countdown.h b/include/console_countdown.h
index df8da71e8bee..f4bebf755b44 100644
--- a/include/console_countdown.h
+++ b/include/console_countdown.h
@@ -9,6 +9,6 @@
 #define CONSOLE_COUNTDOWN_EXTERN (1 << 5)
 
 int console_countdown(int timeout_s, unsigned flags, const char *keys, char *out_key);
-void console_countdown_abort(void);
+void console_countdown_abort(const char *reason);
 
 #endif /* __CONSOLE_COUNTDOWN_H */
-- 
2.39.2




More information about the barebox mailing list