All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] usb: cdns3: two fixes for gadget
@ 2020-02-19 14:14 Peter Chen
  2020-02-19 14:14 ` [PATCH v2 1/2] usb: cdns3: gadget: link trb should point to next request Peter Chen
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Peter Chen @ 2020-02-19 14:14 UTC (permalink / raw)
  To: balbi; +Cc: linux-usb, linux-imx, pawell, rogerq, gregkh, jun.li, Peter Chen

These two issues are found during run "Error Recovery Test"
for the latest USB CV MSC test, the TRB doesn't advance correctly
after dequeue and clear halt. With these two fixes, the test
can be passed.

Peter Chen (2):
  usb: cdns3: gadget: link trb should point to next request
  usb: cdns3: gadget: toggle cycle bit before reset endpoint

 drivers/usb/cdns3/gadget.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

-- 
2.17.1


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

* [PATCH v2 1/2] usb: cdns3: gadget: link trb should point to next request
  2020-02-19 14:14 [PATCH v2 0/2] usb: cdns3: two fixes for gadget Peter Chen
@ 2020-02-19 14:14 ` Peter Chen
  2020-02-19 14:14 ` [PATCH v2 2/2] usb: cdns3: gadget: toggle cycle bit before reset endpoint Peter Chen
  2020-02-27  1:26 ` [PATCH v2 0/2] usb: cdns3: two fixes for gadget Peter Chen
  2 siblings, 0 replies; 5+ messages in thread
From: Peter Chen @ 2020-02-19 14:14 UTC (permalink / raw)
  To: balbi; +Cc: linux-usb, linux-imx, pawell, rogerq, gregkh, jun.li, Peter Chen

It has marked the dequeue trb as link trb, but its next segment
pointer is still itself, it causes the transfer can't go on. Fix
it by set its pointer as the trb address for the next request.

Fixes: f616c3bda47e ("usb: cdns3: Fix dequeue implementation")
Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
No changes.

 drivers/usb/cdns3/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
index 736b0c6e27fe..1d8a2af35bb0 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -2550,7 +2550,7 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep,
 	/* Update ring only if removed request is on pending_req_list list */
 	if (req_on_hw_ring) {
 		link_trb->buffer = TRB_BUFFER(priv_ep->trb_pool_dma +
-					      (priv_req->start_trb * TRB_SIZE));
+			((priv_req->end_trb + 1) * TRB_SIZE));
 		link_trb->control = (link_trb->control & TRB_CYCLE) |
 				    TRB_TYPE(TRB_LINK) | TRB_CHAIN;
 
-- 
2.17.1


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

