linux/drivers/usb/dwc3
Anurag Kumar Vulisha b7a4fbe230 usb: dwc3: Correct the logic for checking TRB full in __dwc3_prepare_one_trb()
Availability of TRB's is calculated using dwc3_calc_trbs_left(), which
determines total available TRB's based on the HWO bit set in a TRB.

In the present code, __dwc3_prepare_one_trb() is called with a TRB which
needs to be prepared for transfer. This __dwc3_prepare_one_trb() calls
dwc3_calc_trbs_left() to determine total available TRBs and set IOC bit
if the total available TRBs are zero. Since the present working TRB (which
is passed as an argument to __dwc3_prepare_one_trb() )  doesn't yet have
the HWO bit set before calling dwc3_calc_trbs_left(), there are chances
that dwc3_calc_trbs_left() wrongly calculates this present working TRB
as free(since the HWO bit is not yet set) and returns the total available
TRBs as greater than zero (including the present working TRB). This could
be a problem.

This patch corrects the above mentioned problem in __dwc3_prepare_one_trb()
by increementing the dep->trb_enqueue at the last (after preparing the TRB)
instead of increementing at the start and setting the IOC bit only if the
total available TRBs returned by dwc3_calc_trbs_left() is 1 . Since we are
increementing the dep->trb_enqueue at the last, the present working TRB is
also considered as available by dwc3_calc_trbs_left() and non zero value is
returned . So, according to the modified logic, when the total available
TRBs is equal to 1 that means the total available TRBs in the pool are 0.

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Reviewed-by: Thinh Nguyen <thinhn@synopsys.com>
Tested-by: Tejas Joglekar <tejas.joglekar@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-12-05 10:44:55 +02:00
..
core.c usb: dwc3: Add workaround for isoc start transfer failure 2018-11-26 09:06:32 +02:00
core.h usb: dwc3: gadget: check if dep->frame_number is still valid 2018-11-27 15:01:41 +02:00
debug.h usb: dwc3: debugfs: Properly print/set link state for HS 2018-11-26 09:06:31 +02:00
debugfs.c usb: dwc3: debugfs: Print/set link state for peripheral mode 2018-11-26 09:06:31 +02:00
drd.c usb: dwc3: drd: Add support for DR detection through extcon 2018-11-26 09:06:32 +02:00
dwc3-exynos.c usb: dwc3: exynos: Add support for Exynos5433 variant with all clocks 2018-10-02 10:33:01 +03:00
dwc3-haps.c usb: dwc3: Add a glue driver for Synopsys HAPS platform 2018-07-26 13:47:51 +03:00
dwc3-keystone.c USB: dwc3: Remove redundant license text 2017-11-07 15:45:01 +01:00
dwc3-of-simple.c usb: dwc3: of-simple: avoid unused function warnings 2018-08-29 09:59:37 +03:00
dwc3-omap.c usb: dwc3: omap: don't miss events during suspend/resume 2018-02-12 10:53:18 +02:00
dwc3-pci.c usb: dwc3: Fix NULL pointer exception in dwc3_pci_remove() 2018-11-14 10:37:19 +02:00
dwc3-qcom.c usb: dwc3: qcom: mark PM functions as __maybe_unused 2018-06-19 12:48:12 +03:00
dwc3-st.c USB: dwc3: Remove redundant license text 2017-11-07 15:45:01 +01:00
ep0.c usb: dwc3: gadget: remove redundant variable maxpacket 2018-07-13 15:41:56 +02:00
gadget.c usb: dwc3: Correct the logic for checking TRB full in __dwc3_prepare_one_trb() 2018-12-05 10:44:55 +02:00
gadget.h usb: dwc3: gadget: introduce cancelled_list 2018-11-26 09:08:29 +02:00
host.c usb: dwc3: Support option to disable USB2 LPM 2018-11-26 09:06:31 +02:00
io.h USB: dwc3: Remove redundant license text 2017-11-07 15:45:01 +01:00
Kconfig usb: dwc3: add EXTCON dependency for qcom 2018-10-02 10:33:43 +03:00
Makefile usb: dwc3: Add a glue driver for Synopsys HAPS platform 2018-07-26 13:47:51 +03:00
trace.c USB: dwc3: Remove redundant license text 2017-11-07 15:45:01 +01:00
trace.h usb: dwc3: trace: log ep commands in hex 2018-11-26 09:14:03 +02:00
ulpi.c USB: dwc3: Remove redundant license text 2017-11-07 15:45:01 +01:00