linux/drivers/usb/dwc3
Thinh Nguyen 1c57b8f051 usb: dwc3: gadget: Prevent losing events in event cache
commit d325a1de49 upstream.

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.

Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2017-09-15 18:29:39 +01:00
..
core.c usb: dwc3: core: fix ordering for PHY suspend 2014-10-05 13:40:59 -07:00
core.h usb: dwc3: Fix assignment of EP transfer resources 2016-03-08 12:15:22 +00:00
debug.h usb: dwc3: switch to GPL v2 only 2013-07-29 13:56:44 +03:00
debugfs.c usb: dwc3: switch to GPL v2 only 2013-07-29 13:56:44 +03:00
dwc3-exynos.c usb: dwc3: exynos: Fix deferred probing storm. 2016-08-22 22:38:11 +01:00
dwc3-keystone.c usb: dwc3: keystone: drop dma_mask configuration 2016-05-01 00:06:09 +02:00
dwc3-omap.c usb: dwc3: dwc3-omap: Fix disable IRQ 2015-03-18 14:41:51 +00:00
dwc3-pci.c usb: dwc3: convert to pcim_enable_device() 2014-05-15 10:26:38 -05:00
ep0.c usb: dwc3: ep0: explicitly call dwc3_ep0_prepare_one_trb() 2017-03-16 02:26:41 +00:00
gadget.c usb: dwc3: gadget: Prevent losing events in event cache 2017-09-15 18:29:39 +01:00
gadget.h usb: dwc3: gadget: make Set Endpoint Configuration macros safe 2017-07-18 18:40:07 +01:00
host.c usb: dwc3: switch to GPL v2 only 2013-07-29 13:56:44 +03:00
io.h usb: dwc3: switch to GPL v2 only 2013-07-29 13:56:44 +03:00
Kconfig usb: dwc3: dwc3-omap: Fix the crash on module removal 2014-06-19 10:06:28 -05:00
Makefile usb: dwc3: add Keystone specific glue layer 2013-12-12 13:43:07 -06:00
platform_data.h usb: dwc3: adapt to use dr_mode device tree helper 2013-07-29 13:56:51 +03:00