Same problem as ep0, but for the normal endpoints. In u-boot the trb pool and the request buffers are plain cached memory, so the controller and the CPU do not see the same data. The resync dropped the cache maintenance u-boot had here.
Without it the controller reads a stale trb and no data moves. DFU still works because it goes over ep0, but ums does not. The device enumerates and usb-storage binds, but no disk shows up and the host gives up after 20 seconds. Flush the data buffer and the trb once the trb is set up. Invalidate the trb before reading it back, and the request buffer before handing it to the gadget driver. Tested on BeagleBoard-X15 with ums. Reported-by: Anshul Dalal <[email protected]> Signed-off-by: Anders Roxell <[email protected]> --- drivers/usb/dwc3/gadget.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index b3a371df3749..fd0ae9e3e092 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -228,6 +228,10 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, dwc3_gadget_del_and_unmap_request(dep, req, status); req->status = DWC3_REQUEST_STATUS_COMPLETED; + if (req->request.dma && req->request.length) + dwc3_invalidate_cache((uintptr_t)req->request.dma, + req->request.length); + spin_unlock(&dwc->lock); usb_gadget_giveback_request(&dep->endpoint, &req->request); spin_lock(&dwc->lock); @@ -1385,6 +1389,9 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, wmb(); trb->ctrl |= DWC3_TRB_CTRL_HWO; + dwc3_flush_cache((uintptr_t)dma, trb_length); + dwc3_flush_cache((uintptr_t)trb, sizeof(*trb)); + dwc3_ep_inc_enq(dep); } @@ -3153,6 +3160,8 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep, { unsigned int count; + dwc3_invalidate_cache((uintptr_t)trb, sizeof(*trb)); + dwc3_ep_inc_deq(dep); req->num_trbs--; -- 2.53.0
