From: Michal Pecio <michal.pecio@gmail.com>
To: Mathias Nyman <mathias.nyman@linux.intel.com>
Cc: Mathias Nyman <mathias.nyman@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org
Subject: Re: [PATCH v2] usb: xhci: Work around the ASM3142 bulk UVC bug
Date: Thu, 3 Dec 2026 17:56:10 +0100 [thread overview]
Message-ID: <20261203175610.7b941db3.michal.pecio@gmail.com> (raw)
In-Reply-To: <c5d7d8e2-3ad1-457b-ac6a-72377b2f9cb7@linux.intel.com>
On Thu, 3 Dec 2026 14:23:00 +0200, Mathias Nyman wrote:
> On 12/2/26 12:30, Michal Pecio wrote:
> > ASM3142 occasionally generates no event for a single-TRB bulk TD which
> > is directly followed by a Link TRB. This affects USB3 UVC devices and
> > makes them stop streaming within a few seconds with logs like:
> >
> > Event dma 0xffe5e000 for ep 6 comp_code 1 not part of TD at ffd0cfe0 - ffd0cfe0
> > Event dma 0xffe5e010 for ep 6 comp_code 1 not part of TD at ffd0cfe0 - ffd0cfe0
> > Event dma 0xffe5e020 for ep 6 comp_code 1 not part of TD at ffd0cfe0 - ffd0cfe0
> > Event dma 0xffe5e030 for ep 6 comp_code 1 not part of TD at ffd0cfe0 - ffd0cfe0
> >
> > Only one line appears if the Link TRB toggles cycle; it seems that the
> > HC fails to toggle its cycle state and stops processing queued TDs, but
> > it ignores cycle of the first TRB in the segment and produces an event.
> > If subsequent TRBs are stale and match the wrong cycle state, the whole
> > ring is executed again - reliably triggered by keeping 2 URBs queued.
> >
> > Regardless of cycle issues, the first event is always bogus - a canary
> > pattern written to the transfer buffer survives, while canary of the TD
> > which was passed silently is fully overwritten (short transfers appear
> > to mitigate this bug). The link target seems treated as chained to the
> > completed prior TD, although no chain bits exist anywhere on the ring.
>
> Could there have a been old chain bit set from previous cycle due to
> splitting last TD over the link?
Doesn't seem so. Following patch makes no difference, but it does have
the expected effect on storage:
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -3722,6 +3722,9 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
addr = (u64) urb->transfer_dma;
block_len = full_len;
}
+ if (num_trbs > 1)
+ xhci_err(xhci, "multi-trb on %d/%d\n", slot_id, ep_index);
+
ret = prepare_transfer(xhci, xhci->devs[slot_id],
ep_index, urb->stream_id,
num_trbs, urb, 0, mem_flags);
Besides, all these URBs are very boring. Five cyclically repeating
data buffers, all 15KB in size (16KB for the reporter's device) and
aligned. There is no reason for any chaining here.
Resubmission loop stops, so the ring can be inspected with debugfs:
[ 4488.879590] uvcvideo 19-2.2:1.0: Allocated 5 URB buffers of 15x1024 bytes each
[ 4494.171672] xhci_hcd 0000:0c:00.0: Event dma 0xffda8000 for ep 6 comp_code 1 not part of TD at ffda4fe0 - ffda4fe0, missed 1
[ 4494.171925] xhci_hcd 0000:0c:00.0: Event dma 0xffda8010 for ep 6 comp_code 1 not part of TD at ffda4fe0 - ffda4fe0, missed 2
[ 4494.172175] xhci_hcd 0000:0c:00.0: Event dma 0xffda8020 for ep 6 comp_code 1 not part of TD at ffda4fe0 - ffda4fe0, missed 3
[ 4494.172434] xhci_hcd 0000:0c:00.0: Event dma 0xffda8030 for ep 6 comp_code 1 not part of TD at ffda4fe0 - ffda4fe0, missed 4
0 0x00000000ffda4f50: Buffer 00000000ffbb8000 length 15360 TD size 0 intr 0 type 'Normal' flags b:i:I:c:s:I:e:c
0 0x00000000ffda4f60: Buffer 00000000ffbd0000 length 15360 TD size 0 intr 0 type 'Normal' flags b:i:I:c:s:I:e:c
0 0x00000000ffda4f70: Buffer 00000000ffbc0000 length 15360 TD size 0 intr 0 type 'Normal' flags b:i:I:c:s:I:e:c
0 0x00000000ffda4f80: Buffer 00000000ffbb0000 length 15360 TD size 0 intr 0 type 'Normal' flags b:i:I:c:s:I:e:c
0 0x00000000ffda4f90: Buffer 00000000ffbc8000 length 15360 TD size 0 intr 0 type 'Normal' flags b:i:I:c:s:I:e:c
0 0x00000000ffda4fa0: Buffer 00000000ffbb8000 length 15360 TD size 0 intr 0 type 'Normal' flags b:i:I:c:s:I:e:c
0 0x00000000ffda4fb0: Buffer 00000000ffbd0000 length 15360 TD size 0 intr 0 type 'Normal' flags b:i:I:c:s:I:e:c
0 0x00000000ffda4fc0: Buffer 00000000ffbc0000 length 15360 TD size 0 intr 0 type 'Normal' flags b:i:I:c:s:I:e:c
0 0x00000000ffda4fd0: Buffer 00000000ffbb0000 length 15360 TD size 0 intr 0 type 'Normal' flags b:i:I:c:s:I:e:c
0 0x00000000ffda4fe0: Buffer 00000000ffbc8000 length 15360 TD size 0 intr 0 type 'Normal' flags b:i:I:c:s:I:e:c
0 0x00000000ffda4ff0: LINK 00000000ffda8000 intr 0 type 'Link' flags i:c:t:c
1 0x00000000ffda8000: Buffer 00000000ffbb8000 length 15360 TD size 0 intr 0 type 'Normal' flags b:i:I:c:s:I:e:c
1 0x00000000ffda8010: Buffer 00000000ffbd0000 length 15360 TD size 0 intr 0 type 'Normal' flags b:i:I:c:s:I:e:c
1 0x00000000ffda8020: Buffer 00000000ffbc0000 length 15360 TD size 0 intr 0 type 'Normal' flags b:i:I:c:s:I:e:c
1 0x00000000ffda8030: Buffer 00000000ffbb0000 length 15360 TD size 0 intr 0 type 'Normal' flags b:i:I:c:s:I:e:c
1 0x00000000ffda8040: Buffer 00000000ffbd0000 length 15360 TD size 0 intr 0 type 'Normal' flags b:i:I:c:s:I:e:C <- old cycle
> Does giving the Link TRB to HW immediately after the last TRB help?
> i.e. always call inc_enq_past_link() .
I hoped it would, but no. Even a queue of over 3 segments forward,
likely well ahead of the HC's prefetcher, makes no difference.
> I noticed that the buffer in that last TRB ended at exactly 64k
> boundary, and was also max packet aligned. Was this true for all
> those cases where event is lost?
64K - not in the run above.
max_packet - not sure because UVC's URBs are max_packet-aligned.
> Would force-splitting a TD over the link TRB then be an option?
> Requires original 'last' TRB buffer size to be over a max packet.
Reducing TRB_MAX_BUFF_SIZE to 8KB limits the bug to unchained links,
so yes, this should work. But not sure if it's easier or better.
Still ends up wasting one TRB slot.
Also, 4.11.5.1:
A TD Fragment shall not span segments. Refer to section 4.11.7.1.
And, of course, 4.11.7.1 doesn't agree:
A TD Fragment should not span Transfer Ring Segments.
But then 6.2.3:
The requirement that TD Fragments shall not span Transfer Ring
Segments places a lower limit on the value of Average TRB Length.
TD Fragments must be aligned to burst payload (16KB for my device).
Make of it whatever you want. So far, packet alignment seems to have
been sufficient, at least to the extent of avoiding total breakage
(not sure about performance). But it's not clear if links unaligned
to burst payload are permitted at all.
Regards,
Michal
prev parent reply other threads:[~2026-12-03 16:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 9:12 [PATCH] usb: xhci: Work around the ASM3142 bulk UVC bug Michal Pecio
2026-12-02 9:21 ` sashiko-bot
2026-12-02 10:30 ` [PATCH v2] " Michal Pecio
2026-12-02 10:39 ` sashiko-bot
2026-12-03 12:23 ` Mathias Nyman
2026-12-03 16:56 ` Michal Pecio [this message]
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=20261203175610.7b941db3.michal.pecio@gmail.com \
--to=michal.pecio@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=mathias.nyman@linux.intel.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