From patchwork Wed Nov 23 03:46:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 83529 Delivered-To: patches@linaro.org Received: by 10.140.97.165 with SMTP id m34csp2443997qge; Tue, 22 Nov 2016 19:46:56 -0800 (PST) X-Received: by 10.84.216.17 with SMTP id m17mr2329003pli.82.1479872816504; Tue, 22 Nov 2016 19:46:56 -0800 (PST) Return-Path: Received: from mail-pg0-x236.google.com (mail-pg0-x236.google.com. [2607:f8b0:400e:c05::236]) by mx.google.com with ESMTPS id 2si2978869pld.0.2016.11.22.19.46.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Nov 2016 19:46:56 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::236 as permitted sender) client-ip=2607:f8b0:400e:c05::236; 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::236 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x236.google.com with SMTP id 3so776414pgd.0 for ; Tue, 22 Nov 2016 19:46:56 -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=O4y+5dCjHpz8xbIYWplhy58SYC5w4nRSsYg30DAEc8I=; b=Kuz9AUnMKCGRa8ek7Fjj1/Aitzx63yPYW1nTFr87vb9bPPs9sAOEdJjk8IfGIW9l7U Ix8V3w/dnsSPUolLRGNttO3EGLNz/TjdFCxke37fRk8w6Tzo+8rQ2lsGmZUVqHaF02se 7AyYwas65BWpIUkWU933TTpR+AqpnGdr7nsEY= 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=O4y+5dCjHpz8xbIYWplhy58SYC5w4nRSsYg30DAEc8I=; b=LlyjzIPfsIdkMO5xbi87yU2CThEytrKZ7fjoNp79XdMa2h6hg3Ry/kdZKQVztpmDsc +ld3X9UpV7Kf0gTXcAmMD8PQFzXCyuZcEVplEHosGnFKDCGukwp84RJd+Trv4XWUH270 gY5gVirBjgi8udKAmFXqaICf4rEKHRz4Brj2fL9q1AlsSogtCAQ8VTGReFN3IdvP5i6b sOHgXmhjWG5ZgB958FmECKaQLWqcFwTB6M7RESJyE2CYS4/NVjoN/cio1xR4C4IEecVr 3zm78ya3gR6H2K1ABlPSqopsw+BlnNNLuMgV+2lWw9VC2M51oXFs9cjL8GYlMzr4+Wah cD2g== X-Gm-Message-State: AKaTC03fO3Sqp4gpV5ORTwImsIKPeNSSXekHjpuMXKSwppEyYF/nr5BqFdJ0eHsM2GMf3txMyRk= X-Received: by 10.99.251.5 with SMTP id o5mr1840135pgh.152.1479872816223; Tue, 22 Nov 2016 19:46:56 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id l11sm48282533pfb.28.2016.11.22.19.46.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Nov 2016 19:46:55 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Wei Xu , Guodong Xu , Amit Pundir , Rob Herring , John Youn , Douglas Anderson , Chen Yu , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [RFC][PATCH 3/3] usb: dwc2: Avoid suspending if we're in gadget mode Date: Tue, 22 Nov 2016 19:46:49 -0800 Message-Id: <1479872809-11958-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479872809-11958-1-git-send-email-john.stultz@linaro.org> References: <1479872809-11958-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. 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 --- 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 df5a065..619ccfe 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4365,6 +4365,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;