From patchwork Mon Jan 9 21:10:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Youn X-Patchwork-Id: 90584 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp279006qgi; Mon, 9 Jan 2017 13:10:29 -0800 (PST) X-Received: by 10.84.217.2 with SMTP id o2mr181093178pli.99.1483996229365; Mon, 09 Jan 2017 13:10:29 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1si80971697ple.165.2017.01.09.13.10.29; Mon, 09 Jan 2017 13:10:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941218AbdAIVK1 (ORCPT + 4 others); Mon, 9 Jan 2017 16:10:27 -0500 Received: from smtprelay4.synopsys.com ([198.182.47.9]:32836 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938564AbdAIVK1 (ORCPT ); Mon, 9 Jan 2017 16:10:27 -0500 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 060DA24E0368; Mon, 9 Jan 2017 13:10:25 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id C70D0856; Mon, 9 Jan 2017 13:10:25 -0800 (PST) Received: from US01WEHTC3.internal.synopsys.com (us01wehtc3.internal.synopsys.com [10.15.84.232]) by mailhost.synopsys.com (Postfix) with ESMTP id ADEA2855; Mon, 9 Jan 2017 13:10:25 -0800 (PST) Received: from US01WEHTC1.internal.synopsys.com (10.12.239.235) by US01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP Server (TLS) id 14.3.266.1; Mon, 9 Jan 2017 13:10:25 -0800 Received: from starbug (10.13.184.20) by us01wehtc1.internal.synopsys.com (10.12.239.236) with Microsoft SMTP Server (TLS) id 14.3.266.1; Mon, 9 Jan 2017 13:10:24 -0800 Received: by starbug (sSMTP sendmail emulation); Mon, 09 Jan 2017 13:10:24 -0800 Date: Mon, 9 Jan 2017 13:10:24 -0800 Message-ID: <55433b92afe5538c998ea64042680e4d4a666fe9.1483996131.git.johnyoun@synopsys.com> In-Reply-To: References: From: John Youn Subject: [PATCH 3/3] usb: dwc2: Avoid suspending if we're in gadget mode To: John Youn , Felipe Balbi , CC: Rob Herring , Kishon Vijay Abraham I , Amit Pundir , John Stultz , Wei Xu , Guodong Xu , Chen Yu , Douglas Anderson MIME-Version: 1.0 X-Originating-IP: [10.13.184.20] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: John Stultz 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. Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: Rob Herring Cc: John Youn Cc: Douglas Anderson Cc: Chen Yu Cc: Kishon Vijay Abraham I Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Suggested-by: Chen Yu Signed-off-by: John Stultz Signed-off-by: John Youn --- drivers/usb/dwc2/hcd.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 911c3b36ac06..8b264d4aaaeb 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4367,6 +4367,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->params.hibernation) goto skip_power_saving;