UPSTREAM: usb: dwc2: host: fix logical omissions in dwc2_process_non_isoc_desc
authorVardan Mikayelyan <mvardan@synopsys.com>
Tue, 16 Feb 2016 23:01:53 +0000 (15:01 -0800)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 3 Jan 2017 10:48:02 +0000 (18:48 +0800)
commitb1f6eec7616f81034567633206c0b3c011d28104
treed71eb7405fed2e83453e00d1aa7064de239f25e4
parent2c7b113cd6698ed8d136c3cad8d9700788fe360c
UPSTREAM: usb: dwc2: host: fix logical omissions in dwc2_process_non_isoc_desc

Fixes memory manipulation issues and makes Host DDMA bulk transfers
work.

dwc2_process_non_isoc_desc() must return non zero value ONLY when
failure happens in one of the queued descriptors. After receiving
non zero value the caller must stop processing of remaining
QTDs and their descriptors from chain.

Commit 26a19ea699060fde ("usb: dwc2: host: fix use of qtd after
free in desc dma mode") breaks non_isoc transaction completion logic
in Host DDMA mode. There were bugs before that, but after this patch
dwc2_process_non_isoc_desc() returns fail status even if descriptor
was processed normally. This causes break from loop which is processing
remaining descriptors assigned to QTD, which is not correct for QTDs
containing more than one descriptor.

Current dwc2 driver gathers queued BULK URBs until receiving URB
without URB_NO_INTERRUPT flag. Once getting it, SW creates
descriptor chain, stores it in qh structure and passes start
address to HW. Multiple URB data is contained in that chain.
Hence on getting error on descriptor after its processing by HW,
SW should go out of both loops(qh->qtd, qtd->descs) and report
the failure.

Change-Id: Ie23695bcad29c155f3d22ecaba0a1c78ec35aec7
Fixes: 26a19ea699060fde ("usb: dwc2: host: fix use of qtd after free in desc dma mode")
Cc: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Vardan Mikayelyan <mvardan@synopsys.com>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 3142a16b9816c24501103a92010a283eb6e2766c)
drivers/usb/dwc2/hcd_ddma.c