diff options
| author | Mathias Nyman <mathias.nyman@linux.intel.com> | 2025-10-27 12:29:19 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-11-02 22:14:41 +0900 |
| commit | 0e660d8224d075eb32ecc9f60d6a891efda5b0df (patch) | |
| tree | 6c8d1d37d2e4ef03bd51ddaf59e2e3600cd6e265 /include/linux/bits.h | |
| parent | 3aa367e6aae7ae8245d3a778072b2fe501d55058 (diff) | |
| download | linux-0e660d8224d075eb32ecc9f60d6a891efda5b0df.tar.gz linux-0e660d8224d075eb32ecc9f60d6a891efda5b0df.tar.bz2 linux-0e660d8224d075eb32ecc9f60d6a891efda5b0df.zip | |
xhci: dbc: fix bogus 1024 byte prefix if ttyDBC read races with stall event
[ Upstream commit f3d12ec847b945d5d65846c85f062d07d5e73164 ]
DbC may add 1024 bogus bytes to the beginneing of the receiving endpoint
if DbC hw triggers a STALL event before any Transfer Blocks (TRBs) for
incoming data are queued, but driver handles the event after it queued
the TRBs.
This is possible as xHCI DbC hardware may trigger spurious STALL transfer
events even if endpoint is empty. The STALL event contains a pointer
to the stalled TRB, and "remaining" untransferred data length.
As there are no TRBs queued yet the STALL event will just point to first
TRB position of the empty ring, with '0' bytes remaining untransferred.
DbC driver is polling for events, and may not handle the STALL event
before /dev/ttyDBC0 is opened and incoming data TRBs are queued.
The DbC event handler will now assume the first queued TRB (length 1024)
has stalled with '0' bytes remaining untransferred, and copies the data
This race situation can be practically mitigated by making sure the event
handler handles all pending transfer events when DbC reaches configured
state, and only then create dev/ttyDbC0, and start queueing transfers.
The event handler can this way detect the STALL events on empty rings
and discard them before any transfers are queued.
This does in practice solve the issue, but still leaves a small possible
gap for the race to trigger.
We still need a way to distinguish spurious STALLs on empty rings with '0'
bytes remaing, from actual STALL events with all bytes transmitted.
Cc: stable <stable@kernel.org>
Fixes: dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver")
Tested-by: Ćukasz Bartosik <ukaszb@chromium.org>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/bits.h')
0 files changed, 0 insertions, 0 deletions
