From: Oliver Neukum <oneukum@suse.com>
To: Robert Hodaszi <robert.hodaszi@digi.com>, linux-usb@vger.kernel.org
Subject: Re: Handling incoming ZLP in cdc-wdm
Date: Thu, 27 Mar 2025 14:21:18 +0100 [thread overview]
Message-ID: <42118b9b-7aa1-4559-824a-2c2ec70ea7d8@suse.com> (raw)
In-Reply-To: <cc40e75d-1a7c-424a-8edb-3ae17bfd1462@digi.com>
[-- Attachment #1: Type: text/plain, Size: 766 bytes --]
Hi,
On 26.03.25 16:50, Robert Hodaszi wrote:
> The problem is, wdm_poll() always return with EPOLLIN even when wdm_in_callback() receives a ZLP, as it sets WDM_READ. So it makes sense for glib to think, there's a pending packet. In wdm_read(), if the packet's length is 0 (desc->length = 0) and WDM_READ is set, we reach
>
> if (!desc->length)
>
> line, where it puts out another URB (as the resp_count is not 0), clear WDM_READ and go back to "retry". The second time we test WDM_READ, it is obviously not set yet, and as we are reading non-blocking, the function returns with EAGAIN.
Arguably the interrupt handler should set the flag for a readable result only
if indeed there is data in the buffer. Could you try the attached patch?
Regards
Oliver
[-- Attachment #2: 0001-usb-cdc-wdm-check-for-zero-length-response.patch --]
[-- Type: text/x-patch, Size: 834 bytes --]
From 47311e34cad1cc13ab5d2fbae239f188a6e82c1d Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneukum@suse.com>
Date: Thu, 27 Mar 2025 14:17:45 +0100
Subject: [PATCH] usb: cdc-wdm: check for zero length response
We should not indicate that there's a response if we have no
data in the buffer.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
drivers/usb/class/cdc-wdm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 86ee39db013f..856488a7cb6b 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -236,6 +236,8 @@ static void wdm_in_callback(struct urb *urb)
*/
schedule_work(&desc->service_outs_intr);
} else {
+ if (!desc->length)
+ goto out;
set_bit(WDM_READ, &desc->flags);
wake_up(&desc->wait);
}
--
2.49.0
next prev parent reply other threads:[~2025-03-27 13:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-26 15:50 Handling incoming ZLP in cdc-wdm Robert Hodaszi
2025-03-27 13:21 ` Oliver Neukum [this message]
2025-03-27 15:23 ` Robert Hodaszi
-- strict thread matches above, loose matches on Subject: below --
2025-03-26 16:03 Hodaszi, Robert
2025-03-27 13:01 ` Robert Hodaszi
2025-03-27 13:24 ` Oliver Neukum
2025-03-27 15:27 ` Robert Hodaszi
2025-03-31 9:59 ` Oliver Neukum
2025-04-02 11:57 ` Robert Hodaszi
2025-04-02 14:01 ` Oliver Neukum
2025-04-02 15:01 ` Robert Hodaszi
2025-04-02 19:13 ` Oliver Neukum
2025-04-03 12:25 ` Robert Hodaszi
[not found] ` <898977f7-3882-4ffe-8833-c44f06914337@digi.com>
2025-04-03 12:58 ` Oliver Neukum
2025-04-03 14:42 ` Robert Hodaszi
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=42118b9b-7aa1-4559-824a-2c2ec70ea7d8@suse.com \
--to=oneukum@suse.com \
--cc=linux-usb@vger.kernel.org \
--cc=robert.hodaszi@digi.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.