All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: Robert Hodaszi <robert.hodaszi@digi.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: Handling incoming ZLP in cdc-wdm
Date: Thu, 27 Mar 2025 14:24:53 +0100	[thread overview]
Message-ID: <dc8500a8-df6a-45d4-8ce3-1dad4b8f2413@suse.com> (raw)
In-Reply-To: <ade69712-836c-4cd9-ba79-79b2d97fba83@digi.com>

Hi,

On 27.03.25 14:01, Robert Hodaszi wrote:

>>
> Following on this: returning 0 bytes for read would kill libqmi, as that handles that as an error as well ("connection broken").
> 
> So what about this patch?
> 
>      diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
>      index 86ee39db013f..37873acd18f4 100644
>      --- a/drivers/usb/class/cdc-wdm.c
>      +++ b/drivers/usb/class/cdc-wdm.c
>      @@ -214,6 +214,11 @@ static void wdm_in_callback(struct urb *urb)
>              if (desc->rerr == 0 && status != -EPIPE)
>                      desc->rerr = status;
>       
>      +       if (length == 0) {
>      +               dev_dbg(&desc->intf->dev, "received ZLP\n");
>      +               goto skip_error;
>      +       }
>      +
>              if (length + desc->length > desc->wMaxCommand) {
>                      /* The buffer would overflow */
>                      set_bit(WDM_OVERFLOW, &desc->flags);
>      @@ -227,10 +232,10 @@ static void wdm_in_callback(struct urb *urb)
>              }
>       skip_error:
>       
>      -       if (desc->rerr) {
>      +       if (desc->rerr || length == 0) {
>                      /*
>      -                * Since there was an error, userspace may decide to not read
>      -                * any data after poll'ing.
>      +                * If there was a ZLP or an error, userspace may decide to not
>      +                * read any data after poll'ing.
>                       * We should respond to further attempts from the device to send
>                       * data, so that we can get unstuck.
>                       */

Why do you wish to react to this like an error?
It seems to me that we indeed need to wait for the device in this case.

	Regards
		Oliver


  reply	other threads:[~2025-03-27 13:24 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 [this message]
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
  -- 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=dc8500a8-df6a-45d4-8ce3-1dad4b8f2413@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.