From: John Youn Date: Fri, 20 May 2016 00:26:08 +0000 (-0700) Subject: UPSTREAM: usb: dwc3: gadget: Initialize the TRB ring X-Git-Tag: firefly_0821_release~1804 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=39298655f88b3a951512a120be82502d59746a83;p=firefly-linux-kernel-4.4.55.git UPSTREAM: usb: dwc3: gadget: Initialize the TRB ring Clears out all the TRBs in the ring to clean up any stale data that might be in them from the previous time the endpoint was enabled. Also removed the existing clear of the LINK trb since the entire ring is cleard just before. Change-Id: I311d0931dc9daa6b6f6e39d252e54c37c516c190 Signed-off-by: John Youn Signed-off-by: Felipe Balbi Signed-off-by: Wu Liang feng (cherry picked from commit 0d25744ad107b6c9010153f3ebf8b59672b5b8e7) --- diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 6aa7366e4024..c690cb3d8918 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -585,12 +585,16 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, if (usb_endpoint_xfer_control(desc)) return 0; + /* Initialize the TRB ring */ + dep->trb_dequeue = 0; + dep->trb_enqueue = 0; + memset(dep->trb_pool, 0, + sizeof(struct dwc3_trb) * DWC3_TRB_NUM); + /* Link TRB. The HWO bit is never reset */ trb_st_hw = &dep->trb_pool[0]; trb_link = &dep->trb_pool[DWC3_TRB_NUM - 1]; - memset(trb_link, 0, sizeof(*trb_link)); - trb_link->bpl = lower_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw)); trb_link->bph = upper_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw)); trb_link->ctrl |= DWC3_TRBCTL_LINK_TRB;