From patchwork Thu Oct 20 04:14:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 78395 Delivered-To: patches@linaro.org Received: by 10.140.97.247 with SMTP id m110csp585903qge; Wed, 19 Oct 2016 21:14:47 -0700 (PDT) X-Received: by 10.99.61.10 with SMTP id k10mr14609535pga.142.1476936887666; Wed, 19 Oct 2016 21:14:47 -0700 (PDT) Return-Path: Received: from mail-pf0-x22f.google.com (mail-pf0-x22f.google.com. [2607:f8b0:400e:c00::22f]) by mx.google.com with ESMTPS id k21si1720382pgj.268.2016.10.19.21.14.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Oct 2016 21:14:47 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::22f as permitted sender) client-ip=2607:f8b0:400e:c00::22f; 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::22f as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-pf0-x22f.google.com with SMTP id s8so28011435pfj.2 for ; Wed, 19 Oct 2016 21:14:47 -0700 (PDT) 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=NegtPG8G1pgjmD+bjicqDA6qQK0gjbhVvljHnahrDLA=; b=cqvvveoIb3Y2o+4NCZXMpyUbjXzSLljHjuxRkr6LWfnHC028cKiJ6KKHovv021kyk2 dxEqgFJuWFZXCp0c/t4oN6KT9B60x9fOy55iECW+zJISKX0sTcFs+N422Jw1eJIEmyxT skWVc74tCW+f5M542in9bcUerxD3/kgrq/Bc8= 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=NegtPG8G1pgjmD+bjicqDA6qQK0gjbhVvljHnahrDLA=; b=O+P5W5NMGkp9H4jaq1SJVSBU9pRw+hYob7sXEq5dzdDt7Jmf6d0conqhHAbDotirbH KsW6Q8CDMT1ITdluhuyPEfQXLebvOihcaFXol+cXZ40fu7a+LUZnvjKoB6E7LUZo7RUQ sOspP+GZfuGci7NJPcx1RrWV3KMfvomC4yqexAtncHe2k7a09e8Kf+ffEPDBiYMu2DEP Vf7fDbzjIcjloV8LErLjTZqmd70hc1LEGg/I+w9sxHPQ1xWKVPm58gNmXdg4r19YVqJE mUIhwyuyxeLB/K0cR9WNF6HxBPQpJ8bYw62gRskfKqB5G/45f+rubr7xpGAWZS1PLGyG kwjA== X-Gm-Message-State: AA6/9RmSMRlme5jgqkB/rYgQbKmQvzJTJP0NptrYTlwapC7fSB8zfftW6fQ8hDMyICTxuSi4/Ek= X-Received: by 10.99.215.5 with SMTP id d5mr14344250pgg.131.1476936887353; Wed, 19 Oct 2016 21:14:47 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id g9sm41355655paw.40.2016.10.19.21.14.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Oct 2016 21:14:46 -0700 (PDT) From: John Stultz To: lkml Cc: Chen Yu , Wei Xu , Guodong Xu , Amit Pundir , Rob Herring , John Youn , Douglas Anderson , Greg Kroah-Hartman , linux-usb@vger.kernel.org, John Stultz Subject: [RFC][PATCH 1/2 v2] usb: dwc2: Force port resume on switching to device mode Date: Wed, 19 Oct 2016 21:14:40 -0700 Message-Id: <1476936881-30743-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476936881-30743-1-git-send-email-john.stultz@linaro.org> References: <1476936881-30743-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: 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 df5a065..b374e60 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -54,6 +54,9 @@ #include "core.h" #include "hcd.h" + +static void dwc2_port_resume(struct dwc2_hsotg *hsotg); + /* * ========================================================================= * Host Core Layer Functions @@ -3204,6 +3207,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",