From patchwork Sat Dec 17 05:31:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 88356 Delivered-To: patches@linaro.org Received: by 10.140.20.101 with SMTP id 92csp180144qgi; Fri, 16 Dec 2016 21:32:01 -0800 (PST) X-Received: by 10.84.129.34 with SMTP id 31mr14785258plb.104.1481952721887; Fri, 16 Dec 2016 21:32:01 -0800 (PST) Return-Path: Received: from mail-pg0-x22b.google.com (mail-pg0-x22b.google.com. [2607:f8b0:400e:c05::22b]) by mx.google.com with ESMTPS id w2si10982952pfg.122.2016.12.16.21.32.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Dec 2016 21:32:01 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22b as permitted sender) client-ip=2607:f8b0:400e:c05::22b; 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::22b as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x22b.google.com with SMTP id g1so98219pgn.0 for ; Fri, 16 Dec 2016 21:32:01 -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=5kNrRWNQWLOIc1G6STXMG28a4SUWbah8bzCC4gOziF4=; b=dL8rtdaSXJ7Fj+8OgFhb1XNvKHzBxD/PhYGqaku0red9xtOuesfxjOusPSst4gPSMy Ot3/t4myf8U7S/9xbK8xq+OmEVHifb2AUdFIQiiwX/aqzfv/gPCTze5aow2x6wtiQPav 576rCMRyA9kPI1ihAJ1+DvtE5lpBTBugDIGsY= 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=5kNrRWNQWLOIc1G6STXMG28a4SUWbah8bzCC4gOziF4=; b=UL3JFFRMIzDu9VkrP3XDS6i6BrBTmy4wVYJnZ1cwADkwouSxrqdBaehawnHlUZmrso CupwfpZB9wyrTKAcSeDEaB+f2olbzocer7i+5QvMpzDGMivDKTjl55XlvkvS5fyLvOek Di+nIBMwtN5lD+zkwVOoPGIQXO5fbRPlvamb2cG5VYKUDxUh7rKCGMnQlsi0ms35ZoN5 uy3Z4SeDIiqCCL9M+sGu4t0l986N7UsNwe9jmSE8LMGDBnUL1iD46Zl/7w9nu8hpzGPv 4VAyCO8KR0JOiOlqwLsttmT6TinK+sfaHNci2S5wn2Rm484e3DChAvt5pWV4DcnMfQ8j TDrQ== X-Gm-Message-State: AKaTC01eOIyIWFGVsrnqaw+63bqU+9JvabdQ+ph/uuWEhFhW2LTWncQpTFCNZYM345DpIuDo3wU= X-Received: by 10.84.202.163 with SMTP id x32mr14581220pld.46.1481952721617; Fri, 16 Dec 2016 21:32:01 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Dec 2016 21:32:00 -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: [RFC][PATCH 3/5 v2] usb: dwc2: Force port resume on switching to device mode Date: Fri, 16 Dec 2016 21:31:51 -0800 Message-Id: <1481952713-29829-4-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> 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 --- 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 b60307a..a089946 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 @@ -3235,6 +3237,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",