mbox series

[0/8] usb: cdns3: improve the sg use case

Message ID 20200901084454.28649-1-peter.chen@nxp.com
Headers show
Series usb: cdns3: improve the sg use case | expand

Message

Peter Chen Sept. 1, 2020, 8:44 a.m. UTC
For sg use cases, there will be serveral TRBs in TD, and the short transfer
may occur during the TD, current code doesn't handle it well, improve it
through this series. Tested by Android MTP and ADB use case.

Peter Chen (8):
  usb: cdns3: gadget: using correct sg operations
  usb: cdns3: gadget: improve the dump TRB operation at
    cdns3_ep_run_transfer
  usb: cdns3: gadget: calculate TDL correctly
  usb: cdns3: gadget: add CHAIN and ISP bit for sg list use case
  usb: cdns3: gadget: handle sg list use case at completion correctly
  usb: cdns3: gadget: need to handle sg case for WA2 case
  usb: cdns3: gadget: sg_support is only for DEV_VER_V2 or above
  usb: cdns3: gadget: enlarge the TRB ring length

 drivers/usb/cdns3/gadget.c | 205 +++++++++++++++++++++++++------------
 drivers/usb/cdns3/gadget.h |  11 +-
 2 files changed, 151 insertions(+), 65 deletions(-)

Comments

Felipe Balbi Sept. 8, 2020, 6:19 a.m. UTC | #1
Hi,

Peter Chen <peter.chen@nxp.com> writes:
> @@ -1162,22 +1164,24 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep,
>  	if (priv_dev->dev_ver <= DEV_VER_V2)
>  		togle_pcs = cdns3_wa1_update_guard(priv_ep, trb);
>  
> +	if (sg_supported)
> +		s = request->sg;
> +
>  	/* set incorrect Cycle Bit for first trb*/
>  	control = priv_ep->pcs ? 0 : TRB_CYCLE;
> -

unnecessary change
Peter Chen Sept. 8, 2020, 9:08 a.m. UTC | #2
On 20-09-08 09:30:59, Felipe Balbi wrote:
> Peter Chen <peter.chen@nxp.com> writes:
> 
> > The scatter buffer list support earlier than DEV_VER_V2 is not
> > good enough, software can't know well about short transfer for it.
> >
> > Cc: Pawel Laszczak <pawell@cadence.com>
> > Signed-off-by: Peter Chen <peter.chen@nxp.com>
> > ---
> >  drivers/usb/cdns3/gadget.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
> > index 1fd36bc5c6db..82dc362550bf 100644
> > --- a/drivers/usb/cdns3/gadget.c
> > +++ b/drivers/usb/cdns3/gadget.c
> > @@ -3161,7 +3161,6 @@ static int cdns3_gadget_start(struct cdns3 *cdns)
> >  	priv_dev->gadget.speed = USB_SPEED_UNKNOWN;
> >  	priv_dev->gadget.ops = &cdns3_gadget_ops;
> >  	priv_dev->gadget.name = "usb-ss-gadget";
> > -	priv_dev->gadget.sg_supported = 1;
> >  	priv_dev->gadget.quirk_avoids_skb_reserve = 1;
> >  	priv_dev->gadget.irq = cdns->dev_irq;
> >  
> > @@ -3200,6 +3199,8 @@ static int cdns3_gadget_start(struct cdns3 *cdns)
> >  		readl(&priv_dev->regs->usb_cap2));
> >  
> >  	priv_dev->dev_ver = GET_DEV_BASE_VERSION(priv_dev->dev_ver);
> > +	if (priv_dev->dev_ver >= DEV_VER_V2)
> > +		priv_dev->gadget.sg_supported = 1;
> 
> is this a bug fix?
> 

Like answered at Patch 4, it is better to keep the whole patch series as
the improvement for sg use case.
Peter Chen Sept. 10, 2020, 8:37 a.m. UTC | #3
> 
> When I debug sg use case, it indeed took several patches for all functions work,
> and some patches improved the old patches since some short transfers use
> case did not be considered well.
> 
> Using this patch, it could let the completion work for both normal transfer and
> short transfer. So I prefer keeping one patch.
> 
> > > + * Then, we check if cycle bit for index priv_ep->dequeue
> > > + * is correct.
> > >   *
> > >   * some rules:
> > > - * 1. priv_ep->dequeue never exceed current_index.
> > > + * 1. priv_ep->dequeue never equals to current_index.
> > >   * 2  priv_ep->enqueue never exceed priv_ep->dequeue
> > >   * 3. exception: priv_ep->enqueue == priv_ep->dequeue
> > >   *    and priv_ep->free_trbs is zero.
> > >   *    This case indicate that TR is full.
> > >   *
> > > - * Then We can split recognition into two parts:
> > > + * At below two cases, the request have been handled.
> > >   * Case 1 - priv_ep->dequeue < current_index
> > >   *      SR ... EQ ... DQ ... CI ... ER
> > >   *      SR ... DQ ... CI ... EQ ... ER
> > >   *
> > > - *      Request has been handled by DMA if ST and ET is between DQ
> and CI.
> > > - *
> > >   * Case 2 - priv_ep->dequeue > current_index
> > > - * This situation take place when CI go through the LINK TRB at the
> > > end of
> > > + * This situation takes place when CI go through the LINK TRB at
> > > + the end of
> >
> > not part of $subject
> >
> 
> I will make another patch for comment improvement, thanks.
> 
 
I find I change the function from handle request to handle TRB, so the comments for this function
needs to be updated accordingly, it needs to be at the same patch.

Peter