From patchwork Tue Dec 6 08:06:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 86705 Delivered-To: patches@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1894890qgi; Tue, 6 Dec 2016 00:06:31 -0800 (PST) X-Received: by 10.99.218.85 with SMTP id l21mr110268285pgj.102.1481011590965; Tue, 06 Dec 2016 00:06:30 -0800 (PST) Return-Path: Received: from mail-pg0-x22e.google.com (mail-pg0-x22e.google.com. [2607:f8b0:400e:c05::22e]) by mx.google.com with ESMTPS id p64si18505778pfa.181.2016.12.06.00.06.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Dec 2016 00:06:30 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22e as permitted sender) client-ip=2607:f8b0:400e:c05::22e; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22e as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x22e.google.com with SMTP id x23so146776003pgx.1 for ; Tue, 06 Dec 2016 00:06:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=w5jQgh9fYQJBc1iwzwi24hi2IV2msWQOzwMbRZgjV7M=; b=OqZbk/cB2iC1tPmviqNJHJbp4SD7WMkHw+qGtwFeXDoxbTXSxminmd27Xtsy5f12+u ycbFuxXG8n42D+qPqznN6AWQcfnuo+wuNxYnY93k2+iIi0qZpMGbnH2GPXXj72osr0Yp bfIa9DsjE1XQq30Yx8/d1OPJ+viO25tUsfXjg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=w5jQgh9fYQJBc1iwzwi24hi2IV2msWQOzwMbRZgjV7M=; b=OXUDoEqkhFBapL1q0wSd2SU3iqxLh8mO43NEjZl0igW7m+sGo27tOPGIwA+q/0IHlg 8XpZNWrP7A9NYslzvO6DbrZ6UCPuit+HHrglwiH6KyQZwFV3QuQrSBQpOmOWlBPcKBBp eZ9y7yMIWkzVvYKyTza3arftlF9/BUgXbUAeU4PDGiXNs1sjiy0BwQLdLIegLnLf0+3x Zq9C+A/gkUhOXI9OEEuoVCXBL0glol62StHkwd9+Rgptj7du9DBG3317lSD9DoSlU+TP sjLsMDcDyec56CF7WU//4LkHRNtsxM17Kj+p3JPkpW0yqYDiwSI3C0UTQrah2NBPdTPk uv9Q== X-Gm-Message-State: AKaTC017oSuJhGQcqlRL3KsFaic5DrP9gQE9ZVTa1zEMTFdZxkz3kE2MaXcJw5zwU39lsjHYdjk= X-Received: by 10.98.198.85 with SMTP id m82mr61897911pfg.69.1481011590646; Tue, 06 Dec 2016 00:06:30 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id q145sm32546834pfq.22.2016.12.06.00.06.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Dec 2016 00:06:30 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Wei Xu , Guodong Xu , Amit Pundir , Rob Herring , John Youn , Douglas Anderson , Chen Yu , Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [RFC][PATCH 2/3 v2] usb: dwc2: Avoid suspending if we're in gadget mode Date: Tue, 6 Dec 2016 00:06:21 -0800 Message-Id: <1481011582-7162-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481011582-7162-1-git-send-email-john.stultz@linaro.org> References: <1481011582-7162-1-git-send-email-john.stultz@linaro.org> I've found when booting HiKey with the usb gadget cable attached if I then try to connect via adb, I get an infinite spew of: dwc2 f72c0000.usb: dwc2_hsotg_ep_sethalt(ep ffffffc0790ecb18 ep1out, 0) dwc2 f72c0000.usb: dwc2_hsotg_ep_sethalt(ep ffffffc0790eca18 ep1in, 0) It seems that the usb autosuspend is suspending the bus shortly after bootup when the gadget cable is attached. So when adbd then tries to use the device, it doesn't work and it then tries to restart it over and over via the ep_sethalt calls (via FUNCTIONFS_CLEAR_HALT ioctl). Chen Yu suggested this patch to avoid suspending if we're in device mode, and it avoids the problem. This doesn't remove the need for the previous patch, to resume the port when we switch to gadget mode from host mode. But it does seem to resolve the issue. Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: Rob Herring Cc: John Youn Cc: Douglas Anderson Cc: Chen Yu Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Suggested-by: Chen Yu Signed-off-by: John Stultz --- drivers/usb/dwc2/hcd.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.7.4 diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 61eea70..75ddfa3 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4386,6 +4386,9 @@ static int _dwc2_hcd_suspend(struct usb_hcd *hcd) if (!HCD_HW_ACCESSIBLE(hcd)) goto unlock; + if (hsotg->op_state == OTG_STATE_B_PERIPHERAL) + goto unlock; + if (!hsotg->core_params->hibernation) goto skip_power_saving;