From patchwork Tue Dec 13 07:09: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: 87797 Delivered-To: patches@linaro.org Received: by 10.140.20.101 with SMTP id 92csp2060689qgi; Mon, 12 Dec 2016 23:09:58 -0800 (PST) X-Received: by 10.84.192.131 with SMTP id c3mr196981316pld.149.1481612997976; Mon, 12 Dec 2016 23:09:57 -0800 (PST) Return-Path: Received: from mail-pg0-x22c.google.com (mail-pg0-x22c.google.com. [2607:f8b0:400e:c05::22c]) by mx.google.com with ESMTPS id l33si47093190pld.41.2016.12.12.23.09.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Dec 2016 23:09:57 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22c as permitted sender) client-ip=2607:f8b0:400e:c05::22c; 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::22c as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x22c.google.com with SMTP id f188so44584721pgc.3 for ; Mon, 12 Dec 2016 23:09:57 -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=HXwNGbDaOGkm3b/JeaMd5oZf8Q9S0a5sehntQulTGIU=; b=ABRIg/+u6RbP3X7ZWA6Eo5Dd+UbRGMTMQwSibuaCku9RDCJkbgipE+MukFvJMizlne dAw88cGtSfxZuUQOxVxNXiFoAyjuadyD6iN4cHvS6IN+0RZIeZfHSW+DcJH7rrFcOV57 cAGisEo/KDStyELC0ioPqEDQhUbmop8hAHfS8= 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=HXwNGbDaOGkm3b/JeaMd5oZf8Q9S0a5sehntQulTGIU=; b=gFBXanw27lZZmpbrYK+Bk/R2IxDhbF4MqZ1UL4ssXG5I7QbhdQfzXiP9Sq7ksH/3CD Zv5Z2aGLbdx9GTmX4LWAqBYzUkl+B+aEp1Hmx70yZUa3t7vVB6/jUoSdfE097s6T3Chq JYmlhhFIaYB291EU/0Mfaxg3jbp+pfn3PhiG9M7oiqXfM3pzasb4gergQmFJAxtncBTH WyiIxPzvDqtxDKR/FvVuUSuxqmJQQ/cetv71y0Jx0toxRyEtu1YHO10zZArkd3FltMrD 2TQlMYeglsN0Pcn+2hfJAxT1h0G/ZWDCsde7tMtWuDB2RcEX5aNk6xKqVUrLyo1p7gqm RXfA== X-Gm-Message-State: AKaTC00Xih/XBVQA5IOYLEWKlW+YEiV6Ht95o0HHkZx57tm3qhRCZXV/ZdjywiTeQta4hMJtW54= X-Received: by 10.99.39.132 with SMTP id n126mr174705195pgn.85.1481612997663; Mon, 12 Dec 2016 23:09:57 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id 13sm79190204pfz.30.2016.12.12.23.09.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Dec 2016 23:09:57 -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 4/5] usb: dwc2: Avoid suspending if we're in gadget mode Date: Mon, 12 Dec 2016 23:09:49 -0800 Message-Id: <1481612990-23409-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481612990-23409-1-git-send-email-john.stultz@linaro.org> References: <1481612990-23409-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: 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 24db997..008f5bc 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4375,6 +4375,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;