Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752185AbcLFIHk (ORCPT ); Tue, 6 Dec 2016 03:07:40 -0500 Received: from mail-pg0-f51.google.com ([74.125.83.51]:35651 "EHLO mail-pg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752067AbcLFIGc (ORCPT ); Tue, 6 Dec 2016 03:06:32 -0500 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> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1707 Lines: 53 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(+) 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", -- 2.7.4