提交 cab817d2 编写于 作者: P Pali Rohár 提交者: Stefan Roese

tools: kwboot: Do not call tcdrain() after each sent packet

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: NPali Rohár <pali@kernel.org>
Reviewed-by: NMarek Behún <marek.behun@nic.cz>
Reviewed-by: NStefan Roese <sr@denx.de>
上级 455c0d22
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册