From patchwork Tue Nov 15 21:47:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 82419 Delivered-To: patches@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1753160qge; Tue, 15 Nov 2016 13:47:42 -0800 (PST) X-Received: by 10.99.176.14 with SMTP id h14mr480934pgf.22.1479246462674; Tue, 15 Nov 2016 13:47:42 -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 l78si28169410pfg.206.2016.11.15.13.47.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Nov 2016 13:47:42 -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 p66so70871721pga.2 for ; Tue, 15 Nov 2016 13:47:42 -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=KmLgj4yqCT8GaKUdozPc6/G7TDYDsE1nTCvvIJcUFRs=; b=Talg81smV4IlfyDCizoGoza/HVqIAInYp+liu9o0JgII/52L08Nf5kRq8TEOOv2Pvx J1QrFuhvMgDWWYEhGc94s08zC7Vv1IT3PkJfERvtBf96RLF23VgretpR4JRtkgaG5cL3 EwtWaHPLrbdMYKfu00NyqsuAz7h+HxD5C6LQU= 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=KmLgj4yqCT8GaKUdozPc6/G7TDYDsE1nTCvvIJcUFRs=; b=dslekkP8SE76xSiKMRHPpAfoCNqYRWHezllo+TdaLwgOryNBHn40MoRHAyGqgC7n9N hRSDZiecaTWhmQ2B7ht53Pgqg0mNCafd76kqFu+hWtUVFvIiXOwy+q0IORxlYYHfnCwz FF4Iko3v2D/NCaqC9f47VrAk7NsNPi2j6QnzBbG0wQEegESqupatzAcwf6+SNscLQxbI gww8EuHCUx8h7vg7jOjsCvPUnQ9e/MVxA/QSaZrofvwB3WA6xLEv8h23YB6NEJoOZrbd r3VFBMBQNJLr5sqxDgc8Iafc7xpjlgtR7PYCD7X7A9T7F8u/ObxuarVkSedl+BuFcq8q cp8Q== X-Gm-Message-State: ABUngvdLg6jcpAUE7jxyC9zkNTJ3c6mdAypppNOEheiZaoFB+n36IHo/41uECDsPTqIGdfy3unM= X-Received: by 10.98.75.11 with SMTP id y11mr50340930pfa.30.1479246462375; Tue, 15 Nov 2016 13:47:42 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id q9sm46049156pfg.47.2016.11.15.13.47.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Nov 2016 13:47:41 -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] usb: dwc2: Avoid suspending if we're in gadget mode Date: Tue, 15 Nov 2016 13:47:35 -0800 Message-Id: <1479246456-21652-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479246456-21652-1-git-send-email-john.stultz@linaro.org> References: <1479246456-21652-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 b374e60..8c980fd 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4373,6 +4373,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;