mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolai Buchwitz <nb@tipi-net.de>
To: Michal Pecio <michal.pecio@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Steve Bayless <steve_bayless@keysight.com>,
	Guido Kiener <guido@kiener-muenchen.de>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Mathias Nyman <mathias.nyman@intel.com>
Subject: Re: [PATCH 0/4] usb: usbtmc: fix undersized high-speed bulk packets on xHCI
Date: Wed, 21 Oct 2026 09:42:28 +0200	[thread overview]
Message-ID: <5f7be4fcf5cb8c3b60e8acc5312d9980@tipi-net.de> (raw)
In-Reply-To: <20261021005654.23517441.michal.pecio@gmail.com>

Hi Michal

On 21.10.2026 00:56, Michal Pecio wrote:
> [...]

>> So this looks like the better fix. How would we want it gated, a USB
>> core quirk flag per device, or per controller?
> 
> [Cc Mathias]
> 
> Good question. Do you need this fixed in stable?

Would be nice, as I've also seen other reports of this issue with
Rigol / Siglent test equipment. Otherwise I can carry it for a while
in our tree.

> 
> Depending on regression risk maybe we could get away with no quirk
> flag at all. That's what ehci and dwc2 seem to do, which means that
> hopefully no device specifies illegal packet size while using 512.

They do. dwc2 just takes usb_endpoint_maxp() as is, and ehci even does
it on purpose, see qh_make():

         /* The USB spec says that high speed bulk endpoints
          * always use 512 byte maxpacket.  But some device
          * vendors decided to ignore that, and MSFT is happy
          * to help them do so.  So now people expect to use
          * such nonconformant devices with Linux too; sigh.
          */

So I'd suspect that Windows takes it as is too.

> 
> Other possible risk is some device doesn't truly care (no transfer
> is ever large enough to matter) and works with 512, but setting its
> requested packet size (needlessly) breaks some xHCI controller.
> 
> Such devices seem not very likely to exist, though more likely than
> the former kind, so I will try to test whether such xHCI breakage is
> possible. Preliminary results are encouraging: although several of
> my HCs reject packet size of 1024 or corrupt data, 64 is accepted by
> all but one. I haven't checked for corruption yet.

Thanks for testing!

> 
> I will also see if I can figure out what Windows does in such case,
> because doing the same thing as Windows may be the safest bet.

Sounds good to me. Doing the same as ehci/dwc2 (and maybe Windows)
feels like the cleanest option. Happy to test whatever you come up
with on BCM2711 and RP1 xHCI with the three devices here.

I can also check on Windows, but I'll need to look up how, as I'm not
really familiar with Windows internals anymore.

Given Guido's reply and the USBTMC spec (the host "should not send a
zero-length packet" if the last payload is wMaxPacketSize), I'll drop
the usbtmc series and work around the Rigol ZLP issue in our test
software instead.

>> >> The Rigols still have one issue I can't work around. They split
>> >> replies over 500 bytes into several transfers, and a follow-on
>> >> transfer that ends exactly on a packet boundary never arrives. Raw
>> >> libusb shows the same, so I guess it's another firmware bug. Should
>> >> be fine for most use cases though.
>> >
>> > What exactly is the sequence of URBs you see vs would want to see?
>> 
>> The Rigols split anything over 500 bytes into two transfers:
>> 
>>    REQUEST_DEV_DEP_MSG_IN #1
>>    IN: 8 x 64 bytes (12 byte header + 500 data), then a ZLP
>>    REQUEST_DEV_DEP_MSG_IN #2
>>    IN: header + the rest
>> 
>> That works fine, unless the second transfer happens to end exactly on
>> a 64 byte boundary (e.g. 640 bytes). Then the device just never
>> answers request #2 and the first IN times out. I also tried leaving
>> the ZLP from #1 pending until after request #2. That fixes the
>> boundary case, but then the device randomly ignores request #2
>> instead (roughly 1 in 5). Raw libusb behaves the same, also with
>> maxpacket 64 in xHCI, so I'm pretty sure it's just another firmware
>> bug. What I'd want to see is simply the second transfer arriving :)
> 
> Doesn't look like any obvious xHCI problem to me. Did it also happen
> with those USB2 controllers that you used previously?

Yes, it's pre-existing and also is present on dwc2, which is what we 
used
before. Replies up to 500 + 480 bytes are fine, but as soon as the 
second
transfer ends on a 64 byte boundary it times out, and some of the
missing data shows up later as garbage in the next reply ("wrong
MsgID: 79 != 2", 79 being the 'O' of RIGOL). So that's a firmware bug,
which I can work around in our application if needed.

The only real blocker is the strict maxpacket handling in xHCI. If it
could be relaxed to what dwc2 (and ehci) already do, that would help a
lot!

> [...]

Thanks,
Nicolai

  reply	other threads:[~2026-10-21  7:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 14:33 Nicolai Buchwitz
2026-10-20 14:33 ` [PATCH 1/4] usb: usbtmc: handle undersized high-speed bulk IN packets Nicolai Buchwitz
2026-10-20 14:33 ` [PATCH 2/4] usb: usbtmc: handle undersized high-speed bulk OUT packets Nicolai Buchwitz
2026-10-20 14:33 ` [PATCH 3/4] usb: usbtmc: add Rigol DP800 and DS1000Z to the packet I/O quirk table Nicolai Buchwitz
2026-10-20 14:33 ` [PATCH 4/4] usb: usbtmc: send a ZLP after a full last packet in packet I/O mode Nicolai Buchwitz
2026-10-20 16:42 ` [PATCH 0/4] usb: usbtmc: fix undersized high-speed bulk packets on xHCI Michal Pecio
2026-10-20 18:33   ` Nicolai Buchwitz
2026-10-20 21:12     ` guido
2026-10-21  7:46       ` Nicolai Buchwitz
2026-10-21 12:29         ` Guido Kiener
2026-10-20 22:56     ` Michal Pecio
2026-10-21  7:42       ` Nicolai Buchwitz [this message]
2026-10-21  9:34       ` Nicolai Buchwitz

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=5f7be4fcf5cb8c3b60e8acc5312d9980@tipi-net.de \
    --to=nb@tipi-net.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=guido@kiener-muenchen.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=michal.pecio@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=steve_bayless@keysight.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

all inboxes | Powered by JetHome®