From patchwork Thu Mar 30 03:23:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 96217 Delivered-To: patches@linaro.org Received: by 10.140.89.233 with SMTP id v96csp47907qgd; Wed, 29 Mar 2017 20:23:41 -0700 (PDT) X-Received: by 10.98.61.5 with SMTP id k5mr3687329pfa.229.1490844221612; Wed, 29 Mar 2017 20:23:41 -0700 (PDT) Return-Path: Received: from mail-pg0-x233.google.com (mail-pg0-x233.google.com. [2607:f8b0:400e:c05::233]) by mx.google.com with ESMTPS id m19si778524pfk.255.2017.03.29.20.23.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Mar 2017 20:23:41 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::233 as permitted sender) client-ip=2607:f8b0:400e:c05::233; 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::233 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x233.google.com with SMTP id g2so25361898pge.3 for ; Wed, 29 Mar 2017 20:23:41 -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=vclAFAr0pDh62sEvOKvk81uar4YIXj366m1vbZPbdTg=; b=IUo1VzQFFGs3qEFlJsvILvz5PH7Qs1kwq0JhQMP8GPaCCyRlk9jBpecPpn7tRO8m9n WZuFb7KLZFcSKzkBQPLnkCRspzsMkPjdAOJMftp6921ZYYbsrOuIRlyXEppy7kgLhD5U dxy6Xn0zROyxkDfbbZJ0G5btMWShcckonjdNk= 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=vclAFAr0pDh62sEvOKvk81uar4YIXj366m1vbZPbdTg=; b=XlfmNowEJ7/QMP0UXukOlDDim4QndkGoNAeI/8kbiJrWHaTbq0shqWnFIu6ex60dta 78XQIWHAbV83WYGNHO8QGGlx9lkMzMLKS/v5Wergp76/yX8WAydMDcakXNe3brieFaZ7 5fJ4k1CmtF2+oO8BZq2d3ik0xTgoWryp9hxFJdSdJqOqwPRFTB8DtIyO4PL1zG6gn+Um ACW+M+9KXwssXdx6R3Yx0X/0F42y/X8l3p8taMtufRf+rOXXS2wNN1o2Vtif06sFiODZ po6FLNKz0bMYRoyiQ7wvUPBwPktGBcgaWlgo3CB76QGUotDmKwp9O5p4MaQtlIg4sBOP ojzA== X-Gm-Message-State: AFeK/H1Yd75QdopS2Pot+6Mf3zg6Iqo7Xbd7x2PmPMlVYuv0yJ1EPltDbuXU8W6DLa9WMI1Ni+Y= X-Received: by 10.84.131.79 with SMTP id 73mr4250315pld.45.1490844221158; Wed, 29 Mar 2017 20:23:41 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id v186sm815775pgv.44.2017.03.29.20.23.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Mar 2017 20:23:39 -0700 (PDT) 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 v2] usb: dwc2: Make sure we disconnect the gadget state Date: Wed, 29 Mar 2017 20:23:36 -0700 Message-Id: <1490844216-32085-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 plugged 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 --- v2: Minor typo fix suggested by Sergei Shtylyov --- 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);