OSDN Git Service

usb: dwc3: Clear pending events when it is bigger than event buffer size
authorMayank Rana <mrana@codeaurora.org>
Fri, 6 Nov 2015 23:11:46 +0000 (15:11 -0800)
committerDavid Keitel <dkeitel@codeaurora.org>
Tue, 22 Mar 2016 18:06:58 +0000 (11:06 -0700)
commitcda82d5273898db9e5f44fbd7ac320851bfc372d
tree9b3f077501df6d355fbe9d2ab9372134615d2634
parent869c733233e0f449e82764b676f2172bf68bba09
usb: dwc3: Clear pending events when it is bigger than event buffer size

Currently there exists a race condition between dwc3_gadget_run_stop()
and dwc3 gadget interrupt handling. run_stop() could get cleared and set
again in between hard IRQ and threaded IRQ contexts, the DWC3_GEVNTCOUNT
could first get set to 0, and then written again in the threaded handler
with a non-zero value. Writing back to this register will cause hardware
to decrement the value, and since it is 0 will result in a high unsigned
value (~65k).

To handle this condition mark received events as processed and return
IRQ_HANDLED if events count is bigger than event buffer size. Note that
the root cause of this condition will be addressed in another patch that
prevents the race by synchronizing the hard and threaded interrupt handlers
with dwc3_gadget_run_stop() getting called asynchronously.

Change-Id: I4d6ade8243867885f26876a5233a8456a7e8bf42
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
drivers/usb/dwc3/gadget.c