All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: cdnsp: Fixed setting last_trb incorrectly
@ 2022-06-09  2:11 3090101217
  2022-06-09  7:33 ` Pawel Laszczak
  0 siblings, 1 reply; 2+ messages in thread
From: 3090101217 @ 2022-06-09  2:11 UTC (permalink / raw)
  To: pawell, gregkh, peter.chen; +Cc: linux-usb, linux-kernel, Jing Leng

From: Jing Leng <jleng@ambarella.com>

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: e913aada0683 ("usb: cdnsp: Fixed issue with ZLP")
Signed-off-by: Jing Leng <jleng@ambarella.com>
---
 drivers/usb/cdns3/cdnsp-ring.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/cdns3/cdnsp-ring.c b/drivers/usb/cdns3/cdnsp-ring.c
index e45c3d6e1536..794e413800ae 100644
--- a/drivers/usb/cdns3/cdnsp-ring.c
+++ b/drivers/usb/cdns3/cdnsp-ring.c
@@ -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 (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;
+			if (need_zero_pkt && !zero_len_trb) {
+				zero_len_trb = true;
+			} else {
+				zero_len_trb = false;
+				field &= ~TRB_CHAIN;
+				field |= TRB_IOC;
+				more_trbs_coming = false;
+				need_zero_pkt = false;
+				preq->td.last_trb = ring->enqueue;
+			}
 		}
 
 		/* 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)
 		length_field = TRB_LEN(trb_buff_len) | TRB_TD_SIZE(remainder) |
 			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),
 				upper_32_bits(send_addr),
 				length_field,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] usb: cdnsp: Fixed setting last_trb incorrectly
  2022-06-09  2:11 [PATCH] usb: cdnsp: Fixed setting last_trb incorrectly 3090101217
@ 2022-06-09  7:33 ` Pawel Laszczak
  0 siblings, 0 replies; 2+ messages in thread
From: Pawel Laszczak @ 2022-06-09  7:33 UTC (permalink / raw)
  To: 3090101217, gregkh, peter.chen; +Cc: linux-usb, linux-kernel, Jing Leng

>
>From: Jing Leng <jleng@ambarella.com>
>
>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: e913aada0683 ("usb: cdnsp: Fixed issue with ZLP")
>Signed-off-by: Jing Leng <jleng@ambarella.com>

Acked-by: Pawel Laszczak <pawell@cadence.com>

>---
> drivers/usb/cdns3/cdnsp-ring.c | 19 +++++++++++--------
> 1 file changed, 11 insertions(+), 8 deletions(-)
>
>diff --git a/drivers/usb/cdns3/cdnsp-ring.c b/drivers/usb/cdns3/cdnsp-ring.c
>index e45c3d6e1536..794e413800ae 100644
>--- a/drivers/usb/cdns3/cdnsp-ring.c
>+++ b/drivers/usb/cdns3/cdnsp-ring.c
>@@ -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 (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;
>+			if (need_zero_pkt && !zero_len_trb) {
>+				zero_len_trb = true;
>+			} else {
>+				zero_len_trb = false;
>+				field &= ~TRB_CHAIN;
>+				field |= TRB_IOC;
>+				more_trbs_coming = false;
>+				need_zero_pkt = false;
>+				preq->td.last_trb = ring->enqueue;
>+			}
> 		}
>
> 		/* 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)
> 		length_field = TRB_LEN(trb_buff_len) | TRB_TD_SIZE(remainder) |
> 			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),
> 				upper_32_bits(send_addr),
> 				length_field,
>--
>2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-09  8:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-09  2:11 [PATCH] usb: cdnsp: Fixed setting last_trb incorrectly 3090101217
2022-06-09  7:33 ` Pawel Laszczak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.