From patchwork Thu Aug 17 19:03:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 110342 Delivered-To: patches@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2577033obb; Thu, 17 Aug 2017 12:03:21 -0700 (PDT) X-Received: by 10.99.101.132 with SMTP id z126mr5912584pgb.64.1502996601696; Thu, 17 Aug 2017 12:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502996601; cv=none; d=google.com; s=arc-20160816; b=l/X2XUNnI7oSsZ4fwbTK3alOhwcheKbyabQIeDcC04kO2W+JOkzpczNY4Y28fUq1/L eyuVBW5NLe+N+Z3pojXTT6T/PHQmsj4TJ2BRS6SiT4K2sM62KfksoOEucHk0sth62U/X kfJzxMQfyBxs5RSm/RC6csgES7BVw2h8ktKx7Q5d85eYR67cKlKV25C51YruO3I7rJr8 ++QEN9hECBi2jPSMiChHmr4PEc6TBF3ZFAkJzteD48yaLvZVrUH7L6/Nlr61dhekgurR WmeiSj3AbESfXwyPIA++gced5h12DXI1PHTlG0iIwiSrhstx4wtK/UQeegm0YDjpatlQ Hojg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=c29vbxC3j1E7I8DBLoD//Exs53JKsggjaCVeKmVsiKQ=; b=Fi4FLiU43OwfIiHAT3jsJndMbY+jBK4k7Bs2qSoD6MBUezj43duGgZ6wARQ9J5N5fD +0l4s1U8EAAPzCnQ2aRMXOQHPh9ezoEwRafWCpo/Iq3wLcHg66m6VewxaiWvIO8KgD3y cNZMhUpnoGRs17uy3HloWz6TFsJoHBA0F30FSOLld8YKbZ5I1h1eeKavkGiFbGmEyE6P MUuDMvNwM/Pic/nIe9LxNAXvE/iWtVYnzQ79Dxn5FyUVnbifaBK2L6447CxnCjkZ5P4y aQFX+g2mCS2YeF1qZAkKZtVDT3kFIu5SzQBxJqfL0EfDWjyJg0Qw+1YRWLjS20tV2g4O QYGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HVZaGl8d; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::236 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-pg0-x236.google.com (mail-pg0-x236.google.com. [2607:f8b0:400e:c05::236]) by mx.google.com with ESMTPS id u15si2649284plk.465.2017.08.17.12.03.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Aug 2017 12:03:21 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::236 as permitted sender) client-ip=2607:f8b0:400e:c05::236; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HVZaGl8d; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::236 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-x236.google.com with SMTP id v189so48511214pgd.2 for ; Thu, 17 Aug 2017 12:03:21 -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=c29vbxC3j1E7I8DBLoD//Exs53JKsggjaCVeKmVsiKQ=; b=HVZaGl8d4LyKjgtz1XZFnCebAPaLyFBp4CTfhMFjoIB/8EhZwRNsEPJgtGHEvwLTej Ym3xD5Q1l2cxeCaZzz1gPg8CxuUSCdDFGQtHEsBd5bq4sJJNS+uStcU+uBVpDPcLSe1v 5tSv858CZPuXbqkhe5RuE4i6gsZeg6+j0K33s= 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=c29vbxC3j1E7I8DBLoD//Exs53JKsggjaCVeKmVsiKQ=; b=KvBvj/TVwSjY4ti1Aso5p5ACZIFqwRdzA3Ql7vUT1pWmmtRiO3a7/m0Y0JCROcbjGW LxeFHHCBTwgLUfhNiqMrYCoOcTDrXNZIszqdKuWXOh+JcWhIHMh3bQoXolDdakC9wfta /8gacbQeQ4ugKNIYmmtu6FhXzq1ncjsdMsrgIMkvD+9HXyKUHxUE71AYx/SQZXmQZXvv IoFUkzRjwKZ5WfFhjA/ZB9Fgo1wiYK0nqLWIeCIQzRyk0RfJrI9RtB0IQWGae0ilZmq0 8xQ7JG/Istb4GwcIIsi7JJ6U3ibzYms9VwURk+OjhaxfIm4byoGU/RMyvRsvPMAdr0ZH 4CmQ== X-Gm-Message-State: AHYfb5iOdFmj+yV7/bwLXRDBlOVwvBT/lQ+TRLxPZhjZTO0R6WhpUEgY 86n8OW4HVbQKFdzYDu4= X-Received: by 10.99.107.72 with SMTP id g69mr6072874pgc.85.1502996601275; Thu, 17 Aug 2017 12:03:21 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id r86sm9337806pfi.161.2017.08.17.12.03.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Aug 2017 12:03:19 -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: [PATCH 1/3] usb: dwc2: Improve gadget state disconnection handling Date: Thu, 17 Aug 2017 12:03:13 -0700 Message-Id: <1502996595-15316-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 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 740c7e8..9fd84a9 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);