linux/drivers/usb/cdns3
Frank Li 387c2b6ba1 usb: cdns3: gadget: fix new urb never complete if ep cancel previous requests
This issue was found at android12 MTP.
1. MTP submit many out urb request.
2. Cancel left requests (>20) when enough data get from host
3. Send ACK by IN endpoint.
4. MTP submit new out urb request.
5. 4's urb never complete.

TRACE LOG:

MtpServer-2157    [000] d..3  1287.150391: cdns3_ep_dequeue: ep1out: req: 00000000299e6836, req buff 000000009df42287, length: 0/16384 zsi, status: -115, trb: [start:87, end:87: virt addr 0x80004000ffd50420], flags:1 SID: 0
MtpServer-2157    [000] d..3  1287.150410: cdns3_gadget_giveback: ep1out: req: 00000000299e6836, req buff 000000009df42287, length: 0/16384 zsi, status: -104, trb: [start:87, end:87: virt addr 0x80004000ffd50420], flags:0 SID: 0
MtpServer-2157    [000] d..3  1287.150433: cdns3_ep_dequeue: ep1out: req: 0000000080b7bde6, req buff 000000009ed5c556, length: 0/16384 zsi, status: -115, trb: [start:88, end:88: virt addr 0x80004000ffd5042c], flags:1 SID: 0
MtpServer-2157    [000] d..3  1287.150446: cdns3_gadget_giveback: ep1out: req: 0000000080b7bde6, req buff 000000009ed5c556, length: 0/16384 zsi, status: -104, trb: [start:88, end:88: virt addr 0x80004000ffd5042c], flags:0 SID: 0
	....
MtpServer-2157    [000] d..1  1293.630410: cdns3_alloc_request: ep1out: req: 00000000afbccb7d, req buff 0000000000000000, length: 0/0 zsi, status: 0, trb: [start:0, end:0: virt addr (null)], flags:0 SID: 0
MtpServer-2157    [000] d..2  1293.630421: cdns3_ep_queue: ep1out: req: 00000000afbccb7d, req buff 00000000871caf90, length: 0/512 zsi, status: -115, trb: [start:0, end:0: virt addr (null)], flags:0 SID: 0
MtpServer-2157    [000] d..2  1293.630445: cdns3_wa1: WA1: ep1out set guard
MtpServer-2157    [000] d..2  1293.630450: cdns3_wa1: WA1: ep1out restore cycle bit
MtpServer-2157    [000] d..2  1293.630453: cdns3_prepare_trb: ep1out: trb 000000007317b3ee, dma buf: 0xffd5bc00, size: 512, burst: 128 ctrl: 0x00000424 (C=0, T=0, ISP, IOC, Normal) SID:0 LAST_SID:0
MtpServer-2157    [000] d..2  1293.630460: cdns3_doorbell_epx: ep1out, ep_trbaddr ffd50414
	....
irq/241-5b13000-2154    [000] d..1  1293.680849: cdns3_epx_irq: IRQ for ep1out: 01000408 ISP , ep_traddr: ffd508ac ep_last_sid: 00000000 use_streams: 0
irq/241-5b13000-2154    [000] d..1  1293.680858: cdns3_complete_trb: ep1out: trb 0000000021a11b54, dma buf: 0xffd50420, size: 16384, burst: 128 ctrl: 0x00001810 (C=0, T=0, CHAIN, LINK) SID:0 LAST_SID:0
irq/241-5b13000-2154    [000] d..1  1293.680865: cdns3_request_handled: Req: 00000000afbccb7d not handled, DMA pos: 185, ep deq: 88, ep enq: 185, start trb: 184, end trb: 184

Actually DMA pos already bigger than previous submit request afbccb7d's TRB (184-184). The reason of (not handled) is that deq position is wrong.

The TRB link is below when irq happen.

	DEQ LINK LINK LINK LINK LINK .... TRB(afbccb7d):START  DMA(EP_TRADDR).

Original code check LINK TRB, but DEQ just move one step.

	LINK DEQ LINK LINK LINK LINK .... TRB(afbccb7d):START  DMA(EP_TRADDR).

