]> git.baikalelectronics.ru Git - kernel.git/commit
usb: dwc3: gadget: Fix dwc3_calc_trbs_left()
authorThinh Nguyen <Thinh.Nguyen@synopsys.com>
Thu, 19 Aug 2021 01:17:03 +0000 (03:17 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Aug 2021 11:47:03 +0000 (13:47 +0200)
commitf0c8746fa375345ea4062dfa9a3c06c9f3db1a6c
tree9e297402fb13c5eb652fcf4632c6f0afa495b5b5
parent64e1df2ec07ed4690705527fcbe9e122e1d68fce
usb: dwc3: gadget: Fix dwc3_calc_trbs_left()

We can't depend on the TRB's HWO bit to determine if the TRB ring is
"full". A TRB is only available when the driver had processed it, not
when the controller consumed and relinquished the TRB's ownership to the
driver. Otherwise, the driver may overwrite unprocessed TRBs. This can
happen when many transfer events accumulate and the system is slow to
process them and/or when there are too many small requests.

If a request is in the started_list, that means there is one or more
unprocessed TRBs remained. Check this instead of the TRB's HWO bit
whether the TRB ring is full.

Fixes: 36b792775b79 ("usb: dwc3: gadget: prepare TRBs on update transfers too")
Cc: <stable@vger.kernel.org>
Acked-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://lore.kernel.org/r/e91e975affb0d0d02770686afc3a5b9eb84409f6.1629335416.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/gadget.c