1ed31c2d2eb147df3ba809e8ee48af62dd03bc17
[openwrt/staging/981213.git] /
1 From 2ca9749f5b4326dad52756eaf5e7865504b4d374 Mon Sep 17 00:00:00 2001
2 From: ED6E0F17 <edge@karikoa.net>
3 Date: Fri, 3 Feb 2017 14:52:42 +0000
4 Subject: [PATCH] usb: dwc2: Avoid suspending if we're in gadget mode (#1825)
5
6 I've found when booting HiKey with the usb gadget cable attached
7 if I then try to connect via adb, I get an infinite spew of:
8
9 dwc2 f72c0000.usb: dwc2_hsotg_ep_sethalt(ep ffffffc0790ecb18 ep1out, 0)
10 dwc2 f72c0000.usb: dwc2_hsotg_ep_sethalt(ep ffffffc0790eca18 ep1in, 0)
11
12 It seems that the usb autosuspend is suspending the bus shortly
13 after bootup when the gadget cable is attached. So when adbd
14 then tries to use the device, it doesn't work and it then tries
15 to restart it over and over via the ep_sethalt calls (via
16 FUNCTIONFS_CLEAR_HALT ioctl).
17
18 Chen Yu suggested this patch to avoid suspending if we're
19 in device mode, and it avoids the problem.
20
21 Cc: Wei Xu <xuwei5@hisilicon.com>
22 Cc: Guodong Xu <guodong.xu@linaro.org>
23 Cc: Amit Pundir <amit.pundir@linaro.org>
24 Cc: Rob Herring <robh+dt@kernel.org>
25 Cc: John Youn <johnyoun@synopsys.com>
26 Cc: Douglas Anderson <dianders@chromium.org>
27 Cc: Chen Yu <chenyu56@huawei.com>
28 Cc: Kishon Vijay Abraham I <kishon@ti.com>
29 Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
30 Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31 Cc: linux-usb@vger.kernel.org
32 Suggested-by: Chen Yu <chenyu56@huawei.com>
33 Signed-off-by: John Stultz <john.stultz@linaro.org>
34 Signed-off-by: John Youn <johnyoun@synopsys.com>
35 Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
36 ---
37 drivers/usb/dwc2/hcd.c | 3 +++
38 1 file changed, 3 insertions(+)
39
40 --- a/drivers/usb/dwc2/hcd.c
41 +++ b/drivers/usb/dwc2/hcd.c
42 @@ -4365,6 +4365,9 @@ static int _dwc2_hcd_suspend(struct usb_
43 if (!HCD_HW_ACCESSIBLE(hcd))
44 goto unlock;
45
46 + if (hsotg->op_state == OTG_STATE_B_PERIPHERAL)
47 + goto unlock;
48 +
49 if (!hsotg->core_params->hibernation)
50 goto skip_power_saving;
51