From patchwork Wed Sep 20 19:57:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 113170 Delivered-To: patches@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1171331qgf; Wed, 20 Sep 2017 12:57:33 -0700 (PDT) X-Received: by 10.84.130.35 with SMTP id 32mr3112580plc.368.1505937453803; Wed, 20 Sep 2017 12:57:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505937453; cv=none; d=google.com; s=arc-20160816; b=Nf/M40b5Pax1rLt7FEvIdQcQu+lJlYZPV9Ng/MmXirml4LUy+ySmcwnDUzLXEDDywz E1MO1Yumc91OqgQxQkVDICvu2/hBMv/K6qyesn+sk5llEh6dFmVLJ6yOQGwM2CAtEEMI ABns4sdybFbh9PVGGce/M9wC6XGqlTxFhAW+xq3WShKBTrUMQHmL5FNvhzwuQQL/09hG +pTBW1r172bkHUQhUkdb2V+BFdwRROFW2919vbgbIWIMsSUSegOscvBvBFgBJP2CfmSm /177h2ll7dAPr88OQU737352E6IZYgm3gYchY4hSAfRt57SgbbMOkI3nbBti3EIZhgAW AxxQ== 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=vreeTt5H6dL+R0fJJeuxucZiVbd7Px180f2ZGzmtpX4a0fFFfFSP/QSHysfGUL7eVQ PeEgUweaOQEy8287mJOUQDlIVNrk8k363G4LyOqULUTAMQmJ1kFlx4VGxHCH9LvIHlmh Wcn2yUuqX5TTxn00zxxd61wZKSworESRkR93REvkkCfr2NoWB/V7Mtz+KOjt9P9t0mTU l/JbG9paHvOxGasukoSv/3N84ja6ptslnLZtmoi5l1Dx+bjVWk+73EC0qNEC/uqBQePX asb3U1nvFtf2JhfzgH3Q+PBPRjHLYGjdjAh1fkrNWOzt1GP2v/yGRLCvZdQneVIJZdYx PTDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EEXoHFgf; 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 i5sor2344776pgt.368.2017.09.20.12.57.33 for (Google Transport Security); Wed, 20 Sep 2017 12:57:33 -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=EEXoHFgf; 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=EEXoHFgfmaqAwhNzjMmooPRPSzKO4yD5fnG5LjdayffLnF2l2SszBuZuzXGTzohJnU AnVHx5N19IHi0YFr4BDvhaOuBxdV8IAp69XO82Pc/rxY25u0/fZbTFqnzRF+Ae2hfDGc 3UGBOxr1Ej0lpzEaLOgy6M17QQ8P4x5ztZFxk= 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=HeJfHzXdS2XPMh/jl1hrtiBeELiYm+VbgwyVqK6dqJkiPKFEtPWCUeagjgtveuNqA6 jQDeUjmYGo3CaNZNuPSb5ajO/exhhgU3t1bS6CDRP6Kafvkh5ma+eRz7lgRtlw/Rjv6j M6lr1tKcBVXBfo4/sp8UYxmvmRydp2C5X3qxKiztZynv9v0SCpfLAB9OK2ArtDTLWw6G V3VsH9/jvZmYltRkCxe/khMVVThvvMJ6eUhHHI3ZAwjh22/5yEKlCQt1sAiQkOb5B/gb G8xZXOl9X8TO11cIwiZTz/ZeHQNFjbsFAEub/uEaV2v8DMhAATwEYVHAYUvjojfsnFui Nxzg== X-Gm-Message-State: AHPjjUhCe1M8bJsZcfaIDAgPTXUBKlQqYBcVeeOpmTA0fcbDhugMjxGS RhVKnIyo7aI2gCsT3cnJX2ds3ZWt X-Google-Smtp-Source: AOwi7QDFAne6TyhYil7FYhx/L3kTgBh98LR8TCKJWIMNUzO0RC1SMXMuj0zo/EP3FDEHKLzt87Z+ag== X-Received: by 10.99.151.2 with SMTP id n2mr3390752pge.315.1505937453483; Wed, 20 Sep 2017 12:57:33 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id i2sm9991660pfd.21.2017.09.20.12.57.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 12:57:32 -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 x2][PATCH 1/3] usb: dwc2: Improve gadget state disconnection handling Date: Wed, 20 Sep 2017 12:57:26 -0700 Message-Id: <1505937448-13475-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505937448-13475-1-git-send-email-john.stultz@linaro.org> References: <1505937448-13475-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);