From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796316970; b=gUk6BPuHfna/l0wDNOaTGHrRv1TFs1M6ZIzHKcQtd92V3xx+GzWjxEGC+HqPrvM3Mm+O 96N+GeJfu/ADEv9+pIDBT8SNyfr/fsPbzFrYsFM1qf7XzgQjf66lrhgSioyZHMmUusfTm y3kbwiYUAwgocR4oZz9vDJis1Re96jmfwGxqY7KG+FrnYcSVNEktEsGI0R94n4pV3qI1k OcQ+TJAeCdCtl0DYy9WRxhfnJmSARzVRkA2uU0E0i3ZoCgN/uAebzaexrg+1Fhcm0BRlL BrFb6A+5uoTrlKBWD+srjJsU80phLNnvM6iM5EEUg0rROu7o038RLb2OmEc6unxNL+w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796316970; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=5qlculokp6Lzv3SNmAh6UxKQglFmReE7R+MKZAC7i+4=; b=G0eKEwaiN5R5VlHdZmmgJqhzM/6pC9a0l62xqK3hRgjfPBquAtTRBbfchf4b0qj4U9fp 6EMITouIJNy4ahBJsyg9Ue4Txo18O8CIGuBBLbsQ+Zncdqs6A7AUtaOZV1VJGjmii+Fl4 2yc4PUDoaF5O6F4YGsYIsJsXrRmp0EEYG/n0uObxIjKMnG5EoCAB6XPNJXp3vTocBhovF MnWNfQ+F5RUhlkPQ8veV2lpyWZqOmhXWlCbRdhcD2h4+nE9ahqbE/CY2egdc5Wrz6h1rV 9Zi6QSUHvjQ6INlTYXVnh+f35mzZNUDKwGJzKIsyDc0cl94sdWYTQIr3R6nkNnkvlYg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=bz1HTqUC; arc=none smtp.remote-ip=209.85.221.46 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27289606A33C for ; Thu, 3 Dec 2026 16:56:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 27289606A33C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=bz1HTqUC Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-4c3f0acc1easo19529f8f.0 for ; Thu, 03 Dec 2026 08:56:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796316968; x=1796921768; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=5qlculokp6Lzv3SNmAh6UxKQglFmReE7R+MKZAC7i+4=; b=bz1HTqUCHOi3qNjD3A4QU/38m6kHN02/5k2x+0yCS8TU866arXflngwWcEhcbwiaiH hseAnPf22deSeldEWAqwHto4pMvOdtqwvZhliqjRBA7efYAK5IIK3psazBLKPUQNdtd7 6ryhLzZoSmVcSE/l8x6gHBk2Rl3bQbj5Zkgntc9qOHjXon1ha0WROd0+MdyLK8N/9O6W CapZezT5FQ/MmoAb3PtNWcQ97MTGejINI7LPnymkzGZ0m59l6+cbYXGgV+WicQ+I0MED zrahNYR4o7h5FXHcCB0h50P/OBbjTBlc51z8cW4vmAJK5pFVOG2RLltJ8XUMOBVMcvOr apJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796316968; x=1796921768; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=5qlculokp6Lzv3SNmAh6UxKQglFmReE7R+MKZAC7i+4=; b=Bxpxf3U/SxH06jYoz9hpj9eHV8aNtlxTFKAqZbSFM2o8SOUcpf08TpNgQyMAy06jR7 iOwckKVRmC0jiJzb2pGJTiCLB0Q24xwQmjP2hl+Q9X4fVG+u6tTvGFkIZkoz9sKNsbkw I4+XMqYZ/06fVWjoQM25jhH6V96afDhP6yFSDeAEzdF0VKDKZY3qazqdUxHaHlZxaBs7 DqOsYrFliVRvKJzZxiyUpEjyqBRy1y9oVxHrMAwAQUHBRbJXdIEooikMklYrMhRMWExF xelKnSi61/bVh21twsz2wPQZfNdecn7rmphVx+C+eAEIULYJOgettsHjXlMn4TyYy/NZ emKA== X-Forwarded-Encrypted: i=1; AL+hErHys0Gk4CppChCGpl1wLUOS4rMsMssIN1Yv1dnAujovA0khE75SWYywoL41U7NE0+iT0ajNUnzOk28=@vger.kernel.org X-Gm-Message-State: APuU4Z/jrbPpDMyjyyJFVvPOLH3Nhy5heEAOANz89vMnBa/9GwIqSqdY JGMPfvCznGPJzZrNeB1uylhfZ8Ij26hQT5KWK26ACWdC3zzUwx9hMAn4 X-Gm-Gg: AZFdTZc+T0zkD1zddNIvAXuLgVLuY0AOn/xpVv0u5SiOWzSHRVb4oocWPhFx6WTQ/zd pSBCb07JJHlieTS8mZ1JdoDWbFVsTQEdaSawCWNC3b+ZM4YERLhyaGjLcK1pT9BT+KQaUwgP/js JC6hYB0J4KEY4MIrKNIJ+6h0vgsQ1jnVMLA6qvU11W6s+uLDNbsQH/GdY8EsZAAa/aihR/Yy39W 11qWnvRJhlsnQp6yCvdTm2Ro4HVfZ8OkscWY67zYKzr2atTk4pDkIUju49BCMNgfneryBG6GAn2 iOwuaINxjr1OcLtzGEt7DnB2ztBCfBJfExwH7flcAKfGifwjH9UaBhAywZxSImXDjdMdLIDAheE R4g9CHjljB8mTi4mCv5CkFwWP2C7JYJMASocIM7nIN+Gj7T0Wa/EncPF7jbT0hhhmoIuHV/rGcy F6Qp8wUXApuGZekuq8D/fie4OmOf/Ps46lJImjuDKFKGCf8uhCz6oF2UhJu/qCTX5zXx+3UeWZ8 Fu6pYlklgvXD/rj32jqa7sD0CPoP9fePFZIFudpAjWdQPx4EjAj2vKz4jO+k6tS9XkXDjQfH+tx XiKPnHYWH3jZNXOWf3Co1nJhhh9GgV6T/9B59An0Z5oAWBnDcAJwN+GuWA== X-Received: by 2002:a05:6000:27c9:10b0:491:cd7:e96b with SMTP id ffacd0b85a97d-4cf498bbb1dmr4280172f8f.15.1796316968321; Thu, 03 Dec 2026 08:56:08 -0800 (PST) Received: from foxbook (bfj60.neoplus.adsl.tpnet.pl. [83.28.47.60]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d17435e11fsm184716f8f.51.2026.12.03.08.56.07 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 03 Dec 2026 08:56:08 -0800 (PST) Date: Thu, 3 Dec 2026 17:56:10 +0100 From: Michal Pecio To: Mathias Nyman Cc: Mathias Nyman , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: Re: [PATCH v2] usb: xhci: Work around the ASM3142 bulk UVC bug Message-ID: <20261203175610.7b941db3.michal.pecio@gmail.com> In-Reply-To: References: <20261202101200.726fc9e3.michal.pecio@gmail.com> <20261202113051.7587a314.michal.pecio@gmail.com> X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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