This patch skip all LINK TRB and sync DEQ to trb's start.

	LINK LINK LINK LINK LINK .... DEQ = TRB(afbccb7d):START  DMA(EP_TRADDR).

Acked-by: Peter Chen <peter.chen@kernel.org>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Jun Li <jun.li@nxp.com>
Link: https://lore.kernel.org/r/20211130154239.8029-1-Frank.Li@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-12-03 13:57:22 +01:00
..
cdns3-debug.h usb: cdns3: Change file names for cdns3 driver. 2020-12-29 12:36:13 +08:00
cdns3-ep0.c usb: cdns3: Fixed incorrect gadget state 2021-07-29 14:13:02 +08:00
cdns3-gadget.c usb: cdns3: gadget: fix new urb never complete if ep cancel previous requests 2021-12-03 13:57:22 +01:00
cdns3-gadget.h usb: cdns3: Optimize DMA request buffer allocation 2021-04-12 20:19:22 +08:00
cdns3-imx.c usb: cdns3: cdns3-imx: File headers are not good candidates for kernel-doc 2021-05-27 09:43:44 +02:00
cdns3-pci-wrap.c usb: cdns3: fix spelling mistake "wrapperr" -> "wrapper" 2020-03-19 15:14:48 +01:00
cdns3-plat.c usb: cdns3: cdns3-plat: Fix incorrect naming of function 'cdns3_plat_remove()' 2021-05-27 09:43:44 +02:00
cdns3-ti.c usb: cdns3: cdns3-ti: File headers are not good candidates for kernel-doc 2021-05-27 09:43:44 +02:00
cdns3-trace.c usb: cdns3: Change file names for cdns3 driver. 2020-12-29 12:36:13 +08:00
cdns3-trace.h usb: cdns3: trace: delete the trace parameter for request->trb 2021-04-12 20:19:21 +08:00
cdnsp-debug.h usb: cdnsp: Fixes for sparse warnings 2020-12-29 12:36:13 +08:00
cdnsp-ep0.c usb: cdnsp: Removes some useless trace events 2021-02-06 15:43:52 +08:00
cdnsp-gadget.c usb: cdnsp: Fix incorrect supported maximum speed 2021-07-29 14:13:02 +08:00
cdnsp-gadget.h usb: cdnsp: Fix the IMAN_IE_SET and IMAN_IE_CLEAR macro 2021-07-29 14:28:15 +08:00
cdnsp-mem.c usb: cdnsp: fix the wrong mult value for HS isoc or intr 2021-08-13 13:05:50 +02:00
cdnsp-pci.c usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver 2020-12-29 12:36:13 +08:00
cdnsp-ring.c usb: cdnsp: Fixed issue with ZLP 2021-07-29 14:13:02 +08:00
cdnsp-trace.c usb: cdnsp: Add tracepoints for CDNSP driver 2020-12-29 12:36:13 +08:00
cdnsp-trace.h treewide: Add missing semicolons to __assign_str uses 2021-06-30 09:19:14 -04:00
core.c usb: cdns3: core: Fix a couple of incorrectly documented function names 2021-05-27 09:43:44 +02:00
core.h usb: cdns3: Adds missing __iomem markers 2021-01-14 09:01:33 +08:00
drd.c usb: cdns3: add power lost support for system resume 2021-04-12 20:19:20 +08:00
drd.h usb: cdns3: add power lost support for system resume 2021-04-12 20:19:20 +08:00
gadget-export.h usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver 2020-12-29 12:36:13 +08:00
host-export.h usb: cdns3: Removes xhci_cdns3_suspend_quirk from host-export.h 2020-12-29 12:36:13 +08:00
host.c usb: cdns3: Removes xhci_cdns3_suspend_quirk from host-export.h 2020-12-29 12:36:13 +08:00
Kconfig usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver 2020-12-29 12:36:13 +08:00
Makefile usb: cdnsp: fixes undefined reference to cdns_remove 2021-01-14 09:02:00 +08:00