linux-stable/drivers/usb
Jack Pham 58d68f2a2c usb: dwc3: gadget: Skip resizing EP's TX FIFO if already resized
[ Upstream commit 876a75cb52 ]

Some functions may dynamically enable and disable their endpoints
regularly throughout their operation, particularly when Set Interface
is employed to switch between Alternate Settings.  For instance the
UAC2 function has its respective endpoints for playback & capture
associated with AltSetting 1, in which case those endpoints would not
get enabled until the host activates the AltSetting.  And they
conversely become disabled when the interfaces' AltSetting 0 is
chosen.

With the DWC3 FIFO resizing algorithm recently added, every
usb_ep_enable() call results in a call to resize that EP's TXFIFO,
but if the same endpoint is enabled again and again, this incorrectly
leads to FIFO RAM allocation exhaustion as the mechanism did not
account for the possibility that endpoints can be re-enabled many
times.

Example log splat:

	dwc3 a600000.dwc3: Fifosize(3717) > RAM size(3462) ep3in depth:217973127
	configfs-gadget gadget: u_audio_start_capture:521 Error!
	dwc3 a600000.dwc3: request 000000000be13e18 was not queued to ep3in

Add another bit DWC3_EP_TXFIFO_RESIZED to dep->flags to keep track of
whether an EP had already been resized in the current configuration.
If so, bail out of dwc3_gadget_resize_tx_fifos() to avoid the
calculation error resulting from accumulating the EP's FIFO depth
repeatedly.  This flag is retained across multiple ep_disable() and
ep_enable() calls and is cleared when GTXFIFOSIZn is reset in
dwc3_gadget_clear_tx_fifos() upon receiving the next Set Config.

Fixes: 9f607a309f ("usb: dwc3: Resize TX FIFOs to meet EP bursting requirements")
Reviewed-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Link: https://lore.kernel.org/r/20211021180129.27938-1-jackp@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-11-18 19:16:54 +01:00
..
atm usb: atm: cxacru: Fix typo in comment 2021-05-21 20:05:40 +02:00
c67x00
cdns3 usb: cdns3: fix race condition before setting doorbell 2021-09-14 10:32:41 +02:00
chipidea USB: chipidea: fix interrupt deadlock 2021-11-18 19:16:08 +01:00
class USB: cdc-acm: fix break reporting 2021-10-05 13:50:52 +02:00
common Partially revert "usb: Kconfig: using select for USB_COMMON dependency" 2021-10-05 13:45:16 +02:00
core Revert "usb: core: hcd: Add support for deferring roothub registration" 2021-11-06 14:13:30 +01:00
dwc2 usb: dwc2: drd: reset current session before setting the new one 2021-11-18 19:16:54 +01:00
dwc3 usb: dwc3: gadget: Skip resizing EP's TX FIFO if already resized 2021-11-18 19:16:54 +01:00
early
gadget usb: gadget: hid: fix error code in do_config() 2021-11-18 19:16:51 +01:00
host usb: xhci: Enable runtime-pm by default on AMD Yellow Carp platform 2021-11-18 19:15:50 +01:00
image
isp1760 usb: isp1760: otg control register access 2021-08-27 16:11:39 +02:00
misc USB: iowarrior: fix control-message timeouts 2021-11-18 19:16:08 +01:00
mon
mtu3 usb: mtu3: fix random remote wakeup 2021-08-26 13:41:52 +02:00
musb usb: musb: select GENERIC_PHY instead of depending on it 2021-11-18 19:16:52 +01:00
phy usb: phy: tahvo: add IRQ check 2021-08-16 18:57:19 +02:00
renesas_usbhs usb: renesas_usbhs: Fix spelling mistake "faile" -> "failed" 2021-08-27 10:29:32 +02:00
roles usb: roles: add helper usb_role_string() 2021-05-27 09:17:18 +02:00
serial USB: serial: keyspan: fix memleak on probe errors 2021-11-18 19:16:07 +01:00
storage usb-storage: Add compatibility quirk flags for iODD 2531/2541 2021-11-12 15:05:48 +01:00
typec usb: typec: STUSB160X should select REGMAP_I2C 2021-11-18 19:16:54 +01:00
usbip usbip:vhci_hcd USB port can get stuck in the disabled state 2021-08-26 13:29:27 +02:00
Kconfig usb: remove reference to deleted config STB03xxx 2021-08-18 15:32:19 +02:00
Makefile usb: host: remove line for obsolete config USB_HWA_HCD 2021-08-18 15:32:19 +02:00
usb-skeleton.c