linux/drivers/usb
Mathias Nyman f5af638f06 xhci: Fix transfer ring expansion size calculation
The amount of new TRBs needed is calculated incorrectly when expanding a
transfer ring.

The room_on_ring() helper will correctly report that the ring needs
expansion if the enqueue pointer is about to reach the dequeue segment.
If enqueue reaches the dequeue segment then there is no easy way
to expand the ring by adding new segments between enqueue and dequeue.

This leads to ring expansion even if num_trbs_free is larger than
num_trbs we are queueing.

As a result we try to store a negative number in a unsigned int, leading
to a huge percieved trb need, and doubling of ring size.

Rework and rename the room_on_ring() to a helper that checks if ring
needs expansion, and return number of new segments needed. Don't rely on
the tracked ring->num_trbs_free value as turns out it has been unreliable.
Use ring enqueue and dequeue positions to determine expansion need.

The unsigned int issue was first reported first Chao zeng, and a bit
later seen in a real world bug.

Reported-by: chao zeng <chao.zengup@gmail.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217242
Tested-by: Miller Hunter <MillerH@hearthnhome.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Message-ID: <20230602144009.1225632-7-mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-06-13 11:34:50 +02:00
..
atm usb: move from strlcpy with unused retval to strscpy 2022-08-19 11:08:54 +02:00
c67x00 usb: c67x00-drv: Convert to platform remove callback returning void 2023-05-28 12:36:14 +01:00
cdns3 Merge 6.4-rc5 into usb-next 2023-06-05 07:39:02 +02:00
chipidea usb: chipidea: imx: remove one duplicated reg define 2023-05-29 15:49:25 +01:00
class USB: usbtmc: Fix direction for 0-length ioctl control messages 2023-05-13 17:25:49 +09:00
common usb: common: usb-conn-gpio: Convert to platform remove callback returning void 2023-05-28 12:36:15 +01:00
core Merge 6.4-rc5 into usb-next 2023-06-05 07:39:02 +02:00
dwc2 usb: dwc2/platform: Convert to platform remove callback returning void 2023-05-30 15:27:17 +01:00
dwc3 usb: dwc3: qcom: Fix potential memory leak 2023-05-29 15:17:28 +01:00
early usb: early: xhci-dbc: Use memcpy_and_pad() 2023-01-31 10:40:54 +01:00
fotg210 usb: fotg210: Convert to platform remove callback returning void 2023-05-28 12:36:25 +01:00
gadget Merge 6.4-rc5 into usb-next 2023-06-05 07:39:02 +02:00
host xhci: Fix transfer ring expansion size calculation 2023-06-13 11:34:50 +02:00
image scsi: usb: uas: Declare two host templates and host template pointers const 2023-03-24 19:20:00 -04:00
isp1760 usb: isp1760: Convert to platform remove callback returning void 2023-05-28 12:38:01 +01:00
misc usb: misc: onboard_hub: Don't warn twice about problems during remove 2023-05-30 15:27:17 +01:00
mon driver core: class: remove module * from class_create() 2023-03-17 15:16:33 +01:00
mtu3 usb: mtu3: add optional clock xhci_ck and frmcnt_ck 2023-04-20 11:17:05 +02:00
musb usb: musb: ux500: Convert to platform remove callback returning void 2023-04-05 19:07:42 +02:00
phy usb: Switch i2c drivers back to use .probe() 2023-05-29 15:53:11 +01:00
renesas_usbhs usb: renesas_usbhs: Convert to platform remove callback returning void 2023-05-28 12:38:01 +01:00
roles usb: roles: intel_xhci: Convert to platform remove callback returning void 2023-05-28 12:38:01 +01:00
serial Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
storage usb-storage: fix deadlock when a scsi command timeouts more than once 2023-05-13 18:53:03 +09:00
typec Merge 6.4-rc5 into usb-next 2023-06-05 07:39:02 +02:00
usbip usbip: vhci_hcd: Convert to platform remove callback returning void 2023-05-28 12:38:02 +01:00
Kconfig usb: move config USB_USS720 to usb's misc Kconfig 2023-03-29 10:34:08 +02:00
Makefile usb: host: u132-hcd: Delete driver 2023-03-21 14:06:11 +01:00
usb-skeleton.c usb: add usb_set_intfdata() documentation 2022-11-29 08:56:09 +01:00