From patchwork Sat Dec 17 05:31:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 88357 Delivered-To: patches@linaro.org Received: by 10.140.20.101 with SMTP id 92csp180152qgi; Fri, 16 Dec 2016 21:32:02 -0800 (PST) X-Received: by 10.84.197.129 with SMTP id n1mr14615214pld.30.1481952722929; Fri, 16 Dec 2016 21:32:02 -0800 (PST) Return-Path: Received: from mail-pg0-x233.google.com (mail-pg0-x233.google.com. [2607:f8b0:400e:c05::233]) by mx.google.com with ESMTPS id e3si10987055pld.173.2016.12.16.21.32.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Dec 2016 21:32:02 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::233 as permitted sender) client-ip=2607:f8b0:400e:c05::233; 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::233 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x233.google.com with SMTP id p66so39688369pga.2 for ; Fri, 16 Dec 2016 21:32:02 -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=gLwTpP5P8VidrBWHoiNH7TU+6Y/chE5qXvTa7uZvxRA=; b=BhHfQttgBJFfigx6moBcjZ+TRmWYjg/bLt7a4X4TB1n+2XUy3IwuRvwI2xpIvpIYYZ VoCA/1rifJnFWzw5tGXC4FD5Q9krJoqjpuuzXJYc+FK5c2ulVvyLauyx5tmVbSSW6lp6 hjnh2mehNbGBTKymbvuZLKgF8LK3Olcu3cAYY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gLwTpP5P8VidrBWHoiNH7TU+6Y/chE5qXvTa7uZvxRA=; b=MpUoDy9fyOmqsRIDMCQjsYh9K9DRjVDZEMhOAHEQSv5XcbESZhXxKItO5h97bjo3dX RwHjkwCAMO+nfj8EXHRXC1uTr026RiBjU8yUT8pCmcoYrldTL/+4upx0SGQB4IFmaPg8 q9MpPye4+IQL3VPgN57crGij5TszHEawSEVtCdq2dzTZzIx29GJfVtfW8YXaqqVk4M2o YufzLoHjzUpMlF//Mb6HovlWn0nZPuPXW9XMEz7ZLSN1yrVn++wd7SldUB3/xyI12Slb bNz5sZ+NX+B83zDW8WRJLPApf/h8A0E09HE8IWLIEeTY7dE4FE2E+Z1TlLnav+krOh3c jiYA== X-Gm-Message-State: AKaTC008MIE2Mhj42388TfPMXU22i/N7rCKMjhDrr2yda7Yv6nzkzKp7s8pQ/4iMcDb6kZ8r5I4= X-Received: by 10.84.175.234 with SMTP id t97mr14464594plb.145.1481952722648; Fri, 16 Dec 2016 21:32:02 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id 72sm15475350pfw.37.2016.12.16.21.32.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Dec 2016 21:32:02 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Wei Xu , Guodong Xu , Amit Pundir , Rob Herring , John Youn , Douglas Anderson , Chen Yu , Vardan Mikayelyan , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [RFC][PATCH 4/5 v2] usb: dwc2: Avoid suspending if we're in gadget mode Date: Fri, 16 Dec 2016 21:31:52 -0800 Message-Id: <1481952713-29829-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481952713-29829-1-git-send-email-john.stultz@linaro.org> References: <1481952713-29829-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: Vardan Mikayelyan 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 a089946..6e4ec8a 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4383,6 +4383,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;