From patchwork Tue Nov 15 21:47:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 82420 Delivered-To: patches@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1753168qge; Tue, 15 Nov 2016 13:47:43 -0800 (PST) X-Received: by 10.99.111.78 with SMTP id k75mr484076pgc.114.1479246463540; Tue, 15 Nov 2016 13:47:43 -0800 (PST) Return-Path: Received: from mail-pg0-x22d.google.com (mail-pg0-x22d.google.com. [2607:f8b0:400e:c05::22d]) by mx.google.com with ESMTPS id i17si28223051pgj.71.2016.11.15.13.47.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Nov 2016 13:47:43 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22d as permitted sender) client-ip=2607:f8b0:400e:c05::22d; 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::22d as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x22d.google.com with SMTP id x23so68131661pgx.1 for ; Tue, 15 Nov 2016 13:47:43 -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=9aTok5E3Q10ZpugegaTHzwcHotSSY9ZoQ368Tk/HnPI=; b=gIr5alJseGSBohNapLEi1pdj2qgWvjhZYVNBj3nL90lfrBzq9Om8yOzt+lQvjrpfQd 4hGCZ1e3HwxfqrTqavuzirn5nROpAsG/U8AePZDzp249Zq5avXFwhdO1KGYAWfoI/P8l wCjFftcBGQTQ/be3TZeEHAYrZpYXQOjpT/Pso= 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=9aTok5E3Q10ZpugegaTHzwcHotSSY9ZoQ368Tk/HnPI=; b=GCh8v2R3pPQfyOpnMNvC0syHv8J6HqMh2GgQTp0ANIQjlqyOXmfgjzybNsKGPaLDXs DVnJ5XSOgSne3ifRXEiEQqAl77nsu4jbqoFb9205LZcKPZDPO5/nJ/ZdqvvDzNyy0QvY eXPwkYd30pfTU4sdx5+Exuj5U9H6z3J00nlKKQuWNuIPqc+VXM5hsLI0MgibkldUJVFi 7XzfbVDW9cTGsS/sZszUk3BsRrLmrja55g4YxLFYDIR1IyJdILY+eT53zrOVValWTUm9 NCC8T9w95FhEhPlBwWipBP52lN52JP31y/XXewA7p2VNFf15DEMhSX9gzs9iQiJU01md 7vww== X-Gm-Message-State: ABUngvcn5ZYQiX/pLysXjwpJeZmVcGZAR+Cw9TOivkTGe7iZ41yVhV2D+E7L6CZp5Q8/9BVigAA= X-Received: by 10.99.60.11 with SMTP id j11mr482925pga.26.1479246463263; Tue, 15 Nov 2016 13:47:43 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id q9sm46049156pfg.47.2016.11.15.13.47.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Nov 2016 13:47:42 -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: [RFC][PATCH 3/3] usb: dwc2: Make sure we disconnect the gadget state Date: Tue, 15 Nov 2016 13:47:36 -0800 Message-Id: <1479246456-21652-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479246456-21652-1-git-send-email-john.stultz@linaro.org> References: <1479246456-21652-1-git-send-email-john.stultz@linaro.org> 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 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 8c980fd..d2557b7 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -3228,6 +3228,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);