linux/drivers
Jack Pham a84e45d3c3 FROMGIT: usb: dwc3: gadget: Skip resizing EP's TX FIFO if already resized
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>

(cherry picked from commit 876a75cb52
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Bug: 204047971
Change-Id: Ia104c2fa9be36182a23a7e6f923e499ef3bcc3b1
Signed-off-by: Jack Pham <quic_jackp@quicinc.com>
2021-10-25 12:02:09 -07:00
..
accessibility
acpi This is the 5.10.60 stable release 2021-08-27 17:14:51 +02:00
amba
android ANDROID: vendor_hooks: export hooks of mem_cgroup subsystem 2021-10-18 19:01:26 +00:00
ata libata: fix ata_host_start() 2021-09-15 09:50:26 +02:00
atm atm: nicstar: register the interrupt handler in the right place 2021-07-19 09:44:52 +02:00
auxdisplay
base Merge tag 'android12-5.10.66_r00' into android12-5.10 2021-10-21 09:45:02 +02:00
bcma bcma: Fix memory leak for internally-handled cores 2021-09-15 09:50:45 +02:00
block This is the 5.10.66 stable release 2021-09-19 10:25:11 +02:00
bluetooth This is the 5.10.62 stable release 2021-09-03 10:51:56 +02:00
bus bus: ti-sysc: Fix error handling for sysc_check_active_timer() 2021-08-26 08:35:42 -04:00
cdrom cdrom: gdrom: initialize global variable at init time 2021-05-26 12:06:55 +02:00
char This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
clk This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
clocksource This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
connector
counter counter: 104-quad-8: Return error when invalid mode during ceiling_write 2021-09-15 09:50:38 +02:00
cpufreq This is the 5.10.62 stable release 2021-09-03 10:51:56 +02:00
cpuidle ANDROID: cpuidle: Allow for an early exit from cpuidle_enter_state() 2021-07-02 19:45:07 +00:00
crypto This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
dax
dca
devfreq PM / devfreq: Add missing error code in devfreq_add_device() 2021-07-14 16:56:11 +02:00
dio
dma Linux 5.10.61 2021-08-27 20:51:37 +02:00
dma-buf ANDROID: dma_heap: add dma_parms for uncached heap 2021-10-25 17:34:19 +00:00
edac EDAC/i10nm: Fix NVDIMM detection 2021-09-15 09:50:30 +02:00
eisa
extcon extcon: intel-mrfld: Sync hardware and software state on init 2021-07-19 09:45:00 +02:00
firewire
firmware This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
fpga fpga: dfl: fme: Fix cpu hotplug issue in performance reporting 2021-08-12 13:22:15 +02:00
fsi fsi: Add missing MODULE_DEVICE_TABLE 2021-07-20 16:05:42 +02:00
gnss
gpio This is the 5.10.58 stable release 2021-08-12 14:58:34 +02:00
gpu Merge tag 'android12-5.10.66_r00' into android12-5.10 2021-10-21 09:45:02 +02:00
greybus
hid This is the 5.10.56 stable release 2021-08-04 15:02:23 +02:00
hsi HSI: core: fix resource leaks in hsi_add_client_from_dt() 2021-05-14 09:50:28 +02:00
hv drivers: hv: Fix missing error code in vmbus_connect() 2021-07-14 16:55:59 +02:00
hwmon This is the 5.10.50 stable release 2021-07-14 17:35:23 +02:00
hwspinlock
hwtracing This is the 5.10.52 stable release 2021-07-20 16:36:53 +02:00
i2c This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
i3c Revert "i3c master: fix missing destroy_workqueue() on error in i3c_master_register" 2021-05-14 09:50:05 +02:00
ide
idle
iio iio: adc: Fix incorrect exit of for-loop 2021-08-18 08:59:05 +02:00
infiniband RDMA/efa: Free IRQ vectors on error flow 2021-09-03 10:09:24 +02:00
input This is the 5.10.52 stable release 2021-07-20 16:36:53 +02:00
interconnect interconnect: qcom: icc-rpmh: Ensure floor BW is enforced for all nodes 2021-08-12 13:22:18 +02:00
iommu Merge tag 'android12-5.10.66_r00' into android12-5.10 2021-10-21 09:45:02 +02:00
ipack ipack: tpci200: fix memory leak in the tpci200_register 2021-08-26 08:35:55 -04:00
irqchip This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
isdn mISDN: fix possible use-after-free in HFC_cleanup() 2021-07-19 09:44:38 +02:00
leds leds: trigger: audio: Add an activate callback to ensure the initial brightness is set 2021-09-15 09:50:36 +02:00
lightnvm
macintosh
mailbox mailbox: qcom-ipcc: Fix IPCC mbox channel exhaustion 2021-07-14 16:56:53 +02:00
mcb
md Merge tag 'android12-5.10.66_r00' into android12-5.10 2021-10-21 09:45:02 +02:00
media This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
memory This is the 5.10.53 stable release 2021-07-25 15:37:14 +02:00
memstick memstick: rtsx_usb_ms: fix UAF 2021-07-14 16:55:53 +02:00
message
mfd UPSTREAM: mfd: syscon: Free the allocated name field of struct regmap_config 2021-07-20 23:53:31 +00:00
misc This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
mmc This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
most
mtd mtd: spinand: Fix incorrect parameters for on-die ECC 2021-09-03 10:09:28 +02:00
mux
net This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
nfc nfc: nfcsim: fix use after free during module unload 2021-08-04 12:46:41 +02:00
ntb
nubus
nvdimm libnvdimm/region: Fix label activation vs errors 2021-08-18 08:59:07 +02:00
nvme nvmet: pass back cntlid on successful completion 2021-09-15 09:50:25 +02:00
nvmem nvmem: core: add a missing of_node_put 2021-07-19 09:45:00 +02:00
of This is the 5.10.50 stable release 2021-07-14 17:35:23 +02:00
opp This is the 5.10.62 stable release 2021-09-03 10:51:56 +02:00
oprofile
parisc
parport
pci This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
pcmcia pcmcia: i82092: fix a null pointer dereference bug 2021-08-12 13:22:16 +02:00
perf perf/arm-cmn: Fix invalid pointer when access dtc object sharing the same IRQ number 2021-07-14 16:56:08 +02:00
phy phy: intel: Fix for warnings due to EMMC clock 175Mhz change in FIP 2021-07-20 16:05:46 +02:00
pinctrl This is the 5.10.60 stable release 2021-08-27 17:14:51 +02:00
platform This is the 5.10.60 stable release 2021-08-27 17:14:51 +02:00
pnp
power This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
powercap
pps
ps3
ptp ptp_pch: Restore dependency on PCI 2021-08-26 08:35:46 -04:00
pwm This is the 5.10.54 stable release 2021-07-28 15:23:47 +02:00
rapidio rapidio: handle create_workqueue() failure 2021-05-26 12:06:52 +02:00
ras
regulator This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
remoteproc This is the 5.10.52 stable release 2021-07-20 16:36:53 +02:00
reset This is the 5.10.63 stable release 2021-09-08 09:08:09 +02:00
rpmsg Merge 5.10.38 into android12-5.10 2021-05-20 15:35:25 +02:00
rtc This is the 5.10.53 stable release 2021-07-25 15:37:14 +02:00
s390 This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
sbus
scsi UPSTREAM: core: Add L2P entry swap quirk for Micron UFS 2021-10-21 10:55:52 -07:00
sfi
sh
siox
slimbus slimbus: ngd: reset dma setup during runtime pm 2021-08-26 08:35:55 -04:00
soc This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
soundwire soundwire: stream: Fix test for DP prepare complete 2021-07-14 16:56:47 +02:00
spi This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
spmi
ssb ssb: Fix error return code in ssb_bus_scan() 2021-07-14 16:56:21 +02:00
staging This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
target scsi: target: Fix protect handling in WRITE SAME(32) 2021-07-28 14:35:39 +02:00
tc
tee tee: Correct inappropriate usage of TEE_SHM_DMA_BUF flag 2021-08-15 14:00:24 +02:00
thermal Merge branch 'android12-5.10' into android12-5.10-lts 2021-09-13 18:12:07 +02:00
thunderbolt thunderbolt: Bond lanes only when dual_link_port != NULL in alloc_dev_default() 2021-07-14 16:56:44 +02:00
tty This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
uio uio_hv_generic: Fix a memory leak in error handling paths 2021-05-26 12:06:52 +02:00
usb FROMGIT: usb: dwc3: gadget: Skip resizing EP's TX FIFO if already resized 2021-10-25 12:02:09 -07:00
vdpa vdpa/mlx5: Avoid destroying MR on empty iotlb 2021-08-26 08:35:42 -04:00
vfio This is the 5.10.50 stable release 2021-07-14 17:35:23 +02:00
vhost vringh: Use wiov->used to check for read/write desc order 2021-09-03 10:09:27 +02:00
video This is the 5.10.65 stable release 2021-09-15 14:16:47 +02:00
virt
virtio This is the 5.10.62 stable release 2021-09-03 10:51:56 +02:00
visorbus visorbus: fix error return code in visorchipset_init() 2021-07-14 16:56:41 +02:00
vlynq
vme
w1 w1: ds2438: fixing bug that would always get page0 2021-07-20 16:05:39 +02:00
watchdog This is the 5.10.57 stable release 2021-08-08 09:36:33 +02:00
xen xen/events: Fix race in set_evtchn_to_irq 2021-08-18 08:59:14 +02:00
zorro
Kconfig
Makefile