From patchwork Tue Dec 6 08:06:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 86706 Delivered-To: patches@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1894903qgi; Tue, 6 Dec 2016 00:06:32 -0800 (PST) X-Received: by 10.84.209.173 with SMTP id y42mr130870455plh.94.1481011592171; Tue, 06 Dec 2016 00:06:32 -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 k9si18516706pli.242.2016.12.06.00.06.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Dec 2016 00:06:32 -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 3so146804709pgd.0 for ; Tue, 06 Dec 2016 00:06:32 -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=K0iZU+cY9xJclITv6KFOhosURyp4UYjO3NbEI/qfrIY=; b=QlW9RPavYbxtSVkHIR/gyFB4r8ZjCuejvgRfYGFtoWJE+Re/a+yNU6vHGY/DxyxwtM ANG0PmsMPJeUjs2fhN3LMyvCm2bSA5VXOj9AEeqJPCDasouKLp90JCy5BQxq9DTpPLGr /5aiVBk50i59a1XJbBa1F7jlXVh61i2Rtyi7c= 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=K0iZU+cY9xJclITv6KFOhosURyp4UYjO3NbEI/qfrIY=; b=E+iuOSDQqMMHEVZQL5PkaTW+s8ilM5o79hDd7x7nc3bm2/vPalNV8/tlu4YWTAAS3L NTx49KUsUAIPHApWez/mM+wMBTvw7yGvz8wVgQI/u27Lyr7BrWVNzvtmZmMJKA+LJ84o QzpMAA+lHP5Nw+RXdPDcix+/vWPsjbzdns2tdF+iX9IjwyAsD/3Y6gvJDQiQyRg99Eix DiHDfn01+cQjLAATtYINawn7UHKDP2jwmD/80RmiuzrfWiiukcLa9DGs1+//2yNbgZKZ SY3PsDyVSah4E/KA8ZfhAxgq/T9Bj5m/KWJNxmnN0R4dNjR0uFMHuMs1H/Fo/oQPkyQE PPeA== X-Gm-Message-State: AKaTC02lTpjrU9tVfjBjfJ9SFVW2bCcGMBNx9Re07K4dMJziijKnxxpb9tFYDRSxGhiyWa1l0Ak= X-Received: by 10.84.216.6 with SMTP id m6mr135398804pli.130.1481011591879; Tue, 06 Dec 2016 00:06:31 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id q145sm32546834pfq.22.2016.12.06.00.06.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Dec 2016 00:06:31 -0800 (PST) From: John Stultz To: lkml Cc: Chen Yu , Wei Xu , Guodong Xu , Amit Pundir , Rob Herring , John Youn , Douglas Anderson , Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org, John Stultz Subject: [RFC][PATCH 3/3 v2] usb: dwc2: Force port resume on switching to device mode Date: Tue, 6 Dec 2016 00:06:22 -0800 Message-Id: <1481011582-7162-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481011582-7162-1-git-send-email-john.stultz@linaro.org> References: <1481011582-7162-1-git-send-email-john.stultz@linaro.org> From: Chen Yu We've seen failures when switching between host and gadget mode, which was diagnosed as being caused due to the bus being auto-suspended when we switched. So this patch forces a port resume when switching to device mode if the bus is suspended. Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: Rob Herring Cc: John Youn Cc: Douglas Anderson Cc: Chen Yu Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Signed-off-by: Chen Yu Signed-off-by: John Stultz --- drivers/usb/dwc2/hcd.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.7.4 diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 75ddfa3..0221534 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -55,6 +55,9 @@ #include "core.h" #include "hcd.h" + +static void dwc2_port_resume(struct dwc2_hsotg *hsotg); + /* * ========================================================================= * Host Core Layer Functions @@ -3205,6 +3208,11 @@ static void dwc2_conn_id_status_change(struct work_struct *work) if (gotgctl & GOTGCTL_CONID_B) { /* Wait for switch to device mode */ dev_dbg(hsotg->dev, "connId B\n"); + if (hsotg->bus_suspended) { + dev_info(hsotg->dev, + "Do port resume before switching to device mode\n"); + dwc2_port_resume(hsotg); + } while (!dwc2_is_device_mode(hsotg)) { dev_info(hsotg->dev, "Waiting for Peripheral Mode, Mode=%s\n",