Message ID | a5e0408867d422f12c31b282a1d95fd6dcb96651.1667586534.git.Thinh.Nguyen@synopsys.com |
---|---|
State | New |
Headers | show |
Series | usb: dwc3: gadget: Reduce TRB IOC settings | expand |
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 5fe2d136dff5..095edcc28f23 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1461,9 +1461,10 @@ static int dwc3_prepare_trbs_sg(struct dwc3_ep *dep, * resume preparing the next SG entry when more TRBs are * free. */ - if (num_trbs_left == 1 || (needs_extra_trb && - num_trbs_left <= 2 && - sg_dma_len(sg_next(s)) >= length)) + if (next_request(&dep->started_list) == req && + (num_trbs_left == 1 || + (needs_extra_trb && num_trbs_left <= 2 && + sg_dma_len(sg_next(s)) >= length))) must_interrupt = true; dwc3_prepare_one_trb(dep, req, trb_length, 1, i, false,
When the TRB ring is full, the dwc3 driver must make sure that there's at least 1 TRB with Interrupt On Completion (IOC) set to notify of available TRBs. The current logic just sets the TRB's IOC whenever we run out of TRBs, but it doesn't consider that there may be other TRBs with IOC/LST set already. This creates more events and unnecessary delay from interrupt handling. Set must_interrupt when we run out of TRBs and all the TRBs in the TRB ring belong to the same request. Note: if the gadget driver keeps queuing requests with more than the DWC3_NUM_TRBS, it prevents the controller from caching new TRBs as often, affecting performance. However, that's a separate issue that needs a separate driver enhancement. Regardless, currently no gadget driver setups a request with more than DWC3_NUM_TRBS. Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> --- drivers/usb/dwc3/gadget.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) base-commit: a8bc8cc193c69e41df5e757d1a592346526e136d