From patchwork Thu Mar 2 23:36:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 94814 Delivered-To: patches@linaro.org Received: by 10.182.3.34 with SMTP id 2csp513198obz; Thu, 2 Mar 2017 15:36:24 -0800 (PST) X-Received: by 10.84.197.3 with SMTP id m3mr22070429pld.89.1488497784550; Thu, 02 Mar 2017 15:36:24 -0800 (PST) Return-Path: Received: from mail-pf0-x232.google.com (mail-pf0-x232.google.com. [2607:f8b0:400e:c00::232]) by mx.google.com with ESMTPS id i15si8718212pfj.285.2017.03.02.15.36.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 15:36:24 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::232 as permitted sender) client-ip=2607:f8b0:400e:c00::232; 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::232 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-x232.google.com with SMTP id w189so26687459pfb.0 for ; Thu, 02 Mar 2017 15:36:24 -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; bh=mRiqZVWLX00+wlumDaTeIUCez2Q2s4P7qqn0tmCaI3Q=; b=cpdE74Ov4JqKr6plnY9ws591KMo+N2PMxqdTFqYA0G9mrC8xTrITmUTnSeZTGWS2cX Yzba5eunhQH2bGBe6LD06huBZyEd/PcfPgwr/9vf2APYfET8LPWI30Ivzt6Fd0Axb/21 L9rzWk99QlqAimKJY6TrQiOaVzkmCac5Kp1Ag= 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; bh=mRiqZVWLX00+wlumDaTeIUCez2Q2s4P7qqn0tmCaI3Q=; b=GhLIsV3LxQMB1RnbctursNu177/ZkhV3cNug9rzY34lepDHbN1y/aM+dZPcjhnQC1G li458R+HsdTycQm4ZSlq7IExqcQOsR05nFUWWOxVc98AGR0XScZz7gC+Wzv9DxJzj0VA eXl8UQAX/y6uetcw/ylP9IJ0Yfay/CfMLTciAiMVZ9Q0mopG+Ju4PJQZkJkDLwdCSbL/ xNYmjd+fFSSW3JgSaIKGdQbxXWz67YBD7cX2efkQr/NpGqVG+338BHyWuBWna7x3geoS wFRcGmToT4gwUKGAg1VVhXEiizsZ5Ipk1JBKXxE2IYYeK8h1FJST5NwZONnknl8aMWLh JEVg== X-Gm-Message-State: AMke39lCLq+c2ajef9uH6J9ewsX/6Wyow2PtMdxZbyp9y+tC+qydyXBF4AvwQGpC5XJpg1bBWlg= X-Received: by 10.84.178.195 with SMTP id z61mr22548533plb.139.1488497784224; Thu, 02 Mar 2017 15:36:24 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id y184sm19099069pfg.86.2017.03.02.15.36.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Mar 2017 15:36:22 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Wei Xu , Guodong Xu , Amit Pundir , Rob Herring , John Youn , Douglas Anderson , Chen Yu , Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [PATCH] usb: dwc2: Make sure we disconnect the gadget state Date: Thu, 2 Mar 2017 15:36:19 -0800 Message-Id: <1488497779-1894-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 I had seen some odd behavior with HiKey's usb-gadget interface that I finally seemed to have chased down. Basically every other time I pluged in the OTG port, the gadget interface would properly initialize. The other times, I'd get a big WARN_ON in dwc2_hsotg_init_fifo() about the fifo_map not being clear. Ends up if we don't disconnect the gadget state, the fifo-map doesn't get cleared properly, which causes WARN_ON messages and also results in the device not properly being setup as a gadget every other time the OTG port is connected. So this patch adds a call to dwc2_hsotg_disconnect() in the reset path so the state is properly cleared. With it, the gadget interface initializes properly on every plug in. 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 Acked-by: John Youn Signed-off-by: John Stultz --- drivers/usb/dwc2/hcd.c | 1 + 1 file changed, 1 insertion(+) -- 2.7.4 diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index a73722e..91ed5b6 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -3264,6 +3264,7 @@ static void dwc2_conn_id_status_change(struct work_struct *work) dwc2_core_init(hsotg, false); dwc2_enable_global_interrupts(hsotg); spin_lock_irqsave(&hsotg->lock, flags); + dwc2_hsotg_disconnect(hsotg); dwc2_hsotg_core_init_disconnected(hsotg, false); spin_unlock_irqrestore(&hsotg->lock, flags); dwc2_hsotg_core_connect(hsotg);