Commit 5c7578c3 authored by Jing Leng's avatar Jing Leng Committed by Greg Kroah-Hartman

usb: cdnsp: Fixed setting last_trb incorrectly

When ZLP occurs in bulk transmission, currently cdnsp will set last_trb
for the last two TRBs, it will trigger an error "ERROR Transfer event TRB
DMA ptr not part of current TD ...".

Fixes: e913aada ("usb: cdnsp: Fixed issue with ZLP")
Cc: stable <stable@kernel.org>
Acked-by: default avatarPawel Laszczak <pawell@cadence.com>
Signed-off-by: default avatarJing Leng <jleng@ambarella.com>
Link: https://lore.kernel.org/r/20220609021134.1606-1-3090101217@zju.edu.cnSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b337af3a
...@@ -1941,13 +1941,16 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) ...@@ -1941,13 +1941,16 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq)
} }
if (enqd_len + trb_buff_len >= full_len) { if (enqd_len + trb_buff_len >= full_len) {
if (need_zero_pkt) if (need_zero_pkt && !zero_len_trb) {
zero_len_trb = !zero_len_trb; zero_len_trb = true;
} else {
field &= ~TRB_CHAIN; zero_len_trb = false;
field |= TRB_IOC; field &= ~TRB_CHAIN;
more_trbs_coming = false; field |= TRB_IOC;
preq->td.last_trb = ring->enqueue; more_trbs_coming = false;
need_zero_pkt = false;
preq->td.last_trb = ring->enqueue;
}
} }
/* Only set interrupt on short packet for OUT endpoints. */ /* Only set interrupt on short packet for OUT endpoints. */
...@@ -1962,7 +1965,7 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) ...@@ -1962,7 +1965,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) | length_field = TRB_LEN(trb_buff_len) | TRB_TD_SIZE(remainder) |
TRB_INTR_TARGET(0); TRB_INTR_TARGET(0);
cdnsp_queue_trb(pdev, ring, more_trbs_coming | zero_len_trb, cdnsp_queue_trb(pdev, ring, more_trbs_coming,
lower_32_bits(send_addr), lower_32_bits(send_addr),
upper_32_bits(send_addr), upper_32_bits(send_addr),
length_field, length_field,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment