mirror_ubuntu-kernels/drivers/usb/host
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
..
bcma-hcd.c USB: bcma: Make GPIO explicitly optional 2022-11-08 16:39:56 +01:00
ehci-atmel.c usb: ehci-atmel: Convert to platform remove callback returning void 2023-05-28 12:36:27 +01:00
ehci-brcm.c usb: ehci-brcm: Convert to platform remove callback returning void 2023-05-28 12:36:28 +01:00
ehci-dbg.c usb: host: {e|o}hci-dbg: kill useless 'ret' variable initializers 2022-02-15 15:11:20 +01:00
ehci-exynos.c usb: ehci-exynos: Convert to platform remove callback returning void 2023-05-28 12:36:28 +01:00
ehci-fsl.c usb: ehci-fsl: Convert to platform remove callback returning void 2023-05-28 12:36:28 +01:00
ehci-fsl.h
ehci-grlib.c usb: ehci-grlib: Convert to platform remove callback returning void 2023-05-28 12:36:28 +01:00
ehci-hcd.c usb: reduce kernel log spam on driver registration 2022-08-31 09:07:53 +02:00
ehci-hub.c
ehci-mem.c
ehci-mv.c usb: ehci-mv: Convert to platform remove callback returning void 2023-05-28 12:36:28 +01:00
ehci-npcm7xx.c usb: ehci-npcm7xx: Convert to platform remove callback returning void 2023-05-28 12:36:28 +01:00
ehci-omap.c usb: ehci-omap: Convert to platform remove callback returning void 2023-05-28 12:36:28 +01:00
ehci-orion.c usb: ehci-orion: Convert to platform remove callback returning void 2023-05-28 12:36:28 +01:00
ehci-pci.c USB: Extend pci resume function to handle PM events 2023-05-13 17:33:18 +09:00
ehci-platform.c usb: ehci-platform: Convert to platform remove callback returning void 2023-05-28 12:36:29 +01:00
ehci-ppc-of.c usb: ehci-ppc-of: Convert to platform remove callback returning void 2023-05-28 12:36:29 +01:00
ehci-ps3.c
ehci-q.c usb: ehci: Use endpoint in URB to get maxpacket 2022-08-31 09:07:53 +02:00
ehci-sched.c
ehci-sh.c usb: ehci-sh: Convert to platform remove callback returning void 2023-05-28 12:36:29 +01:00
ehci-spear.c usb: ehci-spear: Convert to platform remove callback returning void 2023-05-28 12:36:29 +01:00
ehci-st.c usb: ehci-st: Convert to platform remove callback returning void 2023-05-28 12:36:29 +01:00
ehci-sysfs.c
ehci-timer.c
ehci-xilinx-of.c usb: ehci-xilinx-of: Convert to platform remove callback returning void 2023-05-28 12:36:29 +01:00
ehci.h usb: host: fix a typo in ehci.h 2022-11-29 08:56:09 +01:00
fhci-dbg.c
fhci-hcd.c usb: host: fhci-hcd: Convert to platform remove callback returning void 2023-05-29 15:53:24 +01:00
fhci-hub.c USB: FHCI: Switch to GPIO descriptors 2022-09-01 16:08:29 +02:00
fhci-mem.c
fhci-q.c
fhci-sched.c
fhci-tds.c
fhci.h USB: FHCI: Switch to GPIO descriptors 2022-09-01 16:08:29 +02:00
fsl-mph-dr-of.c usb: fsl-mph-dr-of: Convert to platform remove callback returning void 2023-05-28 12:36:29 +01:00
isp116x-hcd.c usb: isp116x-hcd: Convert to platform remove callback returning void 2023-05-28 12:36:29 +01:00
isp116x.h
isp1362-hcd.c usb: isp1362-hcd: Convert to platform remove callback returning void 2023-05-28 12:36:30 +01:00
isp1362.h
Kconfig usb: add HAS_IOPORT dependencies 2023-05-29 15:28:34 +01:00
Makefile usb: host: u132-hcd: Delete driver 2023-03-21 14:06:11 +01:00
max3421-hcd.c usb: host: max3421-hcd: drop of_match_ptr for ID table 2023-03-16 12:15:23 +01:00
octeon-hcd.c usb: octeon-hcd: Convert to platform remove callback returning void 2023-05-28 12:36:30 +01:00
octeon-hcd.h staging: octeon-usb: move driver out of staging 2022-06-21 16:43:37 +02:00
ohci-at91.c usb: ohci-at91: Convert to platform remove callback returning void 2023-05-28 12:36:30 +01:00
ohci-da8xx.c usb: ohci-da8xx: Convert to platform remove callback returning void 2023-05-28 12:36:30 +01:00
ohci-dbg.c usb: host: {e|o}hci-dbg: kill useless 'ret' variable initializers 2022-02-15 15:11:20 +01:00
ohci-exynos.c usb: ohci-exynos: Convert to platform remove callback returning void 2023-05-28 12:36:30 +01:00
ohci-hcd.c usb: remove ohci-tmio driver 2023-02-01 17:23:38 +01:00
ohci-hub.c
ohci-mem.c
ohci-nxp.c usb: ohci-nxp: Convert to platform remove callback returning void 2023-05-28 12:36:30 +01:00
ohci-omap.c usb: ohci-omap: Convert to platform remove callback returning void 2023-05-28 12:36:30 +01:00
ohci-pci.c USB: Extend pci resume function to handle PM events 2023-05-13 17:33:18 +09:00
ohci-platform.c usb: host: ohci-platform: increase max clock number to 4 2023-05-29 15:54:05 +01:00
ohci-ppc-of.c usb: ohci-ppc-of: Convert to platform remove callback returning void 2023-05-28 12:36:31 +01:00
ohci-ps3.c
ohci-pxa27x.c usb: ohci-pxa27x: Convert to platform remove callback returning void 2023-05-28 12:36:31 +01:00
ohci-q.c
ohci-s3c2410.c usb: ohci-s3c2410: Convert to platform remove callback returning void 2023-05-28 12:36:31 +01:00
ohci-sa1111.c ARM: sa1100: remove unused board files 2023-01-12 10:53:12 +01:00
ohci-sm501.c usb: ohci-sm501: Convert to platform remove callback returning void 2023-05-28 12:36:31 +01:00
ohci-spear.c usb: ohci-spear: Convert to platform remove callback returning void 2023-05-28 12:36:31 +01:00
ohci-st.c usb: ohci-st: Convert to platform remove callback returning void 2023-05-28 12:36:31 +01:00
ohci.h
oxu210hp-hcd.c usb: oxu210hp-hcd: Convert to platform remove callback returning void 2023-05-28 12:36:31 +01:00
pci-quirks.c usb: pci-quirks: Reduce the length of a spinlock section in usb_amd_find_chipset_info() 2023-03-29 09:02:19 +02:00
pci-quirks.h
r8a66597-hcd.c usb: r8a66597-hcd: Convert to platform remove callback returning void 2023-05-28 12:36:31 +01:00
r8a66597.h
sl811_cs.c
sl811-hcd.c usb: sl811-hcd: Convert to platform remove callback returning void 2023-05-28 12:36:32 +01:00
sl811.h
ssb-hcd.c
uhci-debug.c
uhci-grlib.c usb: uhci-grlib: Convert to platform remove callback returning void 2023-05-28 12:36:32 +01:00
uhci-hcd.c usb: uhci: handle HAS_IOPORT dependencies 2023-05-29 15:29:03 +01:00
uhci-hcd.h usb: uhci: handle HAS_IOPORT dependencies 2023-05-29 15:29:03 +01:00
uhci-hub.c
uhci-pci.c Merge 6.4-rc4 into usb-next 2023-05-28 15:25:53 +01:00
uhci-platform.c usb: uhci-platform: Convert to platform remove callback returning void 2023-05-28 12:36:32 +01:00
uhci-q.c
xen-hcd.c xen: make remove callback of xen driver void returned 2022-12-15 16:06:10 +01:00
xhci-dbg.c
xhci-dbgcap.c xhci: dbc: Provide sysfs option to configure dbc descriptors 2023-03-23 17:25:22 +01:00
xhci-dbgcap.h xhci: dbc: Provide sysfs option to configure dbc descriptors 2023-03-23 17:25:22 +01:00
xhci-dbgtty.c xhci: dbgtty: use IDR to support several dbc instances. 2022-02-17 16:20:45 +01:00
xhci-debugfs.c xhci: fix debugfs register accesses while suspended 2023-04-20 10:13:06 +02:00
xhci-debugfs.h
xhci-ext-caps.c
xhci-ext-caps.h
xhci-histb.c xhci: get rid of XHCI_PLAT quirk that used to prevent MSI setup 2023-06-13 11:34:50 +02:00
xhci-hub.c xhci: decouple usb2 port resume and get_port_status request handling 2023-02-02 16:44:42 +01:00
xhci-mem.c xhci: Fix transfer ring expansion size calculation 2023-06-13 11:34:50 +02:00
xhci-mtk-sch.c usb: xhci-mtk: fix bandwidth release issue 2022-08-19 10:39:08 +02:00
xhci-mtk.c xhci: get rid of XHCI_PLAT quirk that used to prevent MSI setup 2023-06-13 11:34:50 +02:00
xhci-mtk.h usb: xhci-mtk: add optional frame count clock 2023-04-20 10:13:39 +02:00
xhci-mvebu.c usb: host: xhci: mvebu: Iterate over array indexes instead of using pointer math 2023-02-06 13:46:42 +01:00
xhci-mvebu.h Revert "usb: host: xhci: mvebu: make USB 3.0 PHY optional for Armada 3720" 2022-02-25 19:12:21 +05:30
xhci-pci-renesas.c usb: renesas-xhci: Do not print any log while fw verif success 2022-07-27 14:37:48 +02:00
xhci-pci.c xhci: get rid of XHCI_PLAT quirk that used to prevent MSI setup 2023-06-13 11:34:50 +02:00
xhci-pci.h
xhci-plat.c xhci: get rid of XHCI_PLAT quirk that used to prevent MSI setup 2023-06-13 11:34:50 +02:00
xhci-plat.h usb: xhci-plat: Convert to platform remove callback returning void 2023-05-30 15:27:17 +01:00
xhci-rcar.c usb: xhci-plat: Convert to platform remove callback returning void 2023-05-30 15:27:17 +01:00
xhci-ring.c xhci: Fix transfer ring expansion size calculation 2023-06-13 11:34:50 +02:00
xhci-rzv2m.c xhci: host: Add Renesas RZ/V2M SoC support 2023-01-25 15:48:17 +01:00
xhci-rzv2m.h xhci: host: Add Renesas RZ/V2M SoC support 2023-01-25 15:48:17 +01:00
xhci-tegra.c xhci: get rid of XHCI_PLAT quirk that used to prevent MSI setup 2023-06-13 11:34:50 +02:00
xhci-trace.c xhci: Move functions to setup msi to xhci-pci 2023-03-23 17:25:22 +01:00
xhci-trace.h usb: xhci: Remove unused udev from xhci_log_ctx trace event 2023-06-13 11:34:49 +02:00
xhci.c xhci: Don't require a valid get_quirks() function pointer during xhci setup 2023-06-13 11:34:49 +02:00
xhci.h xhci: get rid of XHCI_PLAT quirk that used to prevent MSI setup 2023-06-13 11:34:50 +02:00