public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v3 5/6] serial: Call flush() before changing baudrate
Date: Mon,  5 Sep 2022 11:31:20 +0200	[thread overview]
Message-ID: <20220905093121.11630-6-pali@kernel.org> (raw)
In-Reply-To: <20220905093121.11630-1-pali@kernel.org>

Changing baudrate is a 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 <pali@kernel.org>
---
Changes in v3:
* Remove support from serial.c
* Fix commit message
---
 cmd/load.c                     | 5 +++++
 drivers/serial/serial-uclass.c | 1 +
 2 files changed, 6 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 f028da0900cd..04b753c229ab 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -476,6 +476,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;
-- 
2.20.1


  parent reply	other threads:[~2022-09-05  9:32 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-05  9:31 [PATCH v3 0/6] console: Implement flush() function Pali Rohár
2022-09-05  9:31 ` [PATCH v3 1/6] sandbox: Add function os_flush() Pali Rohár
2022-09-07 21:10   ` Simon Glass
2022-09-24 18:00   ` Tom Rini
2022-09-05  9:31 ` [PATCH v3 2/6] console: Implement flush() function Pali Rohár
2022-09-07 21:11   ` Simon Glass
2022-09-05  9:31 ` [PATCH v3 3/6] serial: Implement flush callback Pali Rohár
2022-09-05 17:24   ` Michael Nazzareno Trimarchi
2022-09-05 17:28     ` Pali Rohár
2022-09-07 21:11   ` Simon Glass
2022-09-05  9:31 ` [PATCH v3 4/6] serial: Implement serial_flush() function for console flush() fallback Pali Rohár
2022-09-07 21:10   ` Simon Glass
2022-09-20 21:40   ` Tom Rini
2022-09-20 22:18     ` Pali Rohár
2022-09-20 22:29       ` Tom Rini
2022-09-20 22:32         ` Pali Rohár
2022-09-20 22:46           ` Tom Rini
2022-09-05  9:31 ` Pali Rohár [this message]
2022-09-07 21:10   ` [PATCH v3 5/6] serial: Call flush() before changing baudrate Simon Glass
2022-09-05  9:31 ` [PATCH v3 6/6] boot: Call flush() before booting Pali Rohár
2022-09-07 21:10   ` Simon Glass
2022-09-07 21:14     ` Pali Rohár
2022-09-21 13:49 ` [PATCH v3 0/6] console: Implement flush() function Tom Rini
2022-09-21 13:54   ` Pali Rohár
2022-09-21 13:56     ` Tom Rini
2022-09-22 11:27       ` Simon Glass
2022-09-22 13:13         ` Heinrich Schuchardt
2022-09-22 13:14         ` Pali Rohár
2022-09-22 15:06           ` Heinrich Schuchardt
2022-09-23 15:45             ` Pali Rohár
2022-09-23 15:57               ` Tom Rini
2022-09-23 16:07                 ` Pali Rohár
2022-09-23 16:19                   ` Tom Rini
2022-09-24 14:01                     ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220905093121.11630-6-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox