UPSTREAM: usb: dwc2: host: Fix missing device insertions
authorDouglas Anderson <dianders@chromium.org>
Thu, 19 Nov 2015 21:23:14 +0000 (13:23 -0800)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 3 Jan 2017 09:50:49 +0000 (17:50 +0800)
commit0ed2976a586c34a85cab3e01856ea46eef9e6a55
tree99c816294ced7213feda1e134231c5280510a7c0
parentc8785364d103d5c5d22d1f760025d9e531c7e84d
UPSTREAM: usb: dwc2: host: Fix missing device insertions

If you've got your interrupt signals bouncing a bit as you insert your
USB device, you might end up in a state when the device is connected but
the driver doesn't know it.

Specifically, the observed order is:
 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()

Now you'll be stuck with the cable plugged in and no further interrupts
coming in but the driver will think we're disconnected.

We'll fix this by checking for the missing connect interrupt and
re-connecting after the disconnect is posted.  We don't skip the
disconnect because if there is a transitory disconnect we really want to
de-enumerate and re-enumerate.

Notes:
1. As part of this change we add a "force" parameter to
   dwc2_hcd_disconnect() so that when we're unloading the module we
   avoid the new behavior.  The need for this was pointed out by John
   Youn.
2. The bit of code needed at the end of dwc2_hcd_disconnect() is
   exactly the same bit of code from dwc2_port_intr().  To avoid
   duplication, we refactor that code out into a new function
   dwc2_hcd_connect().

Change-Id: Ibe9c7d62b2b35f5666ffcde75a65e7fca9f6805a
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Acked-by: John Youn <johnyoun@synopsys.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 6a6595318ac2dd169d2931a1d9431a64f4ada75c)
drivers/usb/dwc2/core.h
drivers/usb/dwc2/core_intr.c
drivers/usb/dwc2/hcd.c
drivers/usb/dwc2/hcd_intr.c