* [PATCH v2 2/2] usb: cdns3: gadget: toggle cycle bit before reset endpoint
  2020-02-19 14:14 [PATCH v2 0/2] usb: cdns3: two fixes for gadget Peter Chen
  2020-02-19 14:14 ` [PATCH v2 1/2] usb: cdns3: gadget: link trb should point to next request Peter Chen
@ 2020-02-19 14:14 ` Peter Chen
  2020-02-27  1:26 ` [PATCH v2 0/2] usb: cdns3: two fixes for gadget Peter Chen
  2 siblings, 0 replies; 5+ messages in thread
From: Peter Chen @ 2020-02-19 14:14 UTC (permalink / raw)
  To: balbi; +Cc: linux-usb, linux-imx, pawell, rogerq, gregkh, jun.li, Peter Chen

If there are TRBs pending during reset endpoint operation, the
DMA will advance after reset operation, but it isn't expected,
since the data is not yet available (For OUT, the data is not
yet available). After the data is ready, there won't be any
interrupt since the EP_TRADDR already points to next TRB entry
and doorbell is not set.

To fix it, it toggles cycle bit before reset operation, and restores
it after reset, it could avoid unexpected DMA advance due to
cycle bit is for software during the endpoint reset operation.

Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
Changes for v2:
- Improve the comments.
- Using MACRO TRB_CYCLE at code

 drivers/usb/cdns3/gadget.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
index 1d8a2af35bb0..3574dbb09366 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -2595,11 +2595,21 @@ int __cdns3_gadget_ep_clear_halt(struct cdns3_endpoint *priv_ep)
 {
 	struct cdns3_device *priv_dev = priv_ep->cdns3_dev;
 	struct usb_request *request;
+	struct cdns3_request *priv_req;
+	struct cdns3_trb *trb = NULL;
 	int ret;
 	int val;
 
 	trace_cdns3_halt(priv_ep, 0, 0);
 
+	request = cdns3_next_request(&priv_ep->pending_req_list);
+	if (request) {
+		priv_req = to_cdns3_request(request);
+		trb = priv_req->trb;
+		if (trb)
+			trb->control = trb->control ^ TRB_CYCLE;
+	}
+
 	writel(EP_CMD_CSTALL | EP_CMD_EPRST, &priv_dev->regs->ep_cmd);
 
 	/* wait for EPRST cleared */
@@ -2610,10 +2620,11 @@ int __cdns3_gadget_ep_clear_halt(struct cdns3_endpoint *priv_ep)
 
 	priv_ep->flags &= ~(EP_STALLED | EP_STALL_PENDING);
 
-	request = cdns3_next_request(&priv_ep->pending_req_list);
-
-	if (request)
+	if (request) {
+		if (trb)
+			trb->control = trb->control ^ TRB_CYCLE;
 		cdns3_rearm_transfer(priv_ep, 1);
+	}
 
 	cdns3_start_all_request(priv_dev, priv_ep);
 	return ret;
-- 
2.17.1


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

* Re: [PATCH v2 0/2] usb: cdns3: two fixes for gadget
  2020-02-19 14:14 [PATCH v2 0/2] usb: cdns3: two fixes for gadget Peter Chen
  2020-02-19 14:14 ` [PATCH v2 1/2] usb: cdns3: gadget: link trb should point to next request Peter Chen
  2020-02-19 14:14 ` [PATCH v2 2/2] usb: cdns3: gadget: toggle cycle bit before reset endpoint Peter Chen
@ 2020-02-27  1:26 ` Peter Chen
  2020-03-04  8:55   ` Greg Kroah-Hartman
  2 siblings, 1 reply; 5+ messages in thread
From: Peter Chen @ 2020-02-27  1:26 UTC (permalink / raw)
  To: Peter Chen
  Cc: balbi, USB list, linux-imx, pawell, rogerq, Greg Kroah-Hartman, jun.li

On Wed, Feb 19, 2020 at 10:16 PM Peter Chen <peter.chen@nxp.com> wrote:
>
> These two issues are found during run "Error Recovery Test"
> for the latest USB CV MSC test, the TRB doesn't advance correctly
> after dequeue and clear halt. With these two fixes, the test
> can be passed.
>
> Peter Chen (2):
>   usb: cdns3: gadget: link trb should point to next request
>   usb: cdns3: gadget: toggle cycle bit before reset endpoint
>
>  drivers/usb/cdns3/gadget.c | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)
>

A gentle ping...

Peter

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

* Re: [PATCH v2 0/2] usb: cdns3: two fixes for gadget
  2020-02-27  1:26 ` [PATCH v2 0/2] usb: cdns3: two fixes for gadget Peter Chen
@ 2020-03-04  8:55   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2020-03-04  8:55 UTC (permalink / raw)
  To: Peter Chen; +Cc: Peter Chen, balbi, USB list, linux-imx, pawell, rogerq, jun.li

On Thu, Feb 27, 2020 at 09:26:49AM +0800, Peter Chen wrote:
> On Wed, Feb 19, 2020 at 10:16 PM Peter Chen <peter.chen@nxp.com> wrote:
> >
> > These two issues are found during run "Error Recovery Test"
> > for the latest USB CV MSC test, the TRB doesn't advance correctly
> > after dequeue and clear halt. With these two fixes, the test
> > can be passed.
> >
> > Peter Chen (2):
> >   usb: cdns3: gadget: link trb should point to next request
> >   usb: cdns3: gadget: toggle cycle bit before reset endpoint
> >
> >  drivers/usb/cdns3/gadget.c | 19 +++++++++++++++----
> >  1 file changed, 15 insertions(+), 4 deletions(-)
> >
> 
> A gentle ping...

I can take these now, thanks.

greg k-h

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

end of thread, other threads:[~2020-03-04  8:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19 14:14 [PATCH v2 0/2] usb: cdns3: two fixes for gadget Peter Chen
2020-02-19 14:14 ` [PATCH v2 1/2] usb: cdns3: gadget: link trb should point to next request Peter Chen
2020-02-19 14:14 ` [PATCH v2 2/2] usb: cdns3: gadget: toggle cycle bit before reset endpoint Peter Chen
2020-02-27  1:26 ` [PATCH v2 0/2] usb: cdns3: two fixes for gadget Peter Chen
2020-03-04  8:55   ` Greg Kroah-Hartman

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.