From b3f09747be2007be3a372fe80635b51df6ba71bd Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Thu, 7 May 2020 22:32:26 +0200 Subject: [PATCH 2/5] fsl_udc: import build_dtd fixes Signed-off-by: Joakim Tjernlund --- drivers/usb/gadget/udc/fsl_udc_core.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c index 2546bc28f42a..4b1591fa2e1c 100644 --- a/drivers/usb/gadget/udc/fsl_udc_core.c +++ b/drivers/usb/gadget/udc/fsl_udc_core.c @@ -774,12 +774,20 @@ static void fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req) static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, dma_addr_t *dma, int *is_last, gfp_t gfp_flags) { - u32 swap_temp; + u32 swap_temp, mult = 0; struct ep_td_struct *dtd; + struct ep_queue_head *dqh; /* how big will this transfer be? */ - *length = min(req->req.length - req->req.actual, - (unsigned)EP_MAX_LENGTH_TRANSFER); + if (usb_endpoint_xfer_isoc(req->ep->ep.desc)) { + dqh = req->ep->qh; + mult = (dqh->max_pkt_length >> EP_QUEUE_HEAD_MULT_POS) + & 0x3; + *length = min(req->req.length - req->req.actual, + (unsigned)(mult * req->ep->ep.maxpacket)); + } else + *length = min(req->req.length - req->req.actual, + (unsigned)EP_MAX_LENGTH_TRANSFER); dtd = dma_pool_alloc(udc_controller->td_pool, gfp_flags, dma); if (dtd == NULL) @@ -794,6 +802,7 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, /* Init all of buffer page pointers */ swap_temp = (u32) (req->req.dma + req->req.actual); dtd->buff_ptr0 = cpu_to_hc32(swap_temp); + swap_temp &= ~0xFFF; dtd->buff_ptr1 = cpu_to_hc32(swap_temp + 0x1000); dtd->buff_ptr2 = cpu_to_hc32(swap_temp + 0x2000); dtd->buff_ptr3 = cpu_to_hc32(swap_temp + 0x3000); @@ -820,6 +829,7 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, /* Enable interrupt for the last dtd of a request */ if (*is_last && !req->req.no_interrupt) swap_temp |= DTD_IOC; + swap_temp |= mult << 10; dtd->size_ioc_sts = cpu_to_hc32(swap_temp); -- 2.32.0