UPSTREAM: usb: dwc2: host: Clear interrupts before handling them
authorDouglas Anderson <dianders@chromium.org>
Fri, 20 Nov 2015 17:06:28 +0000 (09:06 -0800)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 3 Jan 2017 10:47:19 +0000 (18:47 +0800)
commit5f4369f3769c424db44d2ecfc4f8329868f16813
tree4d05f478981ccb17e44f97db46af55f765973551
parent4b7440cc72276d2f7b9e805d809e5a48ae48cf6e
UPSTREAM: usb: dwc2: host: Clear interrupts before handling them

In general it is wise to clear interrupts before processing them.  If
you don't do that, you can get:
 1. Interrupt happens
 2. You look at system state and process interrupt
 3. A new interrupt happens
 4. You clear interrupt without processing it.

This patch was actually a first attempt to fix missing device insertions
as described in (usb: dwc2: host: Fix missing device insertions) and it
did solve some of the signal bouncing problems but not all of
them (which is why I submitted the other patch).  Specifically, this
patch itself would sometimes change:
 1. hardware sees connect
 2. hardware sees disconnect
 3. hardware sees connect
 4. dwc2_port_intr() - clears connect interrupt
 5. dwc2_handle_common_intr() - calls dwc2_hcd_disconnect()

...to:
 1. hardware sees connect
 2. hardware sees disconnect
 3. dwc2_port_intr() - clears connect interrupt
 4. hardware sees connect
 5. dwc2_handle_common_intr() - calls dwc2_hcd_disconnect()

...but with different timing then sometimes we'd still miss cable
insertions.

In any case, though this patch doesn't fix any (known) problems, it
still seems wise as a general policy to clear interrupt before handling
them.

Note that for dwc2_handle_usb_port_intr(), instead of moving the clear
of PRTINT to the beginning of the function we remove it completely.  The
only way to clear PRTINT is to clear the sources that set it in the
first place.

Change-Id: I94b427aa819f477930287c8c3e85d14e80891f86
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 29539019b46f0e5f64f80f2e9dc8f9bb34d16b4b)
drivers/usb/dwc2/core_intr.c
drivers/usb/dwc2/hcd_intr.c