From patchwork Thu Oct 20 06:00:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 78406 Delivered-To: patches@linaro.org Received: by 10.140.97.247 with SMTP id m110csp614028qge; Wed, 19 Oct 2016 23:00:46 -0700 (PDT) X-Received: by 10.99.111.2 with SMTP id k2mr15200004pgc.136.1476943246322; Wed, 19 Oct 2016 23:00:46 -0700 (PDT) Return-Path: Received: from mail-pf0-x22c.google.com (mail-pf0-x22c.google.com. [2607:f8b0:400e:c00::22c]) by mx.google.com with ESMTPS id m64si43529211pfb.184.2016.10.19.23.00.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Oct 2016 23:00:46 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::22c as permitted sender) client-ip=2607:f8b0:400e:c00::22c; 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::22c as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-pf0-x22c.google.com with SMTP id r16so29809360pfg.1 for ; Wed, 19 Oct 2016 23:00:46 -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; bh=ZEyze6BQEcMBcYeHhov56v0r9YFo5dUd4gfMEC95eLk=; b=Gm4WY6STSkjLISMv4PNOlc09mD7e7HdrcWyUiTlJHc806R5qbyJGmck4YMWyvqbuNb VqDRMn0CzrZzxXt2jqsoRYiEJ50+RUAYTUZ2PNSWEh4zSTQFKeA6qSorMkasuPCw/mOP IRQGprgb7AvfwF6nNN3oBl9K5ed6NiJ1fnc2E= 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; bh=ZEyze6BQEcMBcYeHhov56v0r9YFo5dUd4gfMEC95eLk=; b=ix5Z3fCCAlQ1RrrF7O60rJgI95NAGckYsl0KjCAgyqSJAKCkOeWpOoioXbgPMuIemY Wtc2vIEfeq7RDQIdm96HH/ss6G9IrHrE1LgfEPFd/0S4VdF1nG9dircWRF4iq0z8t/gL kMI54hcMsEPXkizwRSjTbyk0HA6U6XlGCTKPlXnkHI4tv56uYdvXQs010CoIkcK/c+VQ pnhrPEkcgDrbVOPhznhHO781+p6lwOHBpI8E3UMNSH3oydUPeGBG6G3haA11HHJyQ6RN g/Hn7WirL52DIUiDnpNemnzVUZT///jdpesX2pwlfQIZZtGDsqxdU6G8aYqokc984w2r i6gQ== X-Gm-Message-State: AA6/9Rls2dO3V9kW7faystK8xVqmsKTfSwwaQRS3uCG5XTbt/4vqxD/99dqyuOa631acSca7n4w= X-Received: by 10.99.36.65 with SMTP id k62mr14851461pgk.88.1476943245970; Wed, 19 Oct 2016 23:00:45 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id v86sm68004236pfa.91.2016.10.19.23.00.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Oct 2016 23:00:45 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Wei Xu , Guodong Xu , Chen Yu , Amit Pundir , Rob Herring , Mark Rutland , John Youn , Douglas Anderson , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [RFC][PATCH] usb: dwc2: Make sure we disconnect the gadget state on reset Date: Wed, 19 Oct 2016 23:00:41 -0700 Message-Id: <1476943241-31810-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 on reset, 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. I don't know if this is actually the right fix, but it seems to work well. Feedback would be greatly appreciated! Cc: Wei Xu Cc: Guodong Xu Cc: Chen Yu Cc: Amit Pundir Cc: Rob Herring Cc: Mark Rutland Cc: John Youn Cc: Douglas Anderson Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Signed-off-by: John Stultz --- drivers/usb/dwc2/gadget.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.7.4 diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 24fbebc..5505001 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2519,6 +2519,8 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, /* Kill any ep0 requests as controller will be reinitialized */ kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET); + /* Make sure everything is disconnected */ + dwc2_hsotg_disconnect(hsotg); if (!is_usb_reset) if (dwc2_core_reset(hsotg))