From 3c1e3e059d2816d82885c14e45206013950bebc6 Mon Sep 17 00:00:00 2001 From: Tony Dinh Date: Tue, 14 Mar 2023 17:24:26 -0700 Subject: [PATCH] console: Use flush() before panic and reset To make sure the panic and the reset messages will go out, console flush() should be used. Sleep periods do not work in early u-boot phase when timer driver is not initialized yet. Reference: https://lists.denx.de/pipermail/u-boot/2023-March/512233.html Signed-off-by: Tony Dinh Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- arch/arm/lib/reset.c | 4 ++-- lib/panic.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/arm/lib/reset.c b/arch/arm/lib/reset.c index 95169bae1c..3e051e36f1 100644 --- a/arch/arm/lib/reset.c +++ b/arch/arm/lib/reset.c @@ -25,6 +25,7 @@ #include #include #include +#include __weak void reset_misc(void) { @@ -33,8 +34,7 @@ __weak void reset_misc(void) int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { puts ("resetting ...\n"); - - mdelay(50); /* wait 50 ms */ + flush(); disable_interrupts(); diff --git a/lib/panic.c b/lib/panic.c index 58382ac4f4..66ae17f3df 100644 --- a/lib/panic.c +++ b/lib/panic.c @@ -15,6 +15,7 @@ #include #endif #include +#include static void panic_finish(void) __attribute__ ((noreturn)); @@ -24,7 +25,8 @@ static void panic_finish(void) #if defined(CONFIG_PANIC_HANG) hang(); #else - udelay(100000); /* allow messages to go out */ + flush(); /* flush the panic message before reset */ + do_reset(NULL, 0, 0, NULL); #endif while (1) -- 2.39.5