Message ID | 20200910091130.20937-2-peter.chen@nxp.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | usb: cdns3: improve the sg use case | expand |
Peter Chen <peter.chen@nxp.com> writes: > It needs to use request->num_mapped_sgs to indicate mapped sg number, > the request->num_sgs is the sg number before the mapping. These two > entries have different values for the platforms which iommu or > swiotlb is used. Besides, it needs to use correct sg APIs for > mapped sg list for TRB assignment. > > Signed-off-by: Peter Chen <peter.chen@nxp.com> fails to apply to my testing/next checking file drivers/usb/cdns3/gadget.c Hunk #1 succeeded at 1099 (offset 1 line). Hunk #2 succeeded at 1165 (offset 1 line). Hunk #3 FAILED at 1176. Hunk #4 succeeded at 1221 with fuzz 2 (offset 1 line). 1 out of 4 hunks FAILED
> > Peter Chen <peter.chen@nxp.com> writes: > > > It needs to use request->num_mapped_sgs to indicate mapped sg number, > > the request->num_sgs is the sg number before the mapping. These two > > entries have different values for the platforms which iommu or swiotlb > > is used. Besides, it needs to use correct sg APIs for mapped sg list > > for TRB assignment. > > > > Signed-off-by: Peter Chen <peter.chen@nxp.com> > > fails to apply to my testing/next > > checking file drivers/usb/cdns3/gadget.c Hunk #1 succeeded at 1099 (offset 1 > line). > Hunk #2 succeeded at 1165 (offset 1 line). > Hunk #3 FAILED at 1176. > Hunk #4 succeeded at 1221 with fuzz 2 (offset 1 line). > 1 out of 4 hunks FAILED > It could work now, I think the possible reason is you have already applied other cdns3 patches during these two hours. My git log likes below: ca71afbe0c52 (HEAD -> felipe_testing_next) usb: cdns3: gadget: enlarge the TRB ring length 50599e28f626 usb: cdns3: gadget: sg_support is only for DEV_VER_V2 or above ed1e5b0fe5b2 usb: cdns3: gadget: need to handle sg case for workaround 2 case 95c952507262 usb: cdns3: gadget: handle sg list use case at completion correctly 9d45b67cf0c3 usb: cdns3: gadget: add CHAIN and ISP bit for sg list use case 28e5fd2c3fae usb: cdns3: gadget: calculate TDL correctly f57692f1a9a4 usb: cdns3: gadget: improve the dump TRB operation at cdns3_ep_run_transfer 5f94832916b5 usb: cdns3: gadget: using correct sg operations bed7c9e9a5aa (felipe/testing/next) usb: dwc3: gadget: Rename misleading function names 3d7ce113c2d0 usb: dwc3: gadget: Refactor preparing last TRBs 43365b1e90af usb: dwc3: gadget: Set IOC if not enough for extra TRBs ea52ca3fdefb usb: dwc3: gadget: Check for number of TRBs prepared e6ccecf58b1b usb: dwc3: gadget: Return the number of prepared TRBs Thanks, Peter
On Thu, Sep 24, 2020 at 5:35 PM Peter Chen <peter.chen@nxp.com> wrote: > > > > > > Peter Chen <peter.chen@nxp.com> writes: > > > > > It needs to use request->num_mapped_sgs to indicate mapped sg number, > > > the request->num_sgs is the sg number before the mapping. These two > > > entries have different values for the platforms which iommu or swiotlb > > > is used. Besides, it needs to use correct sg APIs for mapped sg list > > > for TRB assignment. > > > > > > Signed-off-by: Peter Chen <peter.chen@nxp.com> > > > > fails to apply to my testing/next > > > > checking file drivers/usb/cdns3/gadget.c Hunk #1 succeeded at 1099 (offset 1 > > line). > > Hunk #2 succeeded at 1165 (offset 1 line). > > Hunk #3 FAILED at 1176. > > Hunk #4 succeeded at 1221 with fuzz 2 (offset 1 line). > > 1 out of 4 hunks FAILED > > > > It could work now, I think the possible reason is you have already applied other cdns3 patches during > these two hours. My git log likes below: > > ca71afbe0c52 (HEAD -> felipe_testing_next) usb: cdns3: gadget: enlarge the TRB ring length > 50599e28f626 usb: cdns3: gadget: sg_support is only for DEV_VER_V2 or above > ed1e5b0fe5b2 usb: cdns3: gadget: need to handle sg case for workaround 2 case > 95c952507262 usb: cdns3: gadget: handle sg list use case at completion correctly > 9d45b67cf0c3 usb: cdns3: gadget: add CHAIN and ISP bit for sg list use case > 28e5fd2c3fae usb: cdns3: gadget: calculate TDL correctly > f57692f1a9a4 usb: cdns3: gadget: improve the dump TRB operation at cdns3_ep_run_transfer > 5f94832916b5 usb: cdns3: gadget: using correct sg operations > bed7c9e9a5aa (felipe/testing/next) usb: dwc3: gadget: Rename misleading function names > 3d7ce113c2d0 usb: dwc3: gadget: Refactor preparing last TRBs > 43365b1e90af usb: dwc3: gadget: Set IOC if not enough for extra TRBs > ea52ca3fdefb usb: dwc3: gadget: Check for number of TRBs prepared > e6ccecf58b1b usb: dwc3: gadget: Return the number of prepared TRBs > > Thanks, > Peter Hi Felipe, I have still not seen these patches on your tree, would you please help to queue them for v5.10-rc1? Peter
Hi, Peter Chen <hzpeterchen@gmail.com> writes: >> > > It needs to use request->num_mapped_sgs to indicate mapped sg number, >> > > the request->num_sgs is the sg number before the mapping. These two >> > > entries have different values for the platforms which iommu or swiotlb >> > > is used. Besides, it needs to use correct sg APIs for mapped sg list >> > > for TRB assignment. >> > > >> > > Signed-off-by: Peter Chen <peter.chen@nxp.com> >> > >> > fails to apply to my testing/next >> > >> > checking file drivers/usb/cdns3/gadget.c Hunk #1 succeeded at 1099 (offset 1 >> > line). >> > Hunk #2 succeeded at 1165 (offset 1 line). >> > Hunk #3 FAILED at 1176. >> > Hunk #4 succeeded at 1221 with fuzz 2 (offset 1 line). >> > 1 out of 4 hunks FAILED >> > >> >> It could work now, I think the possible reason is you have already applied other cdns3 patches during >> these two hours. My git log likes below: >> >> ca71afbe0c52 (HEAD -> felipe_testing_next) usb: cdns3: gadget: enlarge the TRB ring length >> 50599e28f626 usb: cdns3: gadget: sg_support is only for DEV_VER_V2 or above >> ed1e5b0fe5b2 usb: cdns3: gadget: need to handle sg case for workaround 2 case >> 95c952507262 usb: cdns3: gadget: handle sg list use case at completion correctly >> 9d45b67cf0c3 usb: cdns3: gadget: add CHAIN and ISP bit for sg list use case >> 28e5fd2c3fae usb: cdns3: gadget: calculate TDL correctly >> f57692f1a9a4 usb: cdns3: gadget: improve the dump TRB operation at cdns3_ep_run_transfer >> 5f94832916b5 usb: cdns3: gadget: using correct sg operations >> bed7c9e9a5aa (felipe/testing/next) usb: dwc3: gadget: Rename misleading function names >> 3d7ce113c2d0 usb: dwc3: gadget: Refactor preparing last TRBs >> 43365b1e90af usb: dwc3: gadget: Set IOC if not enough for extra TRBs >> ea52ca3fdefb usb: dwc3: gadget: Check for number of TRBs prepared >> e6ccecf58b1b usb: dwc3: gadget: Return the number of prepared TRBs >> >> Thanks, >> Peter > > Hi Felipe, > > I have still not seen these patches on your tree, would you please > help to queue them for v5.10-rc1? Should be in testing/next now
diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index 2ea4d30e1828..2d6dd6896937 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -1098,11 +1098,13 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, u32 control; int pcs; u16 total_tdl = 0; + struct scatterlist *s = NULL; + bool sg_supported = !!(request->num_mapped_sgs); if (priv_ep->type == USB_ENDPOINT_XFER_ISOC) num_trb = priv_ep->interval; else - num_trb = request->num_sgs ? request->num_sgs : 1; + num_trb = sg_supported ? request->num_mapped_sgs : 1; if (num_trb > priv_ep->free_trbs) { priv_ep->flags |= EP_RING_FULL; @@ -1162,6 +1164,9 @@ 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; @@ -1171,13 +1176,13 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, /* fill TRB */ control |= TRB_TYPE(TRB_NORMAL); - trb->buffer = cpu_to_le32(TRB_BUFFER(request->num_sgs == 0 - ? trb_dma : request->sg[sg_iter].dma_address)); - - if (likely(!request->num_sgs)) + if (sg_supported) { + trb->buffer = cpu_to_le32(TRB_BUFFER(sg_dma_address(s))); + length = sg_dma_len(s); + } else { + trb->buffer = cpu_to_le32(TRB_BUFFER(trb_dma)); length = request->length; - else - length = request->sg[sg_iter].length; + } if (likely(priv_dev->dev_ver >= DEV_VER_V2)) td_size = DIV_ROUND_UP(length, @@ -1215,6 +1220,9 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, else priv_req->trb->control = cpu_to_le32(control); + if (sg_supported) + s = sg_next(s); + control = 0; ++sg_iter; priv_req->end_trb = priv_ep->enqueue;
It needs to use request->num_mapped_sgs to indicate mapped sg number, the request->num_sgs is the sg number before the mapping. These two entries have different values for the platforms which iommu or swiotlb is used. Besides, it needs to use correct sg APIs for mapped sg list for TRB assignment. Signed-off-by: Peter Chen <peter.chen@nxp.com> --- drivers/usb/cdns3/gadget.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)