Skip to content

Commit 0d845a4

Browse files
Peter Chengregkh
Peter Chen
authored andcommitted
usb: chipidea: udc: delete td from req's td list at ep_dequeue
commit e4adcff upstream. We need to delete un-finished td from current request's td list at ep_dequeue API, otherwise, this non-user td will be remained at td list before this request is freed. So if we do ep_queue-> ep_dequeue->ep_queue sequence, when the complete interrupt for the second ep_queue comes, we search td list for this request, the first td (added by the first ep_queue) will be handled, and its status is still active, so we will consider the this transfer still not be completed, but in fact, it has completed. It causes the peripheral side considers it never receives current data for this transfer. We met this problem when do "Error Recovery Test - Device Configured" test item for USBCV2 MSC test, the host has never received ACK for the IN token for CSW due to peripheral considers it does not get this CBW, the USBCV test log like belows: -------------------------------------------------------------------------- INFO Issuing BOT MSC Reset, reset should always succeed INFO Retrieving status on CBW endpoint INFO CBW endpoint status = 0x0 INFO Retrieving status on CSW endpoint INFO CSW endpoint status = 0x0 INFO Issuing required command (Test Unit Ready) to verify device has recovered INFO Issuing CBW (attempt #1): INFO |----- CBW LUN = 0x0 INFO |----- CBW Flags = 0x0 INFO |----- CBW Data Transfer Length = 0x0 INFO |----- CBW CDB Length = 0x6 INFO |----- CBW CDB-00 = 0x0 INFO |----- CBW CDB-01 = 0x0 INFO |----- CBW CDB-02 = 0x0 INFO |----- CBW CDB-03 = 0x0 INFO |----- CBW CDB-04 = 0x0 INFO |----- CBW CDB-05 = 0x0 INFO Issuing CSW : try 1 INFO CSW Bulk Request timed out! ERROR Failed CSW phase : should have been success or stall FAIL (5.3.4) The CSW status value must be 0x00, 0x01, or 0x02. ERROR BOTCommonMSCRequest failed: error=80004000 Cc: Andrzej Pietrasiewicz <[email protected]> Signed-off-by: Peter Chen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6ea07d9 commit 0d845a4

File tree

1 file changed

+7
-0
lines changed
  • drivers/usb/chipidea

1 file changed

+7
-0
lines changed

drivers/usb/chipidea/udc.c

+7
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,7 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req)
13261326
struct ci_hw_ep *hwep = container_of(ep, struct ci_hw_ep, ep);
13271327
struct ci_hw_req *hwreq = container_of(req, struct ci_hw_req, req);
13281328
unsigned long flags;
1329+
struct td_node *node, *tmpnode;
13291330

13301331
if (ep == NULL || req == NULL || hwreq->req.status != -EALREADY ||
13311332
hwep->ep.desc == NULL || list_empty(&hwreq->queue) ||
@@ -1336,6 +1337,12 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req)
13361337

13371338
hw_ep_flush(hwep->ci, hwep->num, hwep->dir);
13381339

1340+
list_for_each_entry_safe(node, tmpnode, &hwreq->tds, td) {
1341+
dma_pool_free(hwep->td_pool, node->ptr, node->dma);
1342+
list_del(&node->td);
1343+
kfree(node);
1344+
}
1345+
13391346
/* pop request */
13401347
list_del_init(&hwreq->queue);
13411348

0 commit comments

Comments
 (0)