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 4D92FC19F2A for ; Thu, 11 Aug 2022 12:40:29 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C52AE8492F; Thu, 11 Aug 2022 14:40:10 +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="mbr5dZ8j"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C77FF84906; Thu, 11 Aug 2022 14:39:57 +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 59ED284906 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 DB45461455; Thu, 11 Aug 2022 12:39:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29D13C433D7; 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=swCcmPIcgjTk2NlM4xTCCOIzam4rVHxkUaIEPXk16HE=; h=From:To:Cc:Subject:Date:From; b=mbr5dZ8juqsEntZy11koum7uwcellLROa2w8MQhuSan4EtBdE7siN8EhK5lr24Quj ZKGUgxD2Sc+g5WRKFmUOmm1cNTnwPZ1TexVYaMyhiTQHo8/eEhLlxR6FRufhyVFc4A d4P4AGNo00avBhRqUrjeX1f3FrQo/FXOWb0RvZ/VED1rFxaC1yMCeCUbRJr9xO4n0v ucXBs/AHrmfHsUdINI/BibbeAnZX3JfhTKZg2A+L0cHo7UPkO/5zGf9kyXbYWWQE/M +N7mBunJWoK+9ka4qcxyl1fTSaZoatjMCLd5WbQI0gZKzmAQ5n+DN5+zdmbjAEkGB/ ta/R0MLfdqAzQ== Received: by pali.im (Postfix) id 0A4A0C06; Thu, 11 Aug 2022 14:39:47 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH v2 0/6] console: Implement flush() function Date: Thu, 11 Aug 2022 14:39:19 +0200 Message-Id: <20220811123925.23981-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 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 | 66 ++++++++++++++++++++++++++++++++++ common/stdio.c | 10 ++++++ drivers/serial/serial-uclass.c | 33 +++++++++++++++++ drivers/serial/serial.c | 1 + include/_exports.h | 3 ++ include/os.h | 8 +++++ include/serial.h | 5 +++ include/stdio.h | 15 ++++++++ include/stdio_dev.h | 4 +++ 15 files changed, 165 insertions(+) -- 2.20.1