From: "Marek Behún" <kabel@kernel.org>
To: Stefan Roese <sr@denx.de>
Cc: u-boot@lists.denx.de, "Pali Rohár" <pali@kernel.org>,
"Marek Behún" <marek.behun@nic.cz>
Subject: [PATCH u-boot-marvell 2/5] tools: kwboot: Do not call tcdrain() after each sent packet
Date: Wed, 27 Oct 2021 20:56:59 +0200 [thread overview]
Message-ID: <20211027185702.8186-3-kabel@kernel.org> (raw)
In-Reply-To: <20211027185702.8186-1-kabel@kernel.org>
From: Pali Rohár <pali@kernel.org>
Kwboot puts each xmodem packet to kernel queue, then waits until all bytes
of that packet are transmitted over UART and then waits for xmodem reply
until it is received into kernel queue.
If some reply is received during the time we are waiting until all bytes
are transmitted, then kernel puts them into the queue and returns it to
kwboot in next read() call.
So there is no need to wait (with tcdrain() function) until all bytes from
xmodem packet are transmitted over UART, since any reply received either
during that time or after is returned to kwboot with the next read().
Therefore do not call tcdrain() after each xmodem packet sent. Instead
directly wait for any reply after putting xmodem packet into write kernel
queue.
This change could speed up xmodem transfer in case tcdrain() function waits
for a longer time.
Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
---
tools/kwboot.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/tools/kwboot.c b/tools/kwboot.c
index b2c48812c3..a6bfd3d4ce 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -404,7 +404,7 @@ out:
}
static int
-kwboot_tty_send(int fd, const void *buf, size_t len)
+kwboot_tty_send(int fd, const void *buf, size_t len, int nodrain)
{
if (!buf)
return 0;
@@ -412,13 +412,16 @@ kwboot_tty_send(int fd, const void *buf, size_t len)
if (kwboot_write(fd, buf, len) < 0)
return -1;
+ if (nodrain)
+ return 0;
+
return tcdrain(fd);
}
static int
kwboot_tty_send_char(int fd, unsigned char c)
{
- return kwboot_tty_send(fd, &c, 1);
+ return kwboot_tty_send(fd, &c, 1, 0);
}
static speed_t
@@ -705,7 +708,7 @@ kwboot_bootmsg(int tty, void *msg)
break;
for (count = 0; count < 128; count++) {
- rc = kwboot_tty_send(tty, msg, 8);
+ rc = kwboot_tty_send(tty, msg, 8, 0);
if (rc) {
usleep(msg_req_delay * 1000);
continue;
@@ -737,7 +740,7 @@ kwboot_debugmsg(int tty, void *msg)
if (rc)
break;
- rc = kwboot_tty_send(tty, msg, 8);
+ rc = kwboot_tty_send(tty, msg, 8, 0);
if (rc) {
usleep(msg_req_delay * 1000);
continue;
@@ -929,7 +932,7 @@ kwboot_xm_sendblock(int fd, struct kwboot_block *block, int allow_non_xm,
retries = 0;
do {
- rc = kwboot_tty_send(fd, block, sizeof(*block));
+ rc = kwboot_tty_send(fd, block, sizeof(*block), 1);
if (rc)
return rc;
--
2.32.0
next prev parent reply other threads:[~2021-10-27 18:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-27 18:56 [PATCH u-boot-marvell 0/5] kwboot fix for AXP + some others Marek Behún
2021-10-27 18:56 ` [PATCH u-boot-marvell 1/5] tools: kwboot: Fix sending retry of last header packet Marek Behún
2021-11-03 5:37 ` Stefan Roese
2021-10-27 18:56 ` Marek Behún [this message]
2021-11-03 5:38 ` [PATCH u-boot-marvell 2/5] tools: kwboot: Do not call tcdrain() after each sent packet Stefan Roese
2021-10-27 18:57 ` [PATCH u-boot-marvell 3/5] tools: kwboot: Increase delay after changing baudrate in ARM code Marek Behún
2021-11-03 5:38 ` Stefan Roese
2021-10-27 18:57 ` [PATCH u-boot-marvell 4/5] tools: kwboot: Replace ARM mov + movt instruction pair by mov + orr Marek Behún
2021-11-03 5:38 ` Stefan Roese
2021-10-27 18:57 ` [PATCH u-boot-marvell 5/5] tools: kwboot: Do not use stack when setting baudrate back to default value Marek Behún
2021-11-03 5:38 ` Stefan Roese
2021-11-03 7:46 ` [PATCH u-boot-marvell 0/5] kwboot fix for AXP + some others Stefan Roese
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=20211027185702.8186-3-kabel@kernel.org \
--to=kabel@kernel.org \
--cc=marek.behun@nic.cz \
--cc=pali@kernel.org \
--cc=sr@denx.de \
--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