Skip to content

Commit

Permalink
usb: cdnsp: Fixed issue with ZLP
Browse files Browse the repository at this point in the history
The condition "if (need_zero_pkt && zero_len_trb)" was always false
and it caused that TRB for ZLP was not prepared.

Fix causes that after preparing last TRB in TD, the driver prepares
additional TD with ZLP when a ZLP is required.

Cc: <[email protected]>
Fixes: 3d82904 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver")
Signed-off-by: Pawel Laszczak <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Peter Chen <[email protected]>
  • Loading branch information
pawellcdns authored and Peter Chen committed Jul 29, 2021
1 parent aa82f94 commit e913aad
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions drivers/usb/cdns3/cdnsp-ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -1932,15 +1932,13 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq)
}

if (enqd_len + trb_buff_len >= full_len) {
if (need_zero_pkt && zero_len_trb) {
zero_len_trb = true;
} else {
field &= ~TRB_CHAIN;
field |= TRB_IOC;
more_trbs_coming = false;
need_zero_pkt = false;
preq->td.last_trb = ring->enqueue;
}
if (need_zero_pkt)
zero_len_trb = !zero_len_trb;

field &= ~TRB_CHAIN;
field |= TRB_IOC;
more_trbs_coming = false;
preq->td.last_trb = ring->enqueue;
}

/* Only set interrupt on short packet for OUT endpoints. */
Expand All @@ -1955,7 +1953,7 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq)
length_field = TRB_LEN(trb_buff_len) | TRB_TD_SIZE(remainder) |
TRB_INTR_TARGET(0);

cdnsp_queue_trb(pdev, ring, more_trbs_coming | need_zero_pkt,
cdnsp_queue_trb(pdev, ring, more_trbs_coming | zero_len_trb,
lower_32_bits(send_addr),
upper_32_bits(send_addr),
length_field,
Expand Down

0 comments on commit e913aad

Please sign in to comment.