From: Oliver Neukum <oneukum@suse.com>
To: "Robert Hodaszi" <robert.hodaszi@digi.com>,
"Oliver Neukum" <oneukum@suse.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"Bjørn Mork" <bjorn@mork.no>
Subject: Re: Handling incoming ZLP in cdc-wdm
Date: Wed, 2 Apr 2025 21:13:04 +0200 [thread overview]
Message-ID: <3296aaff-a591-4fcd-b421-9cfcc6291d2b@suse.com> (raw)
In-Reply-To: <8de930f3-2e87-443d-9e8f-9d6f16f7a399@digi.com>
On 02.04.25 17:01, Robert Hodaszi wrote:
>
> But we cannot return with -EAGAIN. If we do that, we're back to sqrt(1), and get stuck again.
Then we have a problem. If we are servicing a read() syscall,
we have to either return data, or, if we cannot do that
we either sleep or return -EAGAIN depending on O_NONBLOCK.
There is nothing we can do about that. This makes me think
that the issue here is poll() rather than in wdm_read()
> So what about modifying the service_interrupt_work to no simply set WDM_READ if resp_count is 0, but instead to check if there's any real message in the buffer, to not confuse consumers. Something like this:
That specific proposal will not work because the issue
is in service_interrupt_work() which can already be scheduled.
We cannot prevent that.
> diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
> index 37873acd18f4..9037379f3603 100644
> --- a/drivers/usb/class/cdc-wdm.c
> +++ b/drivers/usb/class/cdc-wdm.c
> @@ -1010,7 +1010,7 @@ static void service_interrupt_work(struct
> work_struct *work)
>
> spin_lock_irq(&desc->iuspin);
> service_outstanding_interrupt(desc);
> - if (!desc->resp_count) {
> + if (!desc->resp_count && (desc->length || desc->rerr)) {
> set_bit(WDM_READ, &desc->flags);
> wake_up(&desc->wait);
And what happens if wdm_read() wakes up because a signal is delivered?
Regards
Oliver
next prev parent reply other threads:[~2025-04-02 19:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-26 16:03 Handling incoming ZLP in cdc-wdm 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 [this message]
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
-- strict thread matches above, loose matches on Subject: below --
2025-03-26 15:50 Robert Hodaszi
2025-03-27 13:21 ` Oliver Neukum
2025-03-27 15:23 ` 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=3296aaff-a591-4fcd-b421-9cfcc6291d2b@suse.com \
--to=oneukum@suse.com \
--cc=bjorn@mork.no \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox