@@ -337,17 +337,21 @@ static void cdns3_ep_inc_deq(struct cdns3_endpoint *priv_ep)
cdns3_ep_inc_trb(&priv_ep->dequeue, &priv_ep->ccs, priv_ep->num_trbs);
}
-static void cdns3_move_deq_to_next_trb(struct cdns3_request *priv_req)
+static void cdns3_sync_deq_to_trb(struct cdns3_request *priv_req)
{
struct cdns3_endpoint *priv_ep = priv_req->priv_ep;
- int current_trb = priv_req->start_trb;
+ struct cdns3_trb *trb = priv_ep->trb_pool + priv_ep->dequeue;
- while (current_trb != priv_req->end_trb) {
- cdns3_ep_inc_deq(priv_ep);
- current_trb = priv_ep->dequeue;
- }
+ if (TRB_FIELD_TO_TYPE(le32_to_cpu(trb->control)) == TRB_LINK) {
+ while (priv_ep->dequeue != priv_req->start_trb) {
+ dev_dbg(priv_ep->cdns3_dev->dev, "Remove TRB_LINK");
+ trb = priv_ep->trb_pool + priv_ep->dequeue;
+ WARN_ON_ONCE(TRB_FIELD_TO_TYPE(le32_to_cpu(trb->control)) != TRB_LINK);
+ trace_cdns3_complete_trb(priv_ep, trb);
- cdns3_ep_inc_deq(priv_ep);
+ cdns3_ep_inc_deq(priv_ep);
+ }
+ }
}
/**
@@ -1518,10 +1522,7 @@ static void cdns3_transfer_completed(struct cdns3_device *priv_dev,
trb = priv_ep->trb_pool + priv_ep->dequeue;
/* Request was dequeued and TRB was changed to TRB_LINK. */
- if (TRB_FIELD_TO_TYPE(le32_to_cpu(trb->control)) == TRB_LINK) {
- trace_cdns3_complete_trb(priv_ep, trb);
- cdns3_move_deq_to_next_trb(priv_req);
- }
+ cdns3_sync_deq_to_trb(priv_req);
if (!request->stream_id) {
/* Re-select endpoint. It could be changed by other CPU