From patchwork Thu Aug 11 12:39:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1665522 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=FnkqAPqr; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M3RGg37HHz9s5W for ; Thu, 11 Aug 2022 22:40:09 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BD3DA8492C; Thu, 11 Aug 2022 14:39:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="FnkqAPqr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 315A78492C; Thu, 11 Aug 2022 14:39:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_FILL_THIS_FORM_SHORT,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 52236848B9 for ; Thu, 11 Aug 2022 14:39:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DE7B061456; Thu, 11 Aug 2022 12:39:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29C26C433C1; Thu, 11 Aug 2022 12:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660221590; bh=p9WVHtOFETOsCanD995sgo/+AD+bbfbmB/ZiDIn4yjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FnkqAPqr0WUmYzXQbYKzEtq7VexGnoOau3ATLVZ8X0nNkNLHdLQ0KBB8aik1rvUDr u++dUvQMUh9avU3X/qbc07VMhs9jGD16r+fHNiNcSXICDqFgTO0DbfwTzWbnMly9NT YNZ1FgEbaFy0YuMQ0q9M3tAJS11uWnYOeqK2zF9WgroAegxVcxlxjd8XR7eEH03oSO NYzGlyvHkSwJkdqU+OLg+Y317OoW3NJwzp5xHSs7qFLsCf5B4V7wcw6cKG1IJvA2ju 4k9wTXOi7PYsbXuOdMMxoudVHMu02IM572Af0REscV+FiGw+uoNLjkE6zqam1q+pVc 1QIv1x+TJq+jw== Received: by pali.im (Postfix) id 5EFAE2763; Thu, 11 Aug 2022 14:39:47 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH v2 1/6] sandbox: Add function os_flush() Date: Thu, 11 Aug 2022 14:39:20 +0200 Message-Id: <20220811123925.23981-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220811123925.23981-1-pali@kernel.org> References: <20220811123925.23981-1-pali@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean It flushes stdout. Signed-off-by: Pali Rohár Reviewed-by: Simon Glass --- arch/sandbox/cpu/os.c | 5 +++++ include/os.h | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index f937991139c9..01845e388d35 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -669,6 +669,11 @@ void os_puts(const char *str) os_putc(*str++); } +void os_flush(void) +{ + fflush(stdout); +} + int os_write_ram_buf(const char *fname) { struct sandbox_state *state = state_get_current(); diff --git a/include/os.h b/include/os.h index 148178787bc2..5b353ae9d94b 100644 --- a/include/os.h +++ b/include/os.h @@ -295,6 +295,14 @@ void os_putc(int ch); */ void os_puts(const char *str); +/** + * os_flush() - flush controlling OS terminal + * + * This bypasses the U-Boot console support and flushes directly the OS + * stdout file descriptor. + */ +void os_flush(void); + /** * os_write_ram_buf() - write the sandbox RAM buffer to a existing file * From patchwork Thu Aug 11 12:39:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1665528 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=oMVHK6U3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M3RHy3Y4sz9s5W for ; Thu, 11 Aug 2022 22:41:18 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A418A84957; Thu, 11 Aug 2022 14:40:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="oMVHK6U3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1742284926; Thu, 11 Aug 2022 14:39:59 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9407784919 for ; Thu, 11 Aug 2022 14:39:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 59EE761411; Thu, 11 Aug 2022 12:39:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BAE5C433B5; Thu, 11 Aug 2022 12:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660221590; bh=CzNUydB6dlDVVzKHD3gIG3OS9OZ/hTT/k9atirjbwBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oMVHK6U3Z+lUjE/4/9j9+/D8eCyr7JEZ7uPDTlksrsVFxLXIG+WhAH1OO+NQKL6A7 78niz5W7md6F8JN+EapbaGCKxAwln42JXyMVjcgta+cyxP3ywHVsp9+g9sni4Cql2s aERdDhYBN0Y6Cj86tcCdqJROQylhWqL/G1fmcnpp5+BF0y8rl/XHIja6/iIUAq/QLL Spsdqx7l/Hw9UibNpo6qYLixh0zE4+yMe1xSvIQiDW70ITucu386cGmn073J5AlEEl UYrr9q8VKB5DHckk0F2tttm3HA/Py+WD8xreKn781xymADXtOWAygXszNEbUqy7lnQ W3bJdeqipC2dQ== Received: by pali.im (Postfix) id C3F6F2765; Thu, 11 Aug 2022 14:39:47 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH v2 2/6] console: Implement flush() function Date: Thu, 11 Aug 2022 14:39:21 +0200 Message-Id: <20220811123925.23981-3-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220811123925.23981-1-pali@kernel.org> References: <20220811123925.23981-1-pali@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On certain places it is required to flush output print buffers to ensure that text strings were sent to console or serial devices. For example when printing message that U-Boot is going to boot kernel or when U-Boot is going to change baudrate of terminal device. Therefore introduce a new flush() and fflush() functions into console code. These functions will call .flush callback of associated stdio_dev device. As this function may increase U-Boot side, allow to compile U-Boot without this function. For this purpose there is a new config CONSOLE_FLUSH_SUPPORT which is enabled by default and can be disabled. It is a good idea to have this option enabled for all boards which have enough space for it. When option is disabled when U-Boot defines just empty static inline function fflush() to avoid ifdefs in other code. Signed-off-by: Pali Rohár --- common/Kconfig | 6 +++++ common/console.c | 63 +++++++++++++++++++++++++++++++++++++++++++++ include/_exports.h | 3 +++ include/stdio.h | 15 +++++++++++ include/stdio_dev.h | 4 +++ 5 files changed, 91 insertions(+) diff --git a/common/Kconfig b/common/Kconfig index e7914ca750a3..109741cc6c44 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -186,6 +186,12 @@ config PRE_CON_BUF_ADDR We should consider removing this option and allocating the memory in board_init_f_init_reserve() instead. +config CONSOLE_FLUSH_SUPPORT + bool "Enable console flush support" + default y + help + This enables compilation of flush() function for console flush support. + config CONSOLE_MUX bool "Enable console multiplexing" default y if DM_VIDEO || VIDEO || LCD diff --git a/common/console.c b/common/console.c index dc071f1ed665..42415e34d16f 100644 --- a/common/console.c +++ b/common/console.c @@ -198,6 +198,9 @@ static int console_setfile(int file, struct stdio_dev * dev) case stdout: gd->jt->putc = putc; gd->jt->puts = puts; +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT + gd->jt->flush = flush; +#endif gd->jt->printf = printf; break; } @@ -363,6 +366,19 @@ static void console_puts(int file, const char *s) } } +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT +static void console_flush(int file) +{ + int i; + struct stdio_dev *dev; + + for_each_console_dev(i, file, dev) { + if (dev->flush != NULL) + dev->flush(dev); + } +} +#endif + #if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV) static inline void console_doenv(int file, struct stdio_dev *dev) { @@ -412,6 +428,14 @@ static inline void console_puts(int file, const char *s) stdio_devices[file]->puts(stdio_devices[file], s); } +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT +static inline void console_flush(int file) +{ + if (stdio_devices[file]->flush) + stdio_devices[file]->flush(stdio_devices[file]); +} +#endif + #if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV) static inline void console_doenv(int file, struct stdio_dev *dev) { @@ -525,6 +549,14 @@ void fputs(int file, const char *s) console_puts(file, s); } +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT +void fflush(int file) +{ + if (file < MAX_FILES) + console_flush(file); +} +#endif + int fprintf(int file, const char *fmt, ...) { va_list args; @@ -731,6 +763,37 @@ void puts(const char *s) } } +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT +void flush(void) +{ + if (!gd) + return; + + /* sandbox can send characters to stdout before it has a console */ + if (IS_ENABLED(CONFIG_SANDBOX) && !(gd->flags & GD_FLG_SERIAL_READY)) { + os_flush(); + return; + } + + if (IS_ENABLED(CONFIG_DEBUG_UART) && !(gd->flags & GD_FLG_SERIAL_READY)) + return; + + if (IS_ENABLED(CONFIG_SILENT_CONSOLE) && (gd->flags & GD_FLG_SILENT)) + return; + + if (IS_ENABLED(CONFIG_DISABLE_CONSOLE) && (gd->flags & GD_FLG_DISABLE_CONSOLE)) + return; + + if (!gd->have_console) + return; + + if (gd->flags & GD_FLG_DEVINIT) { + /* Send to the standard output */ + fflush(stdout); + } +} +#endif + #ifdef CONFIG_CONSOLE_RECORD int console_record_init(void) { diff --git a/include/_exports.h b/include/_exports.h index f6df8b610734..1af946fac327 100644 --- a/include/_exports.h +++ b/include/_exports.h @@ -12,6 +12,9 @@ EXPORT_FUNC(tstc, int, tstc, void) EXPORT_FUNC(putc, void, putc, const char) EXPORT_FUNC(puts, void, puts, const char *) +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT + EXPORT_FUNC(flush, void, flush, void) +#endif EXPORT_FUNC(printf, int, printf, const char*, ...) #if (defined(CONFIG_X86) && !defined(CONFIG_X86_64)) || defined(CONFIG_PPC) EXPORT_FUNC(irq_install_handler, void, install_hdlr, diff --git a/include/stdio.h b/include/stdio.h index 1939a48f0fb6..3241e2d493fa 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -15,6 +15,11 @@ int tstc(void); defined(CONFIG_SPL_SERIAL)) void putc(const char c); void puts(const char *s); +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT +void flush(void); +#else +static inline void flush(void) {} +#endif int __printf(1, 2) printf(const char *fmt, ...); int vprintf(const char *fmt, va_list args); #else @@ -26,6 +31,10 @@ static inline void puts(const char *s) { } +static inline void flush(void) +{ +} + static inline int __printf(1, 2) printf(const char *fmt, ...) { return 0; @@ -48,11 +57,17 @@ static inline int vprintf(const char *fmt, va_list args) /* stderr */ #define eputc(c) fputc(stderr, c) #define eputs(s) fputs(stderr, s) +#define eflush() fflush(stderr) #define eprintf(fmt, args...) fprintf(stderr, fmt, ##args) int __printf(2, 3) fprintf(int file, const char *fmt, ...); void fputs(int file, const char *s); void fputc(int file, const char c); +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT +void fflush(int file); +#else +static inline void fflush(int file) {} +#endif int ftstc(int file); int fgetc(int file); diff --git a/include/stdio_dev.h b/include/stdio_dev.h index 270fa2729fb2..06278366ae88 100644 --- a/include/stdio_dev.h +++ b/include/stdio_dev.h @@ -37,6 +37,10 @@ struct stdio_dev { void (*putc)(struct stdio_dev *dev, const char c); /* To put a string (accelerator) */ void (*puts)(struct stdio_dev *dev, const char *s); +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT + /* To flush output queue */ + void (*flush)(struct stdio_dev *dev); +#endif /* INPUT functions */ From patchwork Thu Aug 11 12:39:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1665527 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=eoHwNQk7; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M3RHk2GBLz9s5W for ; Thu, 11 Aug 2022 22:41:06 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 93F878494A; Thu, 11 Aug 2022 14:40:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="eoHwNQk7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A0CB284927; Thu, 11 Aug 2022 14:40:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 107D184929 for ; Thu, 11 Aug 2022 14:39:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AB232B81F66; Thu, 11 Aug 2022 12:39:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8125C433D6; Thu, 11 Aug 2022 12:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660221591; bh=NzZPjYSynYm+bnCpiFJPgL2sn5prybThKOb2y7ZLxZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eoHwNQk7541TMfKmlubt+TxyHc28OrVJWdu+eIlBuDUQqZR0npmVfRiMskWhUnifU yo5BAY8IZXSFssJg9E6lvNVZ6PXLHzHksZVx65Dk2dgEpxcCqEf3etbaBHxctf+t9L 2ot/J00ueLwosxywW5BOvuYxMzwwVKjtBez9dFB7AoAkka5yKe5YskI5rlfcqFQhBW ZqibHD/AbL8aIsQgRBY2+hOrKksBfSXcV22vcH/uD/D2gdkMa0d0ARjIrw7+pPfWP6 Jv7wnLcMSkTAzHH1R1AiL1F8kZxdz3uv59mYawQKyOoVPUQoisoo3yBB94oZ3VbxoD UnIxH8ZXvsRjg== Received: by pali.im (Postfix) id 4674F2777; Thu, 11 Aug 2022 14:39:48 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH v2 3/6] serial: Implement flush callback Date: Thu, 11 Aug 2022 14:39:22 +0200 Message-Id: <20220811123925.23981-4-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220811123925.23981-1-pali@kernel.org> References: <20220811123925.23981-1-pali@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean UART drivers have putc/puts functions which just put characters into HW transmit queue and do not wait until all data are transmitted. Implement flush callback via serial driver's pending(false) callback which waits until HW transmit all characters from the queue. Signed-off-by: Pali Rohár Reviewed-by: Simon Glass --- drivers/serial/serial-uclass.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 4b7819fa473b..71ea88e31c9f 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -238,6 +238,18 @@ static void _serial_puts(struct udevice *dev, const char *str) } while (*str); } +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT +static void _serial_flush(struct udevice *dev) +{ + struct dm_serial_ops *ops = serial_get_ops(dev); + + if (!ops->pending) + return; + while (ops->pending(dev, false) > 0) + ; +} +#endif + static int __serial_getc(struct udevice *dev) { struct dm_serial_ops *ops = serial_get_ops(dev); @@ -412,6 +424,13 @@ static void serial_stub_puts(struct stdio_dev *sdev, const char *str) _serial_puts(sdev->priv, str); } +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT +static void serial_stub_flush(struct stdio_dev *sdev) +{ + _serial_flush(sdev->priv); +} +#endif + static int serial_stub_getc(struct stdio_dev *sdev) { return _serial_getc(sdev->priv); @@ -571,6 +590,9 @@ static int serial_post_probe(struct udevice *dev) sdev.priv = dev; sdev.putc = serial_stub_putc; sdev.puts = serial_stub_puts; +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT + sdev.flush = serial_stub_flush; +#endif sdev.getc = serial_stub_getc; sdev.tstc = serial_stub_tstc; From patchwork Thu Aug 11 12:39:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1665526 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=ERZ9PjIs; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M3RHV2vFFz9s5W for ; Thu, 11 Aug 2022 22:40:54 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 59D5B8493C; Thu, 11 Aug 2022 14:40:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="ERZ9PjIs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 87ED184927; Thu, 11 Aug 2022 14:39:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 175CF8492A for ; Thu, 11 Aug 2022 14:39:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B4942B81F6A; Thu, 11 Aug 2022 12:39:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AB36C43140; Thu, 11 Aug 2022 12:39:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660221591; bh=COivyKfD0deTjW8yQa9Q/Yb20efHqBjH3gxzB69H61U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ERZ9PjIs9ERONw1nZBdT9UW/cCuV/OIppzkgvBf3YgjRjloaji25VTXgyKG54E8lt KQm9HJlM3VyaS1i/5epUxZEbeMvPIFKshtiYiYl6LrgXztzqjE2YTAbOScCzUlu7Ic cVLgPFZVz+nHDU0dyRf++gb38SHOkF4WMocu4V60LhExViNI0dkn3NUkHt+vVr0AK3 1D6SUmW49N4oIk/Axfj4diI/OlbU2hHJwmzX/4EFdIY+lwKhGL81Obf+tGhUucY+33 KhSvg/1GkUa52Sv85J1+8j2w0PMWzBo2Oqb8TLGA+b7qtm73jYvYtNbpDm4PFkOv4u 3ybDwawJOvnAw== Received: by pali.im (Postfix) id C9C922779; Thu, 11 Aug 2022 14:39:48 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH v2 4/6] serial: Implement serial_flush() function for console flush() fallback Date: Thu, 11 Aug 2022 14:39:23 +0200 Message-Id: <20220811123925.23981-5-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220811123925.23981-1-pali@kernel.org> References: <20220811123925.23981-1-pali@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Like in all other console functions, implement also serial_flush() function as a fallback int console flush() function. Flush support is available only when config option CONSOLE_FLUSH_SUPPORT is enabled. So when it is disabled then provides just empty static inline function serial_flush(). Signed-off-by: Pali Rohár Reviewed-by: Simon Glass --- common/console.c | 3 +++ common/stdio.c | 10 ++++++++++ drivers/serial/serial-uclass.c | 10 ++++++++++ include/serial.h | 5 +++++ 4 files changed, 28 insertions(+) diff --git a/common/console.c b/common/console.c index 42415e34d16f..72ed7cd3b3b4 100644 --- a/common/console.c +++ b/common/console.c @@ -790,6 +790,9 @@ void flush(void) if (gd->flags & GD_FLG_DEVINIT) { /* Send to the standard output */ fflush(stdout); + } else { + /* Send directly to the handler */ + serial_flush(); } } #endif diff --git a/common/stdio.c b/common/stdio.c index 92161a0df87d..b49a02f16f46 100644 --- a/common/stdio.c +++ b/common/stdio.c @@ -87,6 +87,13 @@ static void stdio_serial_puts(struct stdio_dev *dev, const char *s) serial_puts(s); } +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT +static void stdio_serial_flush(struct stdio_dev *dev) +{ + serial_flush(); +} +#endif + static int stdio_serial_getc(struct stdio_dev *dev) { return serial_getc(); @@ -112,6 +119,9 @@ static void drv_system_init (void) dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT; dev.putc = stdio_serial_putc; dev.puts = stdio_serial_puts; +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT + dev.flush = stdio_serial_flush; +#endif dev.getc = stdio_serial_getc; dev.tstc = stdio_serial_tstc; stdio_register (&dev); diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 71ea88e31c9f..4e32270d4660 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -327,6 +327,16 @@ void serial_puts(const char *str) _serial_puts(gd->cur_serial_dev, str); } +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT +void serial_flush(void) +{ + if (!gd->cur_serial_dev) + return; + + _serial_flush(gd->cur_serial_dev); +} +#endif + int serial_getc(void) { if (!gd->cur_serial_dev) diff --git a/include/serial.h b/include/serial.h index e6051e0a7faf..4e951f0c5f52 100644 --- a/include/serial.h +++ b/include/serial.h @@ -386,6 +386,11 @@ void serial_setbrg(void); void serial_putc(const char ch); void serial_putc_raw(const char ch); void serial_puts(const char *str); +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT +void serial_flush(void); +#else +static inline void serial_flush(void) {} +#endif int serial_getc(void); int serial_tstc(void); From patchwork Thu Aug 11 12:39:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1665523 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=a9TonSJo; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M3RGq3G6Pz9s5W for ; Thu, 11 Aug 2022 22:40:19 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AF906848B9; Thu, 11 Aug 2022 14:40:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="a9TonSJo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7BF858492F; Thu, 11 Aug 2022 14:39:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A37688491D for ; Thu, 11 Aug 2022 14:39:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 32D1FB81F2E; Thu, 11 Aug 2022 12:39:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE9E7C43470; Thu, 11 Aug 2022 12:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660221590; bh=mMroyZe6sdFErnhLoS6lA4s4WCCWF/6Y/AFFQpeit3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a9TonSJoVqnDRsZ33IiTu79JNx75SCD4tsgemou55gbAXjf0sq3x1NKAM9Xee11hv 56Lvo/OXQJfk/zjCLbbL4M3ZiLC7gkf0Qfkws6FkxeB8YTMuC5dJn0/V3VKHJPOxhD Z1c6TImCLKNkRatevNoMsRer/C25yswGrSFb1K4eIcupHzPbcJYEfQFGiwjdMH/JbZ Tuuvd1OMoUsFj6ZYj/KE1Mj9F+NkjfH4FPskrW4lEnaQPaAgSVLzDemKvcC6n+CD9T pF9pFFFdDmu25J0kQY9cjTTvKwaLOE6kZbzBlY799w2yisYqXoB3x3VPlnhLDtU1zY z3f8JFRRQbHpw== Received: by pali.im (Postfix) id 4A97A277F; Thu, 11 Aug 2022 14:39:49 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH v2 5/6] serial: Call flush() before changing baudrate Date: Thu, 11 Aug 2022 14:39:24 +0200 Message-Id: <20220811123925.23981-6-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220811123925.23981-1-pali@kernel.org> References: <20220811123925.23981-1-pali@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Changing baudrate is sensitive operation. To ensure that U-Boot messages printed before changing baudrate are not lost, call new U-Boot console flush() function. Signed-off-by: Pali Rohár --- cmd/load.c | 5 +++++ drivers/serial/serial-uclass.c | 1 + drivers/serial/serial.c | 1 + 3 files changed, 7 insertions(+) diff --git a/cmd/load.c b/cmd/load.c index e44ae0d56b75..5c4f34781d45 100644 --- a/cmd/load.c +++ b/cmd/load.c @@ -83,6 +83,7 @@ static int do_load_serial(struct cmd_tbl *cmdtp, int flag, int argc, printf("## Switch baudrate to %d bps and press ENTER ...\n", load_baudrate); udelay(50000); + flush(); gd->baudrate = load_baudrate; serial_setbrg(); udelay(50000); @@ -126,6 +127,7 @@ static int do_load_serial(struct cmd_tbl *cmdtp, int flag, int argc, printf("## Switch baudrate to %d bps and press ESC ...\n", current_baudrate); udelay(50000); + flush(); gd->baudrate = current_baudrate; serial_setbrg(); udelay(50000); @@ -317,6 +319,7 @@ int do_save_serial(struct cmd_tbl *cmdtp, int flag, int argc, printf("## Switch baudrate to %d bps and press ESC ...\n", (int)current_baudrate); udelay(50000); + flush(); gd->baudrate = current_baudrate; serial_setbrg(); udelay(50000); @@ -471,6 +474,7 @@ static int do_load_serial_bin(struct cmd_tbl *cmdtp, int flag, int argc, printf("## Switch baudrate to %d bps and press ENTER ...\n", load_baudrate); udelay(50000); + flush(); gd->baudrate = load_baudrate; serial_setbrg(); udelay(50000); @@ -533,6 +537,7 @@ static int do_load_serial_bin(struct cmd_tbl *cmdtp, int flag, int argc, printf("## Switch baudrate to %d bps and press ESC ...\n", current_baudrate); udelay(50000); + flush(); gd->baudrate = current_baudrate; serial_setbrg(); udelay(50000); diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 4e32270d4660..0f6860d9100e 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -527,6 +527,7 @@ static int on_baudrate(const char *name, const char *value, enum env_op op, printf("## Switch baudrate to %d bps and press ENTER ...\n", baudrate); udelay(50000); + flush(); } gd->baudrate = baudrate; diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index 6cdbb89841c1..4b525b644928 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -81,6 +81,7 @@ static int on_baudrate(const char *name, const char *value, enum env_op op, printf("## Switch baudrate to %d" " bps and press ENTER ...\n", baudrate); udelay(50000); + flush(); } gd->baudrate = baudrate; From patchwork Thu Aug 11 12:39:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1665525 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=N9wh/GDd; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M3RHG4XcFz9s5W for ; Thu, 11 Aug 2022 22:40:42 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 826C384942; Thu, 11 Aug 2022 14:40:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="N9wh/GDd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 557E384925; Thu, 11 Aug 2022 14:39:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D09D384927 for ; Thu, 11 Aug 2022 14:39:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 832B26145B; Thu, 11 Aug 2022 12:39:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEA58C4347C; Thu, 11 Aug 2022 12:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660221590; bh=HZlpIrBAAWewAR0F54wNyHj7xHX6x7JhcPibUWMJk58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N9wh/GDdGLTLdee64Jq9UF5HYgdTijY8gcRuvD8ghy/qvQyXbNhRl0jLhQWTkqizE IToA4s+HL87iAyac60eJ2RSX3tWe5edKtNOL9QTuXNcSzxrcLOOJWUMJK0qTukZrtb sS9yqsUhkETH67q89Gd02rHti7LY7jRaRfTuYf3d2NNrcHUa5qRWmOw59vPnRRnWnd z9w+C3PUjEvK3gmHvWxf1rGOmhdIj+pfMA/s+sFU+0iX0wl4ZbYApptijVcNIQ84go OnN7vhIlBn8/MD2SCNU1rQKJt4ce6/o2lesLpiNV6owwvNvrhc+fVSmm4JxMaIPr+B eVhCKgDjMseIw== Received: by pali.im (Postfix) id B39422782; Thu, 11 Aug 2022 14:39:49 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH v2 6/6] boot: Call flush() before booting Date: Thu, 11 Aug 2022 14:39:25 +0200 Message-Id: <20220811123925.23981-7-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220811123925.23981-1-pali@kernel.org> References: <20220811123925.23981-1-pali@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean In lot of cases kernel resets UART HW. To ensure that U-Boot messages printed before booting kernel are not lost, call new U-Boot console flush() function. Signed-off-by: Pali Rohár Reviewed-by: Simon Glass --- boot/bootm_os.c | 1 + cmd/boot.c | 1 + cmd/elf.c | 2 ++ 3 files changed, 4 insertions(+) diff --git a/boot/bootm_os.c b/boot/bootm_os.c index f31820cd07ef..079224ce585b 100644 --- a/boot/bootm_os.c +++ b/boot/bootm_os.c @@ -303,6 +303,7 @@ static void do_bootvx_fdt(bootm_headers_t *images) #else printf("## Starting vxWorks at 0x%08lx\n", (ulong)images->ep); #endif + flush(); boot_jump_vxworks(images); diff --git a/cmd/boot.c b/cmd/boot.c index be67a5980de3..14839c1cedcc 100644 --- a/cmd/boot.c +++ b/cmd/boot.c @@ -32,6 +32,7 @@ static int do_go(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) addr = hextoul(argv[1], NULL); printf ("## Starting application at 0x%08lX ...\n", addr); + flush(); /* * pass address parameter as argv[0] (aka command name), diff --git a/cmd/elf.c b/cmd/elf.c index 2b33c50bd026..413d551dc05e 100644 --- a/cmd/elf.c +++ b/cmd/elf.c @@ -72,6 +72,7 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return rcode; printf("## Starting application at 0x%08lx ...\n", addr); + flush(); /* * pass address parameter as argv[0] (aka command name), @@ -274,6 +275,7 @@ int do_bootvx(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) puts("## Not an ELF image, assuming binary\n"); printf("## Starting vxWorks at 0x%08lx ...\n", addr); + flush(); dcache_disable(); #if defined(CONFIG_ARM64) && defined(CONFIG_ARMV8_PSCI)