From: "Pali Rohár" <pali@kernel.org>
To: u-boot@lists.denx.de
Subject: [PATCH 1/4] serial: usbtty: Send urb data in correct order
Date: Sat, 26 Dec 2020 19:28:48 +0100 [thread overview]
Message-ID: <20201226182851.18493-2-pali@kernel.org> (raw)
In-Reply-To: <20201226182851.18493-1-pali@kernel.org>
Function next_urb() selects the last urb data buffer from linked list to
which next data from usbtty puts should be appended.
But to check if TX data still exists it is needed to look at the first urb
data buffer from linked list. So check for endpoint->tx_urb (first from the
linked list) instead of current_urb (the last from the linked list).
Successful call to udc_endpoint_write() may invalidate active urb and
allocate new in queue which invalidate pointer returned by next_urb()
function.
So call next_urb() prior putting data into urb buffer and call it every
time after using udc_endpoint_write() function to prevent sending data from
usbtty puts in incorrect order.
This patch fixes issue that usbtty code does not transmit data when they
are waiting in the tx queue.
Signed-off-by: Pali Roh?r <pali@kernel.org>
---
drivers/serial/usbtty.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/serial/usbtty.c b/drivers/serial/usbtty.c
index 02f8edf200..4f4eb02de0 100644
--- a/drivers/serial/usbtty.c
+++ b/drivers/serial/usbtty.c
@@ -849,17 +849,9 @@ static int write_buffer (circbuf_t * buf)
&endpoint_instance[tx_endpoint];
struct urb *current_urb = NULL;
- current_urb = next_urb (device_instance, endpoint);
-
- if (!current_urb) {
- TTYERR ("current_urb is NULL, buf->size %d\n",
- buf->size);
- return 0;
- }
-
/* TX data still exists - send it now
*/
- if(endpoint->sent < current_urb->actual_length){
+ if(endpoint->sent < endpoint->tx_urb->actual_length){
if(udc_endpoint_write (endpoint)){
/* Write pre-empted by RX */
return -1;
@@ -878,6 +870,8 @@ static int write_buffer (circbuf_t * buf)
*/
while (buf->size > 0) {
+ current_urb = next_urb (device_instance, endpoint);
+
dest = (char*)current_urb->buffer +
current_urb->actual_length;
--
2.20.1
next prev parent reply other threads:[~2020-12-26 18:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-26 18:28 [PATCH 0/4] usbtty/musb: Fix file transfers Pali Rohár
2020-12-26 18:28 ` Pali Rohár [this message]
2020-12-26 18:28 ` [PATCH 2/4] usb: musb: Fix receiving of bigger buffers Pali Rohár
2020-12-26 18:28 ` [PATCH 3/4] usb: musb: Fix handling interrupts for EP0 and SET ADDRESS commmand Pali Rohár
2021-01-23 15:16 ` Lukasz Majewski
2021-01-23 15:23 ` Pali Rohár
2021-01-23 21:23 ` Lukasz Majewski
2021-01-23 21:28 ` Pali Rohár
2020-12-26 18:28 ` [PATCH 4/4] usb: musb: Ensure that we set musb dynamic FIFO buffer for every endpoint Pali Rohár
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=20201226182851.18493-2-pali@kernel.org \
--to=pali@kernel.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