]> git.karo-electronics.de Git - karo-tx-linux.git/commit
usb: dwc3: gadget: Prevent losing events in event cache
authorThinh Nguyen <Thinh.Nguyen@synopsys.com>
Fri, 12 May 2017 00:26:47 +0000 (17:26 -0700)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Tue, 16 May 2017 11:11:03 +0000 (14:11 +0300)
commitd325a1de49d61ee11aca58a529571c91ecea7879
tree70c95be4a03930383c886ff500a7fd032fffc20a
parentf1d6826cae30e97e37a1f2481d7e1dc4faa09ce1
usb: dwc3: gadget: Prevent losing events in event cache

The dwc3 driver can overwite its previous events if its top-half IRQ
handler (TH) gets invoked again before processing the events in the
cache. We see this as a hang in the file transfer and the host will
attempt to reset the device. TH gets the event count and deasserts the
interrupt line by writing DWC3_GEVNTSIZ_INTMASK to DWC3_GEVNTSIZ. If
there's a new event coming between reading the event count and interrupt
deassertion, dwc3 will lose previous pending events. More generally, we
will see 0 event count, which should not affect anything.

This shouldn't be possible in the current dwc3 implementation. However,
through testing and reading the PCIe trace, the TH occasionally still
gets invoked one more time after HW interrupt deassertion. (With PCIe
legacy interrupts, TH is called repeatedly as long as the interrupt line
is asserted). We suspect that there is a small detection delay in the
SW.

To avoid this issue, Check DWC3_EVENT_PENDING flag to determine if the
events are processed in the bottom-half IRQ handler. If not, return
IRQ_HANDLED and don't process new event.

Cc: stable@vger.kernel.org
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc3/gadget.c