linux-stable/drivers/usb
Tejas Joglekar 2017a1e584 usb: xhci: Use temporary buffer to consolidate SG
The Synopsys xHC has an internal TRB cache of size TRB_CACHE_SIZE for
each endpoint. The default value for TRB_CACHE_SIZE is 16 for SS and 8
for HS. The controller loads and updates the TRB cache from the transfer
ring in system memory whenever the driver issues a start transfer or
update transfer command.

For chained TRBs, the Synopsys xHC requires that the total amount of
bytes for all TRBs loaded in the TRB cache be greater than or equal to 1
MPS. Or the chain ends within the TRB cache (with a last TRB).

If this requirement is not met, the controller will not be able to send
or receive a packet and it will hang causing a driver timeout and error.

This can be a problem if a class driver queues SG requests with many
small-buffer entries. The XHCI driver will create a chained TRB for each
entry which may trigger this issue.

This patch adds logic to the XHCI driver to detect and prevent this from
happening.

For every (TRB_CACHE_SIZE - 2), we check the total buffer size of
the SG list and if the last window of (TRB_CACHE_SIZE - 2) SG list length
and we don't make up at least 1 MPS, we create a temporary buffer to
consolidate full SG list into the buffer.

We check at (TRB_CACHE_SIZE - 2) window because it is possible that there
would be a link and/or event data TRB that take up to 2 of the cache
entries.

We discovered this issue with devices on other platforms but have not
yet come across any device that triggers this on Linux. But it could be
a real problem now or in the future. All it takes is N number of small
chained TRBs. And other instances of the Synopsys IP may have smaller
values for the TRB_CACHE_SIZE which would exacerbate the problem.

Signed-off-by: Tejas Joglekar <joglekar@synopsys.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20201208092912.1773650-3-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-12-09 14:32:03 +01:00
..
atm usb: atm: Replace in_interrupt() usage in comment 2020-10-28 12:31:39 +01:00
c67x00 Linux 5.9-rc3 2020-08-31 07:11:45 +02:00
cdns3 usb: cdns3: core: fix goto label for error path 2020-11-30 13:48:32 +08:00
chipidea usb: chipidea: ci_hdrc_imx: Pass DISABLE_DEVICE_STREAMING flag to imx6ul 2020-12-07 15:24:44 +01:00
class usb: cdc-acm: Add DISABLE_ECHO for Renesas USB Download mode 2020-11-13 15:26:49 +01:00
common usb: common: ulpi: Constify static attribute_group struct 2020-11-26 13:40:43 +01:00
core USB: add RESET_RESUME quirk for Snapscan 1212 2020-12-07 15:29:08 +01:00
dwc2 usb: dwc2: Avoid leaving the error_debugfs label unused 2020-10-27 11:33:53 +02:00
dwc3 USB: fixes for v5.10-rc2 2020-11-02 13:36:11 +01:00
early usb: early: ehci-dbgp: convert to readl_poll_timeout_atomic() 2020-09-25 16:29:09 +02:00
gadget USB: dummy-hcd: Fix uninitialized array use in init() 2020-12-07 15:25:23 +01:00
host usb: xhci: Use temporary buffer to consolidate SG 2020-12-09 14:32:03 +01:00
image USB: microtek: use set_host_byte() 2020-09-16 12:42:10 +02:00
isp1760 usb: isp1760-hcd: convert to readl_poll_timeout_atomic() 2020-09-25 16:30:05 +02:00
misc USB: legotower: fix logical error in recent commit 2020-12-08 19:55:09 +01:00
mon
mtu3 usb: mtu3: fix memory corruption in mtu3_debugfs_regset() 2020-12-07 15:26:18 +01:00
musb usb: Fix fall-through warnings for Clang 2020-11-23 17:46:01 +01:00
phy usb: isp1301-omap: Convert to use GPIO descriptors 2020-11-26 09:15:31 +01:00
renesas_usbhs usb: Use fallthrough pseudo-keyword 2020-07-10 08:55:17 +02:00
roles device connection: Remove struct device_connection 2020-09-07 11:14:09 +02:00
serial USB: serial: kl5kusb105: fix memleak on open 2020-12-04 12:02:57 +01:00
storage Merge 5.10-rc7 into usb-next 2020-12-07 10:20:51 +01:00
typec usb: typec: tps6598x: Export some power supply properties 2020-12-07 15:28:04 +01:00
usbip usbip: Remove in_interrupt() check 2020-10-28 13:06:06 +01:00
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
Makefile usb: host: imx21-hcd: Remove the driver 2020-11-13 15:22:46 +01:00
usb-skeleton.c