]> www.infradead.org Git - users/hch/misc.git/commit
xhci: dbc: honor usb transfer size boundaries.
authorMathias Nyman <mathias.nyman@linux.intel.com>
Wed, 16 Oct 2024 14:00:00 +0000 (17:00 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Oct 2024 06:45:36 +0000 (08:45 +0200)
commit30c9ae5ece8ecd69d36e6912c2c0896418f2468c
tree368814ab8dd650f1547c4ac19aab597cf1383a3c
parentf42a36bae0645f85c0290abc1d1385efd8ec9b13
xhci: dbc: honor usb transfer size boundaries.

Treat each completed full size write to /dev/ttyDBC0 as a separate usb
transfer. Make sure the size of the TRBs matches the size of the tty
write by first queuing as many max packet size TRBs as possible up to
the last TRB which will be cut short to match the size of the tty write.

This solves an issue where userspace writes several transfers back to
back via /dev/ttyDBC0 into a kfifo before dbgtty can find available
request to turn that kfifo data into TRBs on the transfer ring.

The boundary between transfer was lost as xhci-dbgtty then turned
everyting in the kfifo into as many 'max packet size' TRBs as possible.

DbC would then send more data to the host than intended for that
transfer, causing host to issue a babble error.

Refuse to write more data to kfifo until previous tty write data is
turned into properly sized TRBs with data size boundaries matching tty
write size

Tested-by: Uday M Bhat <uday.m.bhat@intel.com>
Tested-by: Ɓukasz Bartosik <ukaszb@chromium.org>
Cc: stable@vger.kernel.org
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20241016140000.783905-5-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-dbgcap.h
drivers/usb/host/xhci-dbgtty.c