From patchwork Thu Sep 7 00:30:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 111843 Delivered-To: patches@linaro.org Received: by 10.140.94.239 with SMTP id g102csp54567qge; Wed, 6 Sep 2017 17:31:10 -0700 (PDT) X-Received: by 10.99.0.5 with SMTP id 5mr879976pga.431.1504744270429; Wed, 06 Sep 2017 17:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504744270; cv=none; d=google.com; s=arc-20160816; b=f4Yi4sSLX00NBxwlQOEJtvhQosDTSW91JHhnAs/aJG5kn6dZWOFF3YIRxQHOdezHAZ D3G7eVgbBS/ukA3YitFMc87JkRK+ATmwmTykR5vIekeRPIgETg/+V4A33pWro+2vaBb1 XWgZCFzpEKfnnfFx5Io9rXIyImQJfYpyDewq2DeITeoHppv6cpkLE94RmYq0BeuMI7P1 KsSlByiX0OTrrPhHG4+JZdLNaOGty8rjVDpslImr+4KhKAAHRFfpQRYABjKCyzNmnrLT W0OE68KpEnZnDrhegGg6DKMvUGjQiReCUUJZ3UCQD1mZ1JtTXmYd+YrQuSlBGVS9eyGB qUEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=WzRpO7O4HpoKSNDDao5G6Y7W0aa0YkMXH2f3IzKXZCE=; b=j+e6s058YoOAbxPZwoZfC1QVgQ/beqNmCFuu+nNn3TVRTQZfsXen4YXq+jd5gvgnJk Mxm9VaL/1s/B3SBtK8/7F6SzXtgSEe3VUmLnnXWIl/srkD1JfXCarmzk5Plh3gq2BnN6 f0npcY/UTUJpvv7+sNGuDbjPgZjErnUDDiGcfz3aA4QzvQnwg9XSkR4O8ZiFol+a8Cp6 OcvKoR2Vw21onAle051PI6+pQlfTskfHsdFPG9DGjxY7Glo/lazzlHD9GEjhHSxGiHvx ZBYYC7edfMWnnUuCnZFSRorfkzD0CQGrSpZTD0me/teiZTE3/6huh+Am/4R2XZWDmANm T6PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S7tdJmhO; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id g34sor600500pld.114.2017.09.06.17.31.10 for (Google Transport Security); Wed, 06 Sep 2017 17:31:10 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S7tdJmhO; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=WzRpO7O4HpoKSNDDao5G6Y7W0aa0YkMXH2f3IzKXZCE=; b=S7tdJmhOv9MopwK8zFDyWRlO9eKKmTrwSprYC3R0/w3XmhQ5oc8oFnPLsLa9mYI3ke klIO2+mFi5zBaqAQcb0jtKP10U0tAP6thfHQrudcmoJWlFZu7Ic5pB9XPn7h8p1xlaBO rfOGUuiRBPqP9x0Dt3Xtg4ksV7myLzlLtlin0= 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:in-reply-to :references; bh=WzRpO7O4HpoKSNDDao5G6Y7W0aa0YkMXH2f3IzKXZCE=; b=FNI9wWDhtd+MMKBdNoqhKTmLjscxiq5ApPYQwordBP5PUK4JxRMACvllbWv3POohbQ 20BMDDiAovV/smc1rNB7p07LZ+KqKZyd1Mm2mDaNktcnU/giOlKNuR6D3Ia0ntORl9oi QTmteO285GwWW2uDI3u+ZHWutlLxaud5i7hudqGumftB7NFw8m4uowwaDWjcxtu8x59Y XvHAiqlyb6y9wITEmv2fnz1xBLRDGxT3bnZWaOlupvFBX++SAc9R+pDAXi4LEueZ2GVS 5HVQU9MlxRBbOzBxZHFeP5Kl/H6dnIcwkPg/wRHoEoNhi7CaxsZN/70A0Z9cnmnJryrt +PkQ== X-Gm-Message-State: AHPjjUhq9P7tC+/IFd0vgCagz2TQ6nalfobSsb/ysOCMUtUVPxLrhDjX LELxSc13DWmDsq8N0vg= X-Google-Smtp-Source: ADKCNb6/o02wk5zaH5dOY6ebZWYt0qu3c1gdb56eyzbnAKq98HcDN/jZ6LxbAgJKtcWsC1nvoP7f+Q== X-Received: by 10.84.232.6 with SMTP id h6mr1005904plk.435.1504744270132; Wed, 06 Sep 2017 17:31:10 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id o19sm987378pgn.76.2017.09.06.17.31.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Sep 2017 17:31:08 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Wei Xu , Guodong Xu , Amit Pundir , YongQin Liu , John Youn , Minas Harutyunyan , Douglas Anderson , Chen Yu , Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [RESEND][PATCH 1/3] usb: dwc2: Improve gadget state disconnection handling Date: Wed, 6 Sep 2017 17:30:53 -0700 Message-Id: <1504744255-25281-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504744255-25281-1-git-send-email-john.stultz@linaro.org> References: <1504744255-25281-1-git-send-email-john.stultz@linaro.org> In the earlier commit dad3f793f20f ("usb: dwc2: Make sure we disconnect the gadget state"), I was trying to fix up the fact that we somehow weren't disconnecting the gadget state, so that when the OTG port was plugged in the second time we would get warnings about the state tracking being wrong. The fix there was somewhat simple, as it just made sure to call dwc2_hsotg_disconnect() before we connected things up in OTG mode. But in looking at a different issue I was seeing with UDC state handling, I realized that it would be much better to call dwc2_hsotg_disconnect when we get the state change signal moving to host mode. Thus, this patch removes the earlier disconnect call I added and moves it (and the needed locking) to the host mode transition. Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: YongQin Liu Cc: John Youn Cc: Minas Harutyunyan 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 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index c263114..df54428 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -3277,7 +3277,6 @@ 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); @@ -3296,8 +3295,13 @@ static void dwc2_conn_id_status_change(struct work_struct *work) if (count > 250) dev_err(hsotg->dev, "Connection id status change timed out\n"); - hsotg->op_state = OTG_STATE_A_HOST; + spin_lock_irqsave(&hsotg->lock, flags); + dwc2_hsotg_disconnect(hsotg); + dwc2_hsotg_core_init_disconnected(hsotg, false); + spin_unlock_irqrestore(&hsotg->lock, flags); + + hsotg->op_state = OTG_STATE_A_HOST; /* Initialize the Core for Host mode */ dwc2_core_init(hsotg, false); dwc2_enable_global_interrupts(hsotg);