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.

Signed-off-by: John Youn <johny...@synopsys.com>
---
 drivers/usb/dwc3/gadget.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index f9074c9..c7f1c17 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -567,12 +567,16 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
                if (usb_endpoint_xfer_control(desc))
                        goto out;
 
+               /* 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;
-- 
2.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to