From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79F7FECAAD5 for ; Mon, 5 Sep 2022 09:31:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CE5B98485F; Mon, 5 Sep 2022 11:31:47 +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="hpbRUIEs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 46384848A9; Mon, 5 Sep 2022 11:31:45 +0200 (CEST) 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 775A280517 for ; Mon, 5 Sep 2022 11:31:42 +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 1A0E06119A; Mon, 5 Sep 2022 09:31:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B0D6C433D6; Mon, 5 Sep 2022 09:31:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662370300; bh=W5R2kK2zQMuctqGhl16SOxRDuvgNHO5fUtOJHHVnJwE=; h=From:To:Cc:Subject:Date:From; b=hpbRUIEs6gwUx5wF2UYKquD6Q072RmP2Z/p6rt+bn64jhBnXW0I3OU2EmP9w955dx pxcjS6ay/zTFQx+HbbmhPxtS2X7Qe6DreJIG4+5Esgsm1N/PLXWYFohOKekOP0CG2C uJWrTEkBqIlqtXoIwh6zRohInMJsqKDG1YpOYvU3k1Ykb5oEMzv4lmy0SEqXfJ+M5h QEls3purw2IYvbbQpmXAKdSKOBAkZhnbKiPx53ydXi5t8dRFqN3wiPfH+QxXS529/R 7rwmwTw4CApVvzavknHT0ov/NcaVPbekWTEaSQaVtcHxUBmYuRF9fkQUoix429q1T1 YLZkn2PwgC83Q== Received: by pali.im (Postfix) id 8C30E7D7; Mon, 5 Sep 2022 11:31:37 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH v3 0/6] console: Implement flush() function Date: Mon, 5 Sep 2022 11:31:15 +0200 Message-Id: <20220905093121.11630-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Some console devices, like UART, have putc/puts functions which just put characters into HW transmit queue and do not wait until all data are transmitted. Doing some sensitive operations (like changing baudrate or starting kernel which resets UART HW) cause that U-Boot messages are lost. Therefore introduce a new flush() function, implement it for all serial devices via pending(false) callback and use this new flush() function on sensitive places after which output device may go into reset state. This change fixes printing of U-Boot messages: "## Starting application at ..." "## Switch baudrate to ..." Changes in v3: * add macro STDIO_DEV_ASSIGN_FLUSH() * fix commit messages * remove changes from serial.c Changes in v2: * split one big patch into smaller 6 patches * add config option to allow disabling this new function Pali Rohár (6): sandbox: Add function os_flush() console: Implement flush() function serial: Implement flush callback serial: Implement serial_flush() function for console flush() fallback serial: Call flush() before changing baudrate boot: Call flush() before booting arch/sandbox/cpu/os.c | 5 +++ boot/bootm_os.c | 1 + cmd/boot.c | 1 + cmd/elf.c | 2 ++ cmd/load.c | 5 +++ common/Kconfig | 6 ++++ common/console.c | 64 ++++++++++++++++++++++++++++++++++ common/stdio.c | 8 +++++ drivers/serial/serial-uclass.c | 31 ++++++++++++++++ include/_exports.h | 3 ++ include/os.h | 8 +++++ include/serial.h | 5 +++ include/stdio.h | 15 ++++++++ include/stdio_dev.h | 7 ++++ 14 files changed, 161 insertions(+) -- 2.20.1