From patchwork Tue Jan 3 19:52:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 89732 Delivered-To: patches@linaro.org Received: by 10.140.20.101 with SMTP id 92csp8169825qgi; Tue, 3 Jan 2017 11:52:47 -0800 (PST) X-Received: by 10.98.133.9 with SMTP id u9mr58919329pfd.137.1483473167732; Tue, 03 Jan 2017 11:52:47 -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 p20si53479859pli.180.2017.01.03.11.52.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jan 2017 11:52:47 -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 g1so178868383pgn.0 for ; Tue, 03 Jan 2017 11:52:47 -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=IS2cJHHn5dGiP0XD1kCipplWDXSa8DOIySGaY2UE92fLvVGnQzXkhJgXN6wcly4UBQ l3IBFOd5V7N1G3jDBRIAuGAN8FGtiFH0del3/7uEXQvsdjl0u+cOutzrrwUFkPOYLsmO s/+9wdo0RyOvanxyG98xLRO06xoOFbxAnEVxU= 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=hP7ygXrZfWCT9uKwlTdrBAfaYs2vUZCxx1TKho3mWxI72sZqbxoKpQHc2ydeky0j5O cV9Fh/2rvP0mDC6ono1RWONpl/lfX77z/ynw+vrPuqBnroWBs+yF5PoUFD5CUpAyijtt inMAnLw151wmipOQDHrrKSp9Y83f/OzGLxtWZvX+5BYwp7ffKhW1fHYRBqsB8Mm988X1 l7UUHXCEWiU7s12IhXsBIvPb/s1t3B2Ds2eV8FoWsHtsfV26/iGecxmniRougZYig3ta +dS1rr11ghopAiytX4WiqSCfiKjtG5kVyI1wjXnvBBpc17bcpKbzsArZFfWrVRF1Z5Pt AjLg== X-Gm-Message-State: AIkVDXIm13CrwoYVdK1qHL72v+P9rYZ+0hkFBvjs/lP1iFlkth16ZLeNr2nNZMMZr3Hnpd+/esE= X-Received: by 10.98.64.10 with SMTP id n10mr59570360pfa.168.1483473167402; Tue, 03 Jan 2017 11:52:47 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id r1sm93771794pgn.48.2017.01.03.11.52.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Jan 2017 11:52:46 -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: [PATCH 4/5 v2] usb: dwc2: Avoid suspending if we're in gadget mode Date: Tue, 3 Jan 2017 11:52:36 -0800 Message-Id: <1483473157-16678-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483473157-16678-1-git-send-email-john.stultz@linaro.org> References: <1483473157-16678-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;