DWC3 driver¶
TODO¶
Please pick something while reading :)
Convert interrupt handler to per-ep-thread-irq
As it turns out some DWC3-commands ~1ms to complete. Currently we spinuntil the command completes which is bad.
Implementation idea:
- dwc core implements a demultiplexing irq chip for interrupts perendpoint. The interrupt numbers are allocated during probe and belongto the device. If MSI provides per-endpoint interrupt this dummyinterrupt chip can be replaced with “real” interrupts.
- interrupts are requested / allocated on usb_ep_enable() and removed onusb_ep_disable(). Worst case are 32 interrupts, the lower limit is twofor ep0/1.
dwc3_send_gadget_ep_cmd()will sleep in wait_for_completion_timeout()until the command completes.- the interrupt handler is split into the following pieces:
- primary handler of the devicegoes through every event and calls
generic_handle_irq()for eventit. On return fromgeneric_handle_irq()in acknowledges the eventcounter so interrupt goes away (eventually). - threaded handler of the devicenone
- primary handler of the EP-interruptreads the event and tries to process it. Everything that requiressleeping is handed over to the Thread. The event is saved in anper-endpoint data-structure.We probably have to pay attention not to process events once wehanded something to thread so we don’t process event X prio Ywhere X > Y.
- threaded handler of the EP-interrupthandles the remaining EP work which might sleep such as waitingfor command completion.
- primary handler of the devicegoes through every event and calls
Latency:
There should be no increase in latency since the interrupt-thread has ahigh priority and will be run before an average task in user land(except the user changed priorities).