950-0139-usb-dwc2-Avoid-suspending-if-we-re-in-gadget-mode-18.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From 2ca9749f5b4326dad52756eaf5e7865504b4d374 Mon Sep 17 00:00:00 2001
  2. From: ED6E0F17 <[email protected]>
  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. I've found when booting HiKey with the usb gadget cable attached
  6. if I then try to connect via adb, I get an infinite spew of:
  7. dwc2 f72c0000.usb: dwc2_hsotg_ep_sethalt(ep ffffffc0790ecb18 ep1out, 0)
  8. dwc2 f72c0000.usb: dwc2_hsotg_ep_sethalt(ep ffffffc0790eca18 ep1in, 0)
  9. It seems that the usb autosuspend is suspending the bus shortly
  10. after bootup when the gadget cable is attached. So when adbd
  11. then tries to use the device, it doesn't work and it then tries
  12. to restart it over and over via the ep_sethalt calls (via
  13. FUNCTIONFS_CLEAR_HALT ioctl).
  14. Chen Yu suggested this patch to avoid suspending if we're
  15. in device mode, and it avoids the problem.
  16. Cc: Wei Xu <[email protected]>
  17. Cc: Guodong Xu <[email protected]>
  18. Cc: Amit Pundir <[email protected]>
  19. Cc: Rob Herring <[email protected]>
  20. Cc: John Youn <[email protected]>
  21. Cc: Douglas Anderson <[email protected]>
  22. Cc: Chen Yu <[email protected]>
  23. Cc: Kishon Vijay Abraham I <[email protected]>
  24. Cc: Felipe Balbi <[email protected]>
  25. Cc: Greg Kroah-Hartman <[email protected]>
  26. Cc: [email protected]
  27. Suggested-by: Chen Yu <[email protected]>
  28. Signed-off-by: John Stultz <[email protected]>
  29. Signed-off-by: John Youn <[email protected]>
  30. Signed-off-by: Felipe Balbi <[email protected]>
  31. ---
  32. drivers/usb/dwc2/hcd.c | 3 +++
  33. 1 file changed, 3 insertions(+)
  34. --- a/drivers/usb/dwc2/hcd.c
  35. +++ b/drivers/usb/dwc2/hcd.c
  36. @@ -4381,6 +4381,9 @@ static int _dwc2_hcd_suspend(struct usb_
  37. if (!HCD_HW_ACCESSIBLE(hcd))
  38. goto unlock;
  39. + if (hsotg->op_state == OTG_STATE_B_PERIPHERAL)
  40. + goto unlock;
  41. +
  42. if (!hsotg->core_params->hibernation)
  43. goto skip_power_saving;