From patchwork Thu Jan 12 00:22:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 91011 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1381181qgi; Wed, 11 Jan 2017 16:22:12 -0800 (PST) X-Received: by 10.98.10.198 with SMTP id 67mr13630832pfk.157.1484180532258; Wed, 11 Jan 2017 16:22:12 -0800 (PST) Return-Path: Received: from mail-pf0-x22e.google.com (mail-pf0-x22e.google.com. [2607:f8b0:400e:c00::22e]) by mx.google.com with ESMTPS id p25si6749567pli.325.2017.01.11.16.22.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jan 2017 16:22:12 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::22e as permitted sender) client-ip=2607:f8b0:400e:c00::22e; 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:c00::22e as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-pf0-x22e.google.com with SMTP id 189so2338734pfu.3 for ; Wed, 11 Jan 2017 16:22:12 -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=Rbi9Ts/I/hVOia65EnhhU2xzm5PzSy1ZkjIlMYmBXmI=; b=bTQ38oBytFVisvbMm8FeE/GGb4U+7wYVUuj3siBrejQwjCsF/o5J9MFWfbqf/NqeKh Y56DLyonF/98RY4hRBvQBmRl+ckzmd/GYsO3A47+ymam32yGX01Ghc22rToh96B9arEq sgnb6LvJZgkZO9Ax8LRrOXZoyuwPyzLrrrWvo= 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=Rbi9Ts/I/hVOia65EnhhU2xzm5PzSy1ZkjIlMYmBXmI=; b=DqpQpHYinH9IjM7QRst6EXdxxS1qtcSRLG2eF7B+J1+i9DQ7W8weE31g4gCnl4lc8w OwtVAxcIYLOs/kP5Ets0rQdzBvHRpf53sRbuWaNKwTItn4oZUVlx9UUYXWp62MVHfGbr 8hLyhkgeEVkP2EJRgYJm6rYQjGEONi7r3YXGeBGqb+bSfva7ScSO5D9gxthf1DrUf9T6 4Rv3DseaGEJPavdYwUfiLzAHHkH7WhmTepmwesUKWJvctwFEoM40MW1WGrTgtYGv3ubr 1M6fhGR8Ya2AlozhQKZ2gGTrMc9eWK7mpRDMXmrzYbJzZT8NCp2GvhhehhWP2KIN3gYm ehPA== X-Gm-Message-State: AIkVDXLz6faFH/NzC+5DJp5qkOBSxBjVccn0iOVL0faJD553/69HAq6IOS1Hjkc+wDmOmYjH/y4= X-Received: by 10.98.198.207 with SMTP id x76mr13169993pfk.33.1484180531956; Wed, 11 Jan 2017 16:22:11 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id g85sm16364419pfe.38.2017.01.11.16.22.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jan 2017 16:22:11 -0800 (PST) From: John Stultz To: lkml Cc: Chen Yu , Wei Xu , Guodong Xu , Amit Pundir , Rob Herring , John Youn , Douglas Anderson , Vardan Mikayelyan , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org, John Stultz Subject: [PATCH 3/4 v3] usb: dwc2: Force port resume on switching to device mode Date: Wed, 11 Jan 2017 16:22:03 -0800 Message-Id: <1484180524-4087-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484180524-4087-1-git-send-email-john.stultz@linaro.org> References: <1484180524-4087-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: Vardan Mikayelyan Cc: Kishon Vijay Abraham I Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Signed-off-by: Chen Yu Signed-off-by: John Stultz --- v3: * Rebased to synopsys-usb/next branch drivers/usb/dwc2/hcd.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.7.4 diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 888923c..cdf0bac 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -54,6 +54,8 @@ #include "core.h" #include "hcd.h" +static void dwc2_port_resume(struct dwc2_hsotg *hsotg); + /* * ========================================================================= * Host Core Layer Functions @@ -3232,6 +3234,